Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to navigate the complete model of a given project and dsl?
How to navigate the complete model of a given project and dsl? [message #721674] Fri, 02 September 2011 13:58 Go to next message
F. Alexander Njemz is currently offline F. Alexander NjemzFriend
Messages: 20
Registered: July 2010
Junior Member
Hi,

in my grammar Entities can reference Entities. These references can of course cross
file boundaries. Now I'm trying to collect all the entities and references between
them to visualize them. The problem is that the links never seem to get resolved.

When using the dsl inside the runtime eclipse application code completion works without a problem across file boundaries.

What I'm doing right now is roughly the following:


        @Inject
	private IResourceSetProvider provider;
	
	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
                [snip]
		XtextResourceSet resourceSet = (XtextResourceSet) provider.get(project);
		resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
		
		
		Collection<IFile> resources = null; 
		
		try {
			resources = collectResources(project);
		} catch (CoreException e) {
			e.printStackTrace();
		}
				
		
		for (IFile res : resources) {                             resourceSet.getResource(URI.createURI(res.getLocationURI().toString())
					, true);
		}
		
	        EcoreUtil.resolveAll(resourceSet);
		
		for (Resource r : resourceSet.getResources()) {
			for (Diagnostic d : r.getErrors()) {
				System.err.println(d.getMessage());
			}
		}




which leaves me with a lot of messages like "Couldn't resolve reference to Entity 'Foo'.".

So my question is: how can I make this work? Where should I start to look for possible solutions? Scoping perhaps?

Thanks in advance.

Kind regards,

Alexander
(no subject) [message #721699 is a reply to message #721674] Fri, 02 September 2011 15:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Alex,

When running inside Eclipse, XtextResourceSet.setClasspathURIContext is
set with an IJavaProject to make this work...


On 02/09/2011 6:58 AM, F. Alexander Njemz wrote:
> Hi,
>
> in my grammar Entities can reference Entities. These references can of
> course cross
> file boundaries. Now I'm trying to collect all the entities and
> references between
> them to visualize them. The problem is that the links never seem to
> get resolved.
>
> When using the dsl inside the runtime eclipse application code
> completion works without a problem across file boundaries.
>
> What I'm doing right now is roughly the following:
>
>
>
> @Inject
> private IResourceSetProvider provider;
>
> @Override
> public Object execute(ExecutionEvent event) throws
> ExecutionException {
> [snip]
> XtextResourceSet resourceSet = (XtextResourceSet)
> provider.get(project);
> resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL,
> Boolean.TRUE);
>
>
> Collection<IFile> resources = null;
> try {
> resources = collectResources(project);
> } catch (CoreException e) {
> e.printStackTrace();
> }
>
>
> for (IFile res : resources) {
> resourceSet.getResource(URI.createURI(res.getLocationURI().toString())
> , true);
> }
>
> EcoreUtil.resolveAll(resourceSet);
>
> for (Resource r : resourceSet.getResources()) {
> for (Diagnostic d : r.getErrors()) {
> System.err.println(d.getMessage());
> }
> }
>
>
>
>
> which leaves me with a lot of messages like "Couldn't resolve
> reference to Entity 'Foo'.".
>
> So my question is: how can I make this work? Where should I start to
> look for possible solutions? Scoping perhaps?
>
> Thanks in advance.
>
> Kind regards,
>
> Alexander


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: (no subject) [message #721702 is a reply to message #721699] Fri, 02 September 2011 15:54 Go to previous messageGo to next message
F. Alexander Njemz is currently offline F. Alexander NjemzFriend
Messages: 20
Registered: July 2010
Junior Member
Thanks, Ed.

However, I'm trying to do this stuff inside eclipse and afaict the
XtextResourceSet.setClasspathURIContext is being set with an IJavaProject.
Re: (no subject) [message #721735 is a reply to message #721702] Fri, 02 September 2011 17:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

absolute uris with eclipse are a bad idea

URI.createPlatformResourceURI(res.getFullPath().toString(), true) helps
http://wiki.eclipse.org/index.php/EMF/FAQ#How_do_I_map_between_an_EMF_Resource_and_an_Eclipse_IFile.3F

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: (no subject) [message #722313 is a reply to message #721735] Mon, 05 September 2011 11:06 Go to previous message
F. Alexander Njemz is currently offline F. Alexander NjemzFriend
Messages: 20
Registered: July 2010
Junior Member
Thank you so much, Christian. That did it!
Previous Topic:Compile-time expressions: xbase or not ?
Next Topic:Loading the whole project in a Resource
Goto Forum:
  


Current Time: Fri Apr 26 10:40:45 GMT 2024

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

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

Back to the top