Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ImportURI for external files
ImportURI for external files [message #1062826] Tue, 11 June 2013 00:06 Go to next message
Roza Ghamari is currently offline Roza Ghamari
Messages: 64
Registered: January 2013
Member
Hi all,

I am very lost with how importing global scope is working. I am writing a parser with xtext for a well structure language and I cannot depend on workspace or project concepts. In my language I have include statements which can have relative or absoloute paths of another file. I need to be able to reference objects defined in this other file. I tried using importURI but it doesn't work. All I tried was to add this rule:

 
Include:
	'INCLUDE' '='  importURI=STRING ';'
;


and change the MWE2 file in these parts:

   // scoping and exporting API
                 fragment = scoping.ImportURIScopingFragment {}
                // fragment = exporting.SimpleNamesFragment {}
    
                // scoping and exporting API
                fragment = scoping.ImportNamespacesScopingFragment {}
                fragment = exporting.QualifiedNamesFragment {}


But this doesn't make any effect in my editor. I still can refer to objects defined in every file with the same extension without having the include statements, and I still cannot include files outside of the project.

I really appreciate your help as I have spent a lot of time till now and found nothing understandable.
Re: ImportURI for external files [message #1062844 is a reply to message #1062826] Tue, 11 June 2013 05:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6378
Registered: July 2009
Senior Member
Hi you have to remove types generator and xbase fragments too to get
import uri working.

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: ImportURI for external files [message #1064162 is a reply to message #1062844] Mon, 17 June 2013 21:57 Go to previous message
Roza Ghamari is currently offline Roza Ghamari
Messages: 64
Registered: January 2013
Member
Thanks Christian that worked. Now I have a question about environment variables. Since this grammar is developed previously and there are many test files based on this grammar I need to make my xtext parser to support all we had before. One of these is the ability to import another file using environment variables in the path.

I tried defining the environment variables for the project and then link the files based on these variables, but the problem is importURI string doesn't get teh environment variable.

Assume I have file 1 defined in project which has a link to file to like:

INCLUDE = "${VAR1}/file2.foo";

VAR1 is defined and file2 is linked to project based on VAR1.

This doesn't work unfortunately, do you know how I can solve this?
Previous Topic:Call Java class(pure java code) in the Xtend Code
Next Topic:Use Xtext in Runtime
Goto Forum:
  


Current Time: Mon Oct 20 21:14:19 GMT 2014

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

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