Community
Participate
Working Groups
Build Identifier: AbstractJavaBasedContentProposalProvider.DefaultProposalCreator creates completion proposals based on corresponding IEObjectDescriptions. In particular, it sets 'additionalProposalInfo' to the IEObjectDescription's 'eObjectOrProxy'. In case where the IEObjectDescription in question comes from the index (i.e. it is an EObjectDescriptionImpl), that 'additionalProposalInfo' will always be a proxy. That proxy will be used when ConfigurableCompletionProposal attempts to obtain hover info (in #getAdditionalProposalInfo(IProgressMonitor) method), delegating some parts of computation to such components as IQualifiedNameProvider and ILabelProvider. In most cases, implementations of those components are not prepared to deal with proxies (and more importantly, they fundamentally cannot do well with proxies - usually they have no context against which the proxies could be resolved). For example, DefaultDeclarativeQualifiedNameProvider (if not overriden) just returns 'null' for the proxy, so DefaultEObjectHoverProvider decides there is no hover (in #hasHover(EObject) method). See the call stack attached. Note that if e.g. a custom implementation of IQualifiedNameProvider is used, it may fail on proxies even less gracefully, leading to runtime exceptions thrown directly on the user. Reproducible: Always Steps to Reproduce: 1. Import the attached projects 'org.xtext.example.dmodel' and 'org.xtext.example.dmodel.ui' into the workspace 2. Run the runtime workbench and import the attached project 'example' into the runtime workspace 3. Open 'Bar.dmodel' and invoke content assist after the 'extends' clause. Note that there is a hover for 'Bar', but no hover for 'Foo'
Created attachment 202410 [details] call stack
Created attachment 202411 [details] Sample language projects
Created attachment 202412 [details] 'example' project
We'd have to load the resource for the currently selected proposal and extract the documentation on demand.
I am a little bit scared to resolve the currently selected proposal. I would suggest to avoid hovercomputation for proxies with a guard in the DefaultEobjectHoverprovider. If someone would like to have such things a custom hoverprovider is the way to go. For Xbase I already introduced this guard.
Well only the documentation of the selected proposal will be displayed and therefore only the proxy has to be resolved. I don't think this imposes a problem. Why did you introduce the guard in Xbase? Did you face any problems with resource loading?
I introduced the guard to avoid Nullpointer because at the moment we do not resolve proxies. But when this is the way to go I will remove it and introduce the proxy resolution. Do not see problems with resource loading. Just was a little bit scared to resolve proxies to show hover on proposals. We will see if it is expensive or not.
This issue is causing a NullPointer exception in the example arithmetics project provided with Xtext. If you import a module, all of the definitions in the imported module result in NullPointerExceptions being thrown in the log and no hover window being displayed. Steps to reproduce: 1. File->New->Xtext->arithmetic example. 2. Launch workspace and create Java Project adding Xtext nature 3. Create lib.calc with the following: module lib def abc(a,b): a+b; 4. Create main.calc with the following: module main import lib def xxx(a,b): a-b; 5. Open up main.calc and invoke content assist at the end of the file after the def xxx. Content proposals window is shown including both abc and xxx. NullPointerException should be immediately throw as abc should be selected in the proposal list. Each time the proposal list changes to abc, the exception is thrown. Stack Trace: !ENTRY org.eclipse.jface.text 2 0 2012-07-04 11:29:35.639 !MESSAGE !STACK 0 java.lang.NullPointerException at org.eclipse.xtext.example.arithmetics.arithmetics.util.ArithmeticsSwitch.doSwitch(ArithmeticsSwitch.java:58) at org.eclipse.xtext.example.arithmetics.scoping.NameProvider$1.caseDefinition(NameProvider.java:43) at org.eclipse.xtext.example.arithmetics.scoping.NameProvider$1.caseDefinition(NameProvider.java:1) at org.eclipse.xtext.example.arithmetics.arithmetics.util.ArithmeticsSwitch.doSwitch(ArithmeticsSwitch.java:119) at org.eclipse.xtext.example.arithmetics.arithmetics.util.ArithmeticsSwitch.doSwitch(ArithmeticsSwitch.java:72) at org.eclipse.xtext.example.arithmetics.arithmetics.util.ArithmeticsSwitch.doSwitch(ArithmeticsSwitch.java:58) at org.eclipse.xtext.example.arithmetics.scoping.NameProvider.getFullyQualifiedName(NameProvider.java:66) at org.eclipse.xtext.ui.editor.hover.html.DefaultEObjectHoverProvider.hasHover(DefaultEObjectHoverProvider.java:103) at org.eclipse.xtext.ui.editor.hover.html.DefaultEObjectHoverProvider.getHoverInfoAsHtml(DefaultEObjectHoverProvider.java:76) at org.eclipse.xtext.ui.editor.hover.html.DefaultEObjectHoverProvider.getHoverInfo(DefaultEObjectHoverProvider.java:91) at org.eclipse.xtext.ui.editor.hover.html.DefaultEObjectHoverProvider$2.getInfo(DefaultEObjectHoverProvider.java:519) at org.eclipse.xtext.ui.editor.hover.DispatchingEObjectTextHover.getHoverInfo(DispatchingEObjectTextHover.java:38) at org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal.getAdditionalProposalInfo(ConfigurableCompletionProposal.java:540) at org.eclipse.jface.text.contentassist.AdditionalInfoController$3.run(AdditionalInfoController.java:106) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Moved issue from comment #8 to bug 384334
pushed fix and test to master
Requested via bug 522520. -M.