Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to: list all visible packages from Project
How to: list all visible packages from Project [message #1426935] Fri, 19 September 2014 12:52 Go to next message
Simon Sperl is currently offline Simon SperlFriend
Messages: 21
Registered: May 2014
Junior Member
I have an example project structure:

IProject A
  a.dsl
    package a
    package a.a.a

IProject C
  references A
  cfile.file
    "a is green"
    "a.a.a is yellow"


I now want to check for entries in cfile.file if a and a.a.a exist/ are in the "scope of C".

but the classical way:
URI resourceURI = //cfile.file URI

IResourceDescriptions rds = rdp.getResourceDescriptions( someResourceSet);
IResourceDescription rd = rds.getResourceDescription(resourceURI);
List<IContainer> vis = cm.getVisibleContainers(rd, rds);


rds.getResourceDescription(resourceURI); always returns null since cfile.file exports no ResourceDescriptions/ is no dsl file (i guess).

How do I do that? (..I do not want to loadResource everything)

[Updated on: Fri, 19 September 2014 13:36]

Report message to a moderator

Re: How to: list all visible packages from Project [message #1426947 is a reply to message #1426935] Fri, 19 September 2014 13:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi package is a thing that dos not exist in the xtext world by default. But maybe what you actually want to do is the have a look at the eobjectdescriptions or the resoucesdescriptiond in the xtext index. From your snippet you are almost there. You can query the container for both

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to: list all visible packages from Project [message #1426959 is a reply to message #1426947] Fri, 19 September 2014 13:30 Go to previous messageGo to next message
Simon Sperl is currently offline Simon SperlFriend
Messages: 21
Registered: May 2014
Junior Member
Ah yes, just mentally replace package with a random EObject Smile

My problem is that ResourceDescriptions.getResourceDescription( URIof("cfile.file") ) returns null, which then prevents me from using getVisibleContainers.

if "cfile" were of ".dsl" I can do it no problem with the eobjectdescriptions, but since it isn't I'm stumped.
Re: How to: list all visible packages from Project [message #1426963 is a reply to message #1426959] Fri, 19 September 2014 13:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi the the Uri is not correct it. Have a look at allresourcedescrptions in i Ressource de script ins.

The uri should be platform:/resource/project/path/file.extension


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to: list all visible packages from Project [message #1426977 is a reply to message #1426963] Fri, 19 September 2014 14:01 Go to previous messageGo to next message
Simon Sperl is currently offline Simon SperlFriend
Messages: 21
Registered: May 2014
Junior Member
Ty but sry, I just checked the uris are in that form (and exist).

the problem is that the
resourceDescriptionMap of ResourceDescriptions just does not contain an entry for
"platform:/resource/C/cfile.file" (since cfile.file is never parsed it is just a dumb textfile and (pretty sensibly) so never generates eobjectdescriptions)


I just don't know how to get all EObjectDescriptions of a single Project, if I have that I am happy.

[Updated on: Fri, 19 September 2014 14:01]

Report message to a moderator

Re: How to: list all visible packages from Project [message #1427045 is a reply to message #1426977] Fri, 19 September 2014 16:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

xtext only indexes stuff that have a iresourceserviceprovider. this is by default all xtext languages + ecore. if file is not a dsl file this way wont work.
as i said: package is not a xtext concept.

maybe you want to do this using eclipse resource means (iresource/iproject/ifile - not xtext related)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to: list all visible packages from Project [message #1427427 is a reply to message #1427045] Sat, 20 September 2014 06:30 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
p.s. you may digg into

org.eclipse.xtext.ui.containers.AbstractAllContainersState.getVisibleContainerHandles(String)

this is basically what

org.eclipse.xtext.resource.containers.StateBasedContainerManager.getVisibleContainers(IResourceDescription, IResourceDescriptions)

does

some debugging may show you what actually happens.

the real question i have is: why do you NOT have a start resource?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Customize XtextLinkAdapter
Next Topic:How to add XText editor in an RCP application
Goto Forum:
  


Current Time: Thu Apr 25 06:55:07 GMT 2024

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

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

Back to the top