Problem with Cross-Referencing and ProxyURIs [message #1752236] |
Fri, 20 January 2017 03:16  |
Eclipse User |
|
|
|
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 03:57   |
Eclipse User |
|
|
|
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 03:59] by Moderator
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06105 seconds