I setup the hover for the elements of my DSL properly using these two classes:
MyDslEObjectDocumentationProvider
MyDslEObjectHoverProvider
I need to add hover for some elements that are imported by my dsl too.
I have tried to add an if in the getFirstLine method of MyDslEObjectHoverProvider, but its never reached. For any element of my dsl it is working right:
protected String getFirstLine(EObject o) {
String label = qualifiedNameProvider.getFullyQualifiedName(o)
.toString();
if (o instanceof AnImportedElement)
return myDslUtils.retrieveHoverFirstLineAnImportedElement(
(AnImportedElement) o, label);
you usually to this in the dsl that provides the elements.
never the less: you may have a look at org.eclipse.xtext.ui.editor.hover.DispatchingEObjectTextHover.getHoverInfo(EObject, ITextViewer, IRegion)
there you can see that the stuff is done language specific. and i might be a place to hook in.