From 68160fbee4ff477f5fbaf506ffe52d466178a3ba Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Thu, 4 Apr 2013 14:12:48 +0200 Subject: [PATCH 1/2] Only display problem annotations in the hover. By default, other annotations (like "2 lines added") are also displayed on the annotation ruler. We rule them out in the template editor. --- .../src/org/scalaide/play2/PlayProject.scala | 6 ++++-- .../templateeditor/TemplateConfiguration.scala | 13 +++++++------ .../play2/templateeditor/TemplateEditor.scala | 9 ++++++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/org.scala-ide.play2/src/org/scalaide/play2/PlayProject.scala b/org.scala-ide.play2/src/org/scalaide/play2/PlayProject.scala index 295c3501..919cd754 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/PlayProject.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/PlayProject.scala @@ -46,8 +46,10 @@ class PlayProject private (val scalaProject: ScalaProject) { presentationCompiler.destroy() } - /** - * It has the source directory of scala template files + /** FIXME: This method should probably not exist. + * Template files can be anywhere + * + * @return the absolute location of the `/app/views` directory, below the project root */ lazy val sourceDir = new File(scalaProject.underlying.getLocation().toString() + "/app/views") } diff --git a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/TemplateConfiguration.scala b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/TemplateConfiguration.scala index 3e81a477..e2694315 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/TemplateConfiguration.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/TemplateConfiguration.scala @@ -39,6 +39,7 @@ import scala.tools.eclipse.lexical.ScalaPartitions import org.eclipse.jdt.ui.text.IJavaPartitions import scala.tools.eclipse.ui.BracketAutoEditStrategy import org.eclipse.jdt.internal.ui.text.java.SmartSemicolonAutoEditStrategy +import org.eclipse.jface.text.source.Annotation class TemplateConfiguration(prefStore: IPreferenceStore, templateEditor: TemplateEditor) extends TextSourceViewerConfiguration with PropertyChangeHandler { @@ -64,12 +65,6 @@ class TemplateConfiguration(prefStore: IPreferenceStore, templateEditor: Templat TemplatePartitions.getTypes() } - /** Necessary for hover over annotations - */ - override def getAnnotationHover(viewer: ISourceViewer): IAnnotationHover = { - new DefaultAnnotationHover(true) - } - /** Necessary for code completion */ override def getContentAssistant(sourceViewer: ISourceViewer): IContentAssistant = { @@ -118,6 +113,12 @@ class TemplateConfiguration(prefStore: IPreferenceStore, templateEditor: Templat Array(detector, localDetector) } + override def getAnnotationHover(viewer: ISourceViewer): IAnnotationHover = { + new DefaultAnnotationHover(true) { + override def isIncluded(a: Annotation): Boolean = TemplateEditor.annotationsShownInHover(a.getType) + } + } + override def getTextHover(sv: ISourceViewer, contentType: String, stateMask: Int): ITextHover = { if (templateEditor != null && contentType.equals(TemplatePartitions.TEMPLATE_SCALA)) { val cu = TemplateCompilationUnit.fromEditor(templateEditor) diff --git a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/TemplateEditor.scala b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/TemplateEditor.scala index a53d629c..12aeec7a 100644 --- a/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/TemplateEditor.scala +++ b/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/TemplateEditor.scala @@ -20,11 +20,12 @@ import org.eclipse.ui.editors.text.TextEditor import org.eclipse.ui.texteditor.ChainedPreferenceStore import org.scalaide.play2.PlayPlugin + class TemplateEditor extends TextEditor with ISourceViewerEditor with InteractiveCompilationUnitEditor { private lazy val preferenceStore = new ChainedPreferenceStore(Array((EditorsUI.getPreferenceStore()), PlayPlugin.prefStore)) private val sourceViewConfiguration = new TemplateConfiguration(preferenceStore, this) private val documentProvider = new TemplateDocumentProvider() - + setSourceViewerConfiguration(sourceViewConfiguration); setPreferenceStore(preferenceStore) setDocumentProvider(documentProvider); @@ -70,4 +71,10 @@ class TemplateEditor extends TextEditor with ISourceViewerEditor with Interactiv annotationModel.replaceAnnotations(previousAnnotations.toArray, newAnnotations.toMap.asJava) previousAnnotations = newAnnotations.unzip._1 } +} + +object TemplateEditor { + /** The annotation types shown when hovering on the left-side ruler (or in the status bar). */ + val annotationsShownInHover = Set( + "org.eclipse.jdt.ui.error", "org.eclipse.jdt.ui.warning", "org.eclipse.jdt.ui.info") } \ No newline at end of file From 40185661af8b0ca52a42ef4e62edef4327ddfd3f Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Thu, 4 Apr 2013 14:19:17 +0200 Subject: [PATCH 2/2] Ignore more non-git files. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 5b20a9f7..60285da3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .cache target/ .settings/ +.target/ +.worksheet/ \ No newline at end of file