Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Resolving proxy for cross-reference to another file
Resolving proxy for cross-reference to another file [message #733825] Wed, 05 October 2011 18:09 Go to next message
Andrew Gacek is currently offline Andrew GacekFriend
Messages: 32
Registered: October 2011
Member
I have a language in Xtext with cross-references to variables declared in another file. When I am traversing the model returned by Xtext and I come across one of these variables it is a proxy object and any calls to its getXXX() methods returns null. How do I tell EMF to resolve this proxy? Can I force all proxies to be resolved when the model is loaded?

I'm loading the model using the following code which is part of an Eclipse plug-in. It is supposed to load the model for the file that the user is currently editing.

IEditorPart activeEditor = window.getActivePage().getActiveEditor();
IFile activeFile = (IFile) activeEditor.getEditorInput().getAdapter(IFile.class);
Injector injector = new MydslStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
URI uri = URI.createURI(activeFile.getFullPath().toString());	
Resource resource = resourceSet.getResource(uri, true);
return (Model) resource.getContents().get(0);

-Andrew

[Updated on: Wed, 05 October 2011 18:09]

Report message to a moderator

Re: Resolving proxy for cross-reference to another file [message #733834 is a reply to message #733825] Wed, 05 October 2011 18:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
Hi,

first: calling Injector injector = new MydslStandaloneSetup().createInjectorAndDoEMFRegistration();
from an eclipse ui is a very very bad idea. the stuff if not named standalone for fun.

second: if your using standlone setup all resources have to be added to the resourceset before resolvinbg anything.

third: why do you want to reload the model at all?
i guess you want to do something like http://www.eclipse.org/forums/index.php/mv/msg/170054/543633/#msg_543633

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Resolving proxy for cross-reference to another file [message #733843 is a reply to message #733834] Wed, 05 October 2011 18:56 Go to previous message
Andrew Gacek is currently offline Andrew GacekFriend
Messages: 32
Registered: October 2011
Member
Christian, you are exactly right. The link you provided works perfectly.

Thanks again,
Andrew
Previous Topic:Puzzling Ecore inference
Next Topic:Unable to generate mwe2 workflow w. mixin with ant
Goto Forum:
  


Current Time: Fri Apr 26 21:25:55 GMT 2024

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

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

Back to the top