Get All Objects of Type in Global Scope? Easy Way? [message #1766375] |
Tue, 20 June 2017 13:44  |
Eclipse User |
|
|
|
I'm dumb. I've now run into this problem the second time in 3 weeks.
I am trying to do something I think should be very simple and probably comes up on every Xtext project: I need to obtain a list of all Objects of a given type that are present in the global scope. The builder knows this. I don't.
I must be asking Google wrong, cause I can't find it.
I'm stuck here, where I can iterate through the global index, get ResourceDescriptions for every Object of a Type, but then I always get stuck in the same place where I can't resolve the damn proxy.
// Use the global scope provider. This ensures that we see the descriptions created by the prelinking phase of the Xtext builder.
// the designSandbox is an object that I'm currently validating in my DSL's validator
val rs = globalScopeProvider.getResourceDescriptions(designSandbox.eResource)
val sdIndex = rs.getExportedObjectsByType(bmxPackage.Literals.SUPPORT_DEF)
// All the SuportDef objects are in other files other than the one containing the designSandbox - by definition
for (supportDefDesc : sdIndex) {
var sd = supportDefDesc.EObjectOrProxy
EcoreUtil2.resolve(sd, sd.eResource)
sd is _always_ a proxy. I can't figure out how to resolve it. In this case, the exported Object isn't in the current file I'm in, it's from some other imported file. That imported file (and the exported Object I have (which is always a proxy) makes reference to something in my current file). I do need to find out what external objects reference me.
Maybe there's a better way to check the cross references (EcoreUtil2 likely), but I am still coming back to the problem - which I will eventually need in my job - how do I get a list of all the Objects in my Global Scope and how do I get REAL resolved objects and not proxies?
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03280 seconds