Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #68 from dragos/master

Only display problem annotations in the hover.
  • Loading branch information...
commit fc2b2a62869eb61a8269525c4d8a70110521e643 2 parents 25189ca + 4018566
@dragos dragos authored
View
2  .gitignore
@@ -1,3 +1,5 @@
.cache
target/
.settings/
+.target/
+.worksheet/
View
6 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")
}
View
13 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)
View
9 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")
}
Please sign in to comment.
Something went wrong with that request. Please try again.