|
Re: Get all EObjects of a Type [message #1100691 is a reply to message #1100681] |
Tue, 03 September 2013 12:59 |
|
Hi,
the easiest is ( i think so) to store the gobality intoformation in the xtext index
(therefore customize DefaultResourceDescriptionStrategy and add a token to the userdata of the IEObjectDescription)
then filter delegateGetScope(ctx,ref) on EObjectDescriptions that have this flag.
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Get all EObjects of a Type [message #1101277 is a reply to message #1100681] |
Wed, 04 September 2013 08:41 |
kamo cuvao Messages: 11 Registered: July 2013 |
Junior Member |
|
|
Thank you Christian for your quick response and the direction you gave me. My Program now works wonderful.
For all the ones who are interested how I made it:
This really helped me out: www.eclipse.org/forums/index.php/mv/msg/361362/885861/#msg_885861
I used the whole inherit code, because first of all I needed it and secondly it provides this nice SimpleName --> QualifiedName mechanism.
For my global variables I just added a Flag in the createEObjectDescriptions of MyDslDefaultResourceDescriptionStrategy
if(eObject instanceof VariableDefinition){
Map<String, String> userData = Maps.newHashMap();
Model model = EcoreUtil2.getContainerOfType(eObject, Model.class);
userData.put("model", model.getName());
if(((VariableBlock)(eObject)).isIsGlobal()){ //flag is here
userData.put("isGlobal", "true");
}
return createEOD(eObject, acceptor, userData);
}
and in my Scope provider I grabbed all Variables with the flag (and the inherited ones):
def scope_AssignRef_reference(Model m, EReference ref){
val allModels = getAllModels(m);
return new FilteringScope(delegateGetScope(m, ref), [ieod |
(ieod.getUserData("model") != null && allModels.contains(ieod.getUserData("model"))) ||
(ieod.getUserData("isGlobal") != null && ieod.getUserData("isGlobal").equals("true"))
]);
}
[Updated on: Wed, 04 September 2013 08:45] Report message to a moderator
|
|
|
|
|
Re: Get all EObjects of a Type [message #1102135 is a reply to message #1102128] |
Thu, 05 September 2013 12:06 |
|
Hi,
hi i am not sure what you are talking about/what you are actually doing.
it is your choice on how you solve that.
using the filteirng scope you should not collect that may iterators/stuff since all is done lazy.
adding all to a set (uniqueness problem) may be much more expensive
but this depends on your usecase.
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Powered by
FUDForum. Page generated in 0.03875 seconds