Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Hovers on keywors crashes(Implementation of Hovers on Keywords fails due to injector)
Hovers on keywors crashes [message #1786619] Tue, 08 May 2018 14:10 Go to next message
Adrian Yankov is currently offline Adrian YankovFriend
Messages: 13
Registered: March 2018
Junior Member
Hello, everyone.

I followed this tutorial to create Hover over keywords:

https://blogs.itemis.com/en/xtext-usability-hovers-on-keywords

However, when I run my new Eclipse instance I get :

Caused by: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException

I have registered the hoverproviders:

def Class<? extends IEObjectHoverProvider> bindIEObjectHoverProvider() {
MyXbaseHoverProvider
}


override Class<? extends IEObjectHover> bindIEObjectHover() {
MyXbaseDispatchingEObjectTextHover
}

If I comment out the first one, the new Eclipse instance does not crash.

Can you please help with what I am forgetting?

Kind regards,
Adrian

Re: Hovers on keywors crashes [message #1786623 is a reply to message #1786619] Tue, 08 May 2018 17:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12233
Registered: July 2009
Senior Member
it would be nice if you could give more details about your implementations.

e.g. the name xbase and a missing override confuses me


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Hovers on keywors crashes [message #1786665 is a reply to message #1786623] Wed, 09 May 2018 07:11 Go to previous messageGo to next message
Adrian Yankov is currently offline Adrian YankovFriend
Messages: 13
Registered: March 2018
Junior Member
Dear Christian,

I copy pasted the exact same code as in the tutorial. The only thing I changed was registering the Hovers, because in the original it was Java and
now it is Xtend. The quickfix said I needed to add override in front of the second class. The first one did not require it.

I assume it has something to do with com.google.inject not being loaded correctly. Right now it is an import
import com.google.inject.Inject;


Unfortunately, I cannot share the complete project.

Greetings,
Adrian
Re: Hovers on keywors crashes [message #1786673 is a reply to message #1786665] Wed, 09 May 2018 08:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12233
Registered: July 2009
Senior Member
does you language use xbase or not. if not you should inherit from the non xbase baseclasses

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Hovers on keywors crashes [message #1786674 is a reply to message #1786673] Wed, 09 May 2018 08:30 Go to previous messageGo to next message
Adrian Yankov is currently offline Adrian YankovFriend
Messages: 13
Registered: March 2018
Junior Member
I do not have any Xbase classes.

Which one should I replace it with?

BTW,
I changed my manifest.file in the UI and added

Import-Package: com.google.inject;version="1.4.0",
com.google.inject.binder;version="1.4.0",
com.google.inject.internal,
com.google.inject.internal.util,
com.google.inject.matcher;version="1.4.0",
com.google.inject.name;version="1.4.0",
com.google.inject.spi;version="1.4.0",
com.google.inject.util;version="1.4.0",

Now I just get FrameworkError.
Re: Hovers on keywors crashes [message #1786676 is a reply to message #1786674] Wed, 09 May 2018 08:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12233
Registered: July 2009
Senior Member
DefaultEObjectHoverProvider and DispatchingEObjectTextHover

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Hovers on keywors crashes [message #1786678 is a reply to message #1786676] Wed, 09 May 2018 08:44 Go to previous messageGo to next message
Adrian Yankov is currently offline Adrian YankovFriend
Messages: 13
Registered: March 2018
Junior Member
The new instance runs.
However, I had to change the label provider to getLabelProvider()
public class MyXbaseHoverProvider extends DefaultEObjectHoverProvider {
/** Utility mapping keywords and hovertext. */
@Inject MyKeywordHovers keywordHovers;

@Override
protected XtextBrowserInformationControlInput getHoverInfo(EObject obj, IRegion region, XtextBrowserInformationControlInput prev) {
if (obj instanceof Keyword) {
String html = getHoverInfoAsHtml(obj);
if (html != null) {
StringBuffer buffer = new StringBuffer(html);
HTMLPrinter.insertPageProlog(buffer, 0, getStyleSheet());
HTMLPrinter.addPageEpilog(buffer);
return new XtextBrowserInformationControlInput(prev, obj, buffer.toString(),getLabelProvider());
}
}
return super.getHoverInfo(obj, region, prev);
}

@Override
protected String getHoverInfoAsHtml(EObject o){
if (o instanceof Keyword)
return keywordHovers.hoverText((Keyword) o);
return super.getHoverInfoAsHtml(o);
}
}

I will try and see if it works.
Re: Hovers on keywors crashes [message #1786679 is a reply to message #1786678] Wed, 09 May 2018 08:49 Go to previous messageGo to next message
Adrian Yankov is currently offline Adrian YankovFriend
Messages: 13
Registered: March 2018
Junior Member
class MyKeywordHovers {
@Inject SomeGrammar ga;
def hoverText(Keyword k) {
val result = switch (k) {
case ga.somethingBlablaAccess.someKeyword_0:'''
An entity represents real business objects. It <ul>
<li>can <code>extend</code> another entity,i.e. inherit the features of another entity.</li>
<li>has attributes, specification syntax <code><name> : <type></code></li>
<li>has operations, specification syntax <code>op <name> (<List of Parameters>)) : <Returntype></code></li>
</ul>
'''
}
result.toString;
}
}

I have this as a class that gives information. When I hover over it, nothing happens. I suspect that the getLabelProvider() does not work, or something is wrong in the code.

If I hover over an other keyword it says that I get:
Error on computation of hover information. No hover information available for org.eclipse.xtext.impl.KeywordImpl@6d6cbe5c (cardinality: null, predicated: false, firstSetPredicated: false) (value: Metric) at offset: 217, length: 6
java.lang.NullPointerException
Re: Hovers on keywors crashes [message #1786681 is a reply to message #1786679] Wed, 09 May 2018 08:56 Go to previous message
Adrian Yankov is currently offline Adrian YankovFriend
Messages: 13
Registered: March 2018
Junior Member
I tried for a different keyword and it worked!

THANK YOU VERY MUCH ONE MORE TIME!
Previous Topic:Xbase DSL library without source?
Next Topic:Generated project tries to access missing URL
Goto Forum:
  


Current Time: Fri Sep 21 06:16:24 GMT 2018

Powered by FUDForum. Page generated in 0.01873 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top