Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » F3/Open Declaration disabled on cross references
F3/Open Declaration disabled on cross references [message #926252] Fri, 28 September 2012 13:13 Go to next message
Olivier Petri is currently offline Olivier Petri
Messages: 9
Registered: July 2012
Junior Member
Hello,

we've got several Xtext projects here, using the cross reference feature. Some do allow to use F3 to jump to the declaration (and "Open Declaration" is enabled in the context menu), some do not ("Open Declaration" is disabled and greyed out). Funny enough, Ctrl+mouse does work in both cases! I've been looking around in code and internet, but I can not find a clue to explain the difference in behaviour. The documentation reads as if both (F3 and Ctrl+mouse) was handled the same way (http://www.eclipse.org/Xtext/documentation.html#hyperlinking), but this is seemingly not the case.

Any hint is appreciated.

Regards,

Olivier
Re: F3/Open Declaration disabled on cross references [message #926302 is a reply to message #926252] Fri, 28 September 2012 14:09 Go to previous messageGo to next message
Christian Dietrich is currently online Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi you may have a look into the HyperlinkDetector/HyperlinkHelper

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: F3/Open Declaration disabled on cross references [message #929284 is a reply to message #926302] Mon, 01 October 2012 10:46 Go to previous messageGo to next message
Olivier Petri is currently offline Olivier Petri
Messages: 9
Registered: July 2012
Junior Member
Hi Christian,

Thanks for your fast reply.

I did investigate in the direction you have indicated, but any of:

  • IHyperlinkHelper.createHyperlinksByOffset()
  • HyperlinkHelper.createHyperlinksTo()
  • IHyperlinkDetector.detectHyperlinks()

is called only for ctrl+mouse where only ctrl+mouse works and for both, ctrl+mouse and F3, where both work. In other words, it is too late at those points.

I do not think its a key binding problem though, since the "Open Declaration" item is disabled in the "F3 does not work" case, and not simply missing (plus the disabled menue item shows the F3 shortcut).

For similar reasons it does not seem to be very likely that I am facing an event propagation problem, like hitting F3 being swallowed by the SemanticHighlighter or something: If it was that, I'd expect the "Open Declaration" context menu to be enabled but not responding.

Thus I assume Xtext is not registering the defining rules of the cross references in question as "Declarations" upon Eclipse. Pure speculation of corse.

I'd be happy if I had made an obvious mistake in the definition of the cross referencable rule, but what can go wrong in this?:

ExampleItem:
   (optionalStuff = STRING)?
   'ExamplKeyWord' name = ID
   '(' SomeMoreStuff ')'
;

ExampleUse:
   exampleCall = [ ExampleItem ] '(' YetMoreStuff ')'
;


Best regards,

Olivier

[Updated on: Mon, 01 October 2012 11:12]

Report message to a moderator

Re: F3/Open Declaration disabled on cross references [message #929486 is a reply to message #929284] Mon, 01 October 2012 13:52 Go to previous messageGo to next message
Olivier Petri is currently offline Olivier Petri
Messages: 9
Registered: July 2012
Junior Member
It seems as if this was a global problem on grammar level.

Global, because F3 works, or does not work, for all cross references in a project/language.

On grammar level (and not on ui level), because I disabled every customisation in the UIModule of the defective project, and it still won't work. Makes me think this must be something in the main project. But where could it be?

Meanwhile I discovered there is an OpenDeclarationHandler (org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclarationHandler). As you will guess, it is called when F3 gets through, but it is not called at all in the "F3 does not work" case.
...
DefaultHyperlinkDetector$1.exec(XtextResource) line: 38	
DefaultHyperlinkDetector$1.exec(Object) line: 1	
XtextDocument$XtextDocumentLocker(AbstractReadWriteAcces<P>).readOnly(IUnitOfWork<T,P>) line: 32	
XtextDocument.readOnly(IUnitOfWork<T,XtextResource>) line: 78	
TestingHyperlinkDetector(DefaultHyperlinkDetector).detectHyperlinks(ITextViewer, IRegion, boolean) line: 36	
TestingHyperlinkDetector.detectHyperlinks(ITextViewer, IRegion, boolean) line: 65	
OpenDeclarationHandler.execute(ExecutionEvent) line: 42	
...

So this somewhat confirms my suspicion about Xtext not identifying the rules in question as a "Declaration". But it does not lead any further though, because we are still in the call stack of F3 - or not. That is too late again.

Cheers,

Olivier
Re: F3/Open Declaration disabled on cross references [message #929575 is a reply to message #929486] Mon, 01 October 2012 15:23 Go to previous messageGo to next message
Olivier Petri is currently offline Olivier Petri
Messages: 9
Registered: July 2012
Junior Member
To avoid confusion: It's not in the grammar itself. When I said "on grammar level" I meant to say "in the main project" (and it's only a guess).

I copied the grammar file to a virgin new xtext project and there F3 does work. Guess I will copy step by step the entire project until I can reproduce the error. Unless of corse someone around has a better idea...

So long,

Olivier
Re: F3/Open Declaration disabled on cross references [message #929596 is a reply to message #929575] Mon, 01 October 2012 15:36 Go to previous messageGo to next message
Christian Dietrich is currently online Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi can you send a list of custom bindings you use?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: F3/Open Declaration disabled on cross references [message #930294 is a reply to message #929596] Tue, 02 October 2012 07:24 Go to previous messageGo to next message
Olivier Petri is currently offline Olivier Petri
Messages: 9
Registered: July 2012
Junior Member
In the main project:
public class XYZRuntimeModule extends de.xmpl.dsl.xyz.AbstractXYZRuntimeModule {
	public void configure(Binder binder) {
		super.configure(binder);
                // configuration for customised serialization
		binder.bind( XPathElementFormatConfiguration.class ).toProvider( AnyNSElementFormatProvider.class );
	}

        // plugin entry point
	public Class<? extends org.eclipse.xtext.generator.IGenerator> bindIGenerator() {
		return de.xmpl.dsl.xyz.generator.XYZGeneratorPlugin.class;
	}

	// Input encoding for stand alone execution (outside eclipse) (ISO-latin-1).
	public void configureRuntimeEncodingProvider(Binder binder) {
	    binder.bind(IEncodingProvider.class)
	          .annotatedWith(DispatchingProvider.Runtime.class)
	          .to( InputEncodingProvider.class );
	}
}


In the UI project:
public class XYZUiModule extends de.xmpl.dsl.rtl.ui.AbstractXYZUiModule
{
	public XYZUiModule(AbstractUIPlugin plugin) {
		super(plugin);
	}

	public Class<? extends IEObjectHoverProvider> bindIEObjectHoverProvider() {
		return XYZHoverProvider.class;
	}

	public Class<? extends IEObjectDocumentationProvider> bindIEObjectDocumentationProvider() {
		return XYZEObjectDocumentationProvider.class;
	}

	public Class<? extends IHighlightingConfiguration> bindIHighlightingConfiguration() {
		return de.xmpl.dsl.xyz.ui.highlighting.HighlightingConfiguration.class;
	}

	public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
		return de.xmpl.dsl.xyz.ui.highlighting.XYZSemanticHighlighter.class;
	}

	public Class<? extends ILocationInFileProvider> bindILocationInFileProvider() {
		return de.xmpl.dsl.xyz.ui.XYZLocationInFileProvider.class;
	}

	public Class<? extends  AbstractAntlrTokenToAttributeIdMapper> bindAbstractAntlrTokenToAttributeIdMapper() {
		return de.xmpl.dsl.xyz.ui.highlighting.XYZLexicalHighlighter.class;
	}
}


Thank you for caring!

Olivier
Re: F3/Open Declaration disabled on cross references [message #930311 is a reply to message #930294] Tue, 02 October 2012 07:33 Go to previous messageGo to next message
Christian Dietrich is currently online Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
I would look at the locationinfileprovider

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: F3/Open Declaration disabled on cross references [message #930363 is a reply to message #930294] Tue, 02 October 2012 08:41 Go to previous messageGo to next message
Olivier Petri is currently offline Olivier Petri
Messages: 9
Registered: July 2012
Junior Member
Gee, this drives me nuts. I've copied over 75% of the defect project to a test location - and it is still working. The problem must obviously be in the missing 25% - but that's essentially string handling stuff! Argh!

Anyway. To complete the picture; I occassionally find an xtext stacktrace (that is 3 possibly related stack traces) in the console when running the project as "Eclipse Application". Not sure if it is related to the present problem, not sure if it is related to the defective project at all (it could very well be comming from one of the other languages, the stack does not give any indication). I add it though, maybe you find something useful. The first one says
org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type org.eclipse.xtext.xbase.lib.Functions$Function1 cannot be resolved. It is indirectly referenced from required .class files
	at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:121)
	at 
(...)
	at org.eclipse.jdt.internal.core.util.BindingKeyResolver.getCompilationUnitDeclaration(BindingKeyResolver.java:580)

and the last one
23500 ERROR org.eclipse.xtext.builder.clustering.ClusteringBuilderState - Error resolving cross references on resource 'archive:file:/C:/tools/eclipse/eclipse37/eclipse37_full_64bit/plugins/org.eclipse.xtext.xbase_2.2.1.v201112130541.jar!/org/eclipse/xtext/xbase/compiler/JvmModelGenerator.xtend'
org.eclipse.emf.common.util.WrappedException: org.eclipse.emf.common.util.WrappedException: java.lang.IllegalStateException: Could not create binding for 'org.eclipse.xtext.xbase.compiler.CompilationStrategyAdapter'.
	at 
(...)
Caused by: java.lang.IllegalStateException: Could not create binding for 'org.eclipse.xtext.xbase.compiler.CompilationStrategyAdapter'.
	at 
(...)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:175)


Looks familiar, but it doesn't talk to me...

Olivier
Re: F3/Open Declaration disabled on cross references [message #930370 is a reply to message #930363] Tue, 02 October 2012 08:50 Go to previous messageGo to next message
Olivier Petri is currently offline Olivier Petri
Messages: 9
Registered: July 2012
Junior Member
What concerns the LocationInFileProvider: If I disable it, nothing changes. Not surprising since it just handles some special cases and delegates the rest to super:
protected List<INode> getLocationNodes(EObject obj) {
	if (obj instanceof AbcDefG) {
		// do something special
	} else {
		return super.getLocationNodes(obj);
	}
}


Olivier
Re: F3/Open Declaration disabled on cross references [message #930748 is a reply to message #930370] Tue, 02 October 2012 15:50 Go to previous messageGo to next message
Olivier Petri is currently offline Olivier Petri
Messages: 9
Registered: July 2012
Junior Member
I've got a copy of the original project now that's 99% identical - working. Looks like vodoo. Two days burned on this bloody issue and no finding. I hate to say it, but I give up on this. Have to, before I become insane or get fired or both.

.
Re: F3/Open Declaration disabled on cross references [message #989002 is a reply to message #926252] Tue, 04 December 2012 09:35 Go to previous message
Charles Bonneau is currently offline Charles Bonneau
Messages: 32
Registered: February 2010
Location: Belgium
Member
Hello,
I found your post looking for a stack trace that I have.
It is not a blocking issue but I have entries in the error log when building a DSL file, and it really bothers the users.
Here is the error :
org.eclipse.xtext.linking.lazy.LazyLinkingResource  - resolution of uriFragment 'xtextLink_::0.0.4::3::/2' failed.


and a part of the stack trace :
Caused by: java.io.IOException: Could not create binding for 'org.eclipse.xtext.xbase.compiler.CompilationStrategyAdapter'.
	at org.eclipse.xtext.common.types.access.TypeResource.doLoad(TypeResource.java:96)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1505)
	at org.eclipse.xtext.common.types.access.TypeResource.load(TypeResource.java:80)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	... 47 more


And the weirdest part is that my grammar isn't XBase dependent.

Any idea on where it might come from and how to fix it ?

BR,

Charles Bonneau
Previous Topic:Keeping old Xtext versions in maven repository
Next Topic:Custom IResourceValidator
Goto Forum:
  


Current Time: Fri Oct 24 12:55:34 GMT 2014

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

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