I try to implement a custom HoverProvider according to this tutorial: enter link description here
However, I'm stuck translating to Java code of MyDSLUiModule
to Xtend.
The register-method should read like this:
def Class<? extends IEObjectDocumentationProvider> bindIEObjectDocumentationProviderr() {
return MyDSLHoverProvider.class
}
However, this doesn't compile since MyDSLHoverProvider
only implements
the IEObjectDocumentationProvider
but not extend
this class (MyDSLHoverProvider
is the same as in the tutorial).
Therefore this error is thrown:
Type mismatch: cannot convert from Class<? extends Class> to Class<? extends IEObjectDocumentationProvider>
How can I get around this error?
Btw: If I test my DSL in an Eclipse instance, I get a wierd NPE:
!ENTRY org.eclipse.oomph.setup.ui 2 0 2016-09-16 16:42:34.203 !MESSAGE java.lang.NullPointerException !STACK 0 java.lang.NullPointerException at org.eclipse.oomph.setup.ui.SetupUIPlugin.performStartup(SetupUIPlugin.java:373) at org.eclipse.oomph.setup.ui.SetupUIPlugin.access$4(SetupUIPlugin.java:344) at org.eclipse.oomph.setup.ui.SetupUIPlugin$1$1.run(SetupUIPlugin.java:241) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
I have no clue where this exception comes from.
The class MyDSLHoverProvider looks like this:
import org.eclipse.emf.ecore.EObject
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider
class MyDSLHoverProvider implements IEObjectDocumentationProvider {
override getDocumentation(EObject o) {
println("Hover: " + o)
if (o instanceof MyFieldElements) {
return "This is a nice Greeting with nice <b>markup</b> in the <i>documentation</i>";
}
}
}
Edit: I found a way to display the tooltips, but it seems strange. A tooltip is shown for this rule:
name = ID
but if I rename it to
myField = ID
the tooltip is not triggered.
Is this the expected behaviour?
the correct Xtend syntax is
def Class<? extends IEObjectDocumentationProvider> bindIEObjectDocumentationProviderr() {
return MyDSLHoverProvider
}
or
def Class<? extends IEObjectDocumentationProvider> bindIEObjectDocumentationProviderr() {
MyDSLHoverProvider
}
MyDSLHoverProvider.class
is the same as MyDslHoverProvider.class.getClass()
in Java