Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to resolve the reference to other resources in a resource file(Maybe scope problem)
How to resolve the reference to other resources in a resource file [message #822174] Fri, 16 March 2012 08:49 Go to next message
Andy Ma is currently offline Andy MaFriend
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

Re: How to resolve the reference to other resources in a resource file [message #825360 is a reply to message #822174] Tue, 20 March 2012 19:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13425
Registered: July 2009
Senior Member
Hi,

i guess you should not use file uris. at least in the example i blogged about some month ago it works using platform resource uris
http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to resolve the reference to other resources in a resource file [message #829602 is a reply to message #825360] Mon, 26 March 2012 14:35 Go to previous message
Andy Ma is currently offline Andy MaFriend
Messages: 12
Registered: August 2011
Junior Member
Thank you very much, this is what I want, with platform uri, I can get all reference resources.
Previous Topic:building an Xtext project (using also Xtend) with Tycho
Next Topic:Auto Editing (parenthesis closing issue)
Goto Forum:
  


Current Time: Tue Apr 07 11:51:53 GMT 2020

Powered by FUDForum. Page generated in 0.01925 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top