Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem with Cross-Referencing and ProxyURIs
Problem with Cross-Referencing and ProxyURIs [message #1752236] Fri, 20 January 2017 08:16 Go to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 63
Registered: March 2015
Member
Hello there,

i try to get a cross-reference from my xtext editor but it never resolves to a real element.

here is what i did:

in my grammar i have 'Parameter' reference=[ecore::EObject|ID]

in my model is an EClass that has the reference-reference (not containment)

i pass an eobject (from another instance-model) to my scope-provider and traverse it until i reach the point in the model with the eobjects i would like to reference.

then i make a scope out of it:

EList<EParameter> eParameters = eOperation.getEParameters();
return Scopes.scopeFor(eParameters);

if i press Strg + Space i get the right elements in my editor.

if i save my model now and ask the resource for my model with this

xtextResource.getContents().get(0);

and then look at the point with my reference-reference i get a proxy uri that looks like this:

org.eclipse.emf.ecore.impl.EObjectImpl@3c4570f4 (eProxyURI: platform:/resource/test-project/src/main/resources/temp.model#|::0.2::1::/2)

platform:/resource/test-project/src/main/resources/temp.model <-- this is the uri of my xtext-resource.

i expected an uri that looks like this:
http://mymodel/subpackage#//subpackage/EClassName/eOperationName/parameter

if i look in my eParameters that i pass to the Scopes.scopeFor()-Method the uris are in that form.

Any ideas?




Re: Problem with Cross-Referencing and ProxyURIs [message #1752240 is a reply to message #1752236] Fri, 20 January 2017 08:57 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 83
Registered: January 2016
Location: Kiel
Member

The uri you are looking at is a "lazy URI" from Xtext. After parsing xtext installs proxies with uri's that contain all the needed information to, at a later point, resolve the link.
So it points to itself (the context), the EReference and the node (the text) of the cross reference.

It's not quite clear what the issue is that you have, but if you want to have the proxy resolved, you need to make sure you navigate the getter of the reference or call EcoreUtil.resolve.
If that still returns a proxy with the mentioned URI it means that it couldn't be resolved. I.e. the scoping didn't return an element.

Note that, the scope can be called differently from content assist and during linking, because the model might not be fully parseable so that the context might be different. Xtext tries to use the best context object it gets.

hth,
sven

[Updated on: Fri, 20 January 2017 08:59]

Report message to a moderator

Re: Problem with Cross-Referencing and ProxyURIs [message #1752243 is a reply to message #1752240] Fri, 20 January 2017 09:06 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 63
Registered: March 2015
Member
Hello Sven, thank you for your response.

i tryed to resolve it but its still a proxy. can you give me any further advice how to improve my scope provider so that it returns an eobject? or can i deactivate that lazylinking?

Or how can i customize the linking phase?

[Updated on: Fri, 20 January 2017 09:11]

Report message to a moderator

Re: Problem with Cross-Referencing and ProxyURIs [message #1752244 is a reply to message #1752243] Fri, 20 January 2017 09:22 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 83
Registered: January 2016
Location: Kiel
Member

I would write a test and then debug the issue.
During resolve your ScopeProvider will be called with the EObject containing the reference.
Make sure you return a scope object that contains an EObjectDescription with the correct name.

A good point for debugging such linking issues is `org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(EObject, EReference, INode)`
Re: Problem with Cross-Referencing and ProxyURIs [message #1752247 is a reply to message #1752244] Fri, 20 January 2017 09:49 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 63
Registered: March 2015
Member
The method org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(EObject, EReference, INode) is never called.

i also created a class that extends DefaultLinkingService and registered it in my RuntimeModule. The Constructor of that class is also never called.

i also noticed that in the moment where i try to get my model from my resource my getScope method is also not called. the getScope method is only called in the moment where i press STRG + Space

I guess it never gets resolved?

What am i doing wrong?

[Updated on: Fri, 20 January 2017 09:52]

Report message to a moderator

Re: Problem with Cross-Referencing and ProxyURIs [message #1752249 is a reply to message #1752247] Fri, 20 January 2017 09:56 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 83
Registered: January 2016
Location: Kiel
Member

Could you share the code you use to obtain the object?
Re: Problem with Cross-Referencing and ProxyURIs [message #1752257 is a reply to message #1752249] Fri, 20 January 2017 10:49 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 63
Registered: March 2015
Member
What Object? The final one?

EcoreUtil.resolveAll(xtextResource);
xtextResource.getContents().get(0);

and then i traverse to the point where my reference is.

or do you mean the one i use to create the scope? then this is the code:

EOperation eOperation = 'eobjectfrommyodel'.eContainer().eClass().getEOperations().get(0);
EList<EParameter> eParameters = eOperation.getEParameters();
		if((context instanceof IParameterReference)) {
			IParameterReference parameterReference = (IParameterReference) context;
			if (reference.getName().equals("reference")){
				return Scopes.scopeFor(eParameters);
			}
		}

[Updated on: Fri, 20 January 2017 10:53]

Report message to a moderator

Re: Problem with Cross-Referencing and ProxyURIs [message #1752269 is a reply to message #1752257] Fri, 20 January 2017 13:19 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 83
Registered: January 2016
Location: Kiel
Member

I meant the "final one". I cannot tell based on your information why the Linking is not called on resolve, sorry.
I would step into the call to `myObject.getReference()` and see why the proxy is not resolved. It should go to `LazyLinkingResource.getEObject(String)` and then to the default linking service.
Please note that it tries to resolve a proxy only once. Afterward, it is marked as unresolvable and it won'T go into the previously mentioned method again.
Re: Problem with Cross-Referencing and ProxyURIs [message #1752273 is a reply to message #1752269] Fri, 20 January 2017 13:59 Go to previous message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 63
Registered: March 2015
Member
I found it. Thx!

The Problem was that i initialize my XTextEditor and the XTextResource for it myself. i used the XTextResource and not the LazyLinkingResource. Now i changed it to LazyLInkingResource and it works like a charm.
Previous Topic:Invalid context uring Epsilon transformation execution
Next Topic:Problems with code generation
Goto Forum:
  


Current Time: Tue Apr 23 09:23:40 GMT 2024

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

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

Back to the top