|
Re: Resolver/ResourceSet behavior doubts [message #1763595 is a reply to message #1763592] |
Wed, 17 May 2017 17:23 |
|
no the problem is the one mentioned before:
var resourceSet = resource.resourceSet
var resources = resourceSet.resources
there is no guarantee that all resources are loaded to the resourceset.
actually only the changed ones and the involved ones.
this is why this approach does not work.
you would have to query the xtext index for all greetings and use this information to load all resources needed.
class MyDslGenerator extends AbstractGenerator {
@Inject
IResourceDescriptionsProvider rdp;
@Inject
IContainer.Manager cmgr
override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
val rds = rdp.getResourceDescriptions(resource.resourceSet)
val rd = rds.getResourceDescription(resource.URI)
val greetings = <Greeting>newArrayList
for (c : cmgr.getVisibleContainers(rd, rds)) {
for (d : c.getExportedObjectsByType(MyDslPackage.Literals.GREETING)) {
var g = d.EObjectOrProxy as Greeting
if (g.eIsProxy) {
g = EcoreUtil.resolve(g, resource.resourceSet) as Greeting
greetings.add(g);
}
}
}
fsa.generateFile("xxxxxx.txt", '''
«FOR g : greetings»
«g.name»
«ENDFOR»
''')
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03901 seconds