How to resolve the reference to other resources in a resource file [message #822174] |
Fri, 16 March 2012 08:49 |
Andy Ma Messages: 12 Registered: August 2011 |
Junior Member |
|
|
Hi Xtext exports,
I have made an xtext grammar with grammar file extension "ced", with the generator we transform the ced file to xml file.
Our requirement is we can write and edit the ced files in eclipse UI, and can transform it to xml file in both eclipse UI and standalone. Now I create a ced project in the eclipse UI, including main.ced, and other ced files with included in main.ced, I want to make sure any ced file changed in eclipse will trigger the generation from main.ced to xml file.
In order to make this work in both eclipse UI and standalone, I tried to create all ced resource from file URI and add it to the resourceset in the generator xtend file like following:
CalcEngineGenerator.xtend:
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
...
var reset = resourceSetProvider.get()
var filelist= new ArrayList<File>()
getAllCedFiles(projectFolder,filelist)
for(f:filelist)
{
reset.getResource(URI::createFileURI(f.absolutePath), true);
}
for(res:reset.resources)
{
var issues = validator.validate(rs, CheckMode::ALL, CancelIndicator::NullImpl)
if (!issues.isEmpty())
{
for (issue : issues)
{
println(issue);
}
}
}
...
}
After this ,I find the cross-file references are not resolved, it is like "eProxyURI: file:/D:/.../equations.ced#xtextLink_::0::1::/4)".
The reason I add all resources to the ResourceSet is that I don't use ImportURIScopingFragment in mwe workflow, instead I use ImportNamespacesScopingFragment, so even my grammar support both file including and namespace importing, only namespace importing works, and with all resources included in the resource set, I should be able to resolve all the cross-file reference(I am not sure if it is like this, but in my standalone version it seems work like this in my Main.java, see later),my grammar is like:
CalcEngine.xtext:
...
Include:
'include' importURI = STRING
;
Import:
'import' importedNamespace = QualifiedNameWithWildCard
;
...
the include URI is only used for myself to get other file path, and create resources by hand, xtextbuilder doesn't dear with it for scoping. Of course it would be nice if I can use ImportNamespacesScopingFragment and ImportURIScopingFragment together, but seems not.
I also tried like this in my Main.java for only standalone version, it works very well for cross file reference resolution, I don't know why this is not work in my xtend generator.
Any one knows why this happens?
[Updated on: Fri, 16 March 2012 08:59] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02067 seconds