Home » Modeling » Epsilon » [Epsilon - EOL](Iterate over a resource without resolve the proxies)
[Epsilon - EOL] [message #1775218] |
Thu, 26 October 2017 08:18  |
Eclipse User |
|
|
|
Hi,
I'm currently trying to iterate over a resource, but I just want to iterate over the direct objects, without resolving proxies. The thing is that I'm trying to do it using:
var emfTool : new Native("org.eclipse.epsilon.emc.emf.tools.EmfTool");
var ecoreUtil = emfTool.ecoreUtil;
var contents = ecoreUtil.getAllContents(Model.resource, false);
The variable contents is empty, but the resource has objects and I can iterate over those objects using for example:
for (element in Subsystem.all.asSet()) {
element.println();
}
I do not know what I'm doing wrong. Is there any way of doing this?
Any help will be appreciated.
Epsilon 1.4.
Cheers,
Antonio
|
|
| |
Re: [Epsilon - EOL] [message #1775515 is a reply to message #1775254] |
Tue, 31 October 2017 05:19   |
Eclipse User |
|
|
|
Hi Antonio,
Thanks for the reply!
I am executing EOL via standalone, but I have made a minimal example. I want to iterate only the objects inside the main resource, but I want that if any constraint has 'X.all', then eol resolve the proxies.
In the minimal example that I attached var contents = ecoreUtil.getAllContents(HControl1.resource, false); , contents is empty, because of this I suppose that eol is not compatible with TreeIterator, is that true?
Temporary solution:
I create a Java Method giving as a parameters Model.Resource and the name of the class. Basically the method, return a List<EObject> after having iterated all the objects of the model.
Cheers,
Antonio
[Updated on: Tue, 31 October 2017 05:22] by Moderator
|
|
| | |
Re: [Epsilon - EOL] [message #1775546 is a reply to message #1775526] |
Tue, 31 October 2017 17:09   |
Eclipse User |
|
|
|
Ah, didn't see it before I had to run off to a school meeting :-S.
The problem is that getAllContents(...) returns a TreeIterator, which (confusingly) is also a BasicEList of iterators :-). I believe Epsilon tries to treat it as a collection (as it is a BasicEList after all), rather than as a TreeIterator. This code works fine:
var emfTool : new Native("org.eclipse.epsilon.emc.emf.tools.EmfTool");
var ecoreUtil = emfTool.ecoreUtil;
var contents = ecoreUtil.getAllContents(HControl1.resource, false);
while (contents.hasNext()) {
contents.next().println();
}
It produces this output:
Subsystem [name=HControl1, ]
Subsystem [name=HControl2, ]
ControlSubsystem [name=H2Control1, ]
StateMachine [name=null, isPublic=true]
InitialState [name=null, description=null, ]
SimpleState [name=null, description=null, ]
ControlSubsystem [name=H2Control2, ]
ControlSubsystem [name=H2Control3, ]
ControlSubsystem [name=H2Control4, ]
ControlSubsystem [name=H2Control5, ]
StateMachine [name=a, isPublic=true]
InitialState [name=null, description=null, ]
SimpleState [name=null, description=null, ]
Architecture [name=H1Arquitecture, ]
Component [label=null]
ControlSubsystem [name=HControlDefinition, ]
ControlSubsystem [name=H2, ]
ControlSubsystem [name=H3, ]
ControlSubsystem [name=H4, ]
ControlSubsystem [name=new_file, ]
Is that the behaviour you wanted?
[Updated on: Tue, 31 October 2017 17:11] by Moderator
|
|
| | | | |
Goto Forum:
Current Time: Thu Jul 24 12:53:31 EDT 2025
Powered by FUDForum. Page generated in 0.07817 seconds
|