Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Global Scoping
Global Scoping [message #646725] Thu, 30 December 2010 14:35 Go to next message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
Hello everybody! Fisrt of all, thank you for all the help you have given me.

I need to implement cross-reference for my language. For this langague, I have defined several Xtext grammars and the user will have a directory structure like the next to develop software using my language:

-parent_folder
------objects_1
------objects_2
.
.
.
-----objects_n


, where objects_1 contains the files written using my grammar 1 (language1.xtext), etc. I need to have cross-references among objects inside these directories.

I experimented with importUri mechanism explained in the post: http://blog.efftinge.de/2009/01/xtext-scopes-and-emf-index.html Sven wrote and it worked really great, but I would prefer not to have to write imports like:

import "../objects_b/myObjectb.mydslb"


, also I have a large amount of files, so it would be difficult to write all the necessary imports and keep track of them if I for example, delete an object imported in many other files.


I read the "Global Scopes Based On External Configuration (e.g. Classpath-
Based)" and the "About the Index, Containers and Their Manager" sections of the Xtext documentation but I haven't figure out how to make them work. I think I should use one of those mechanism to do what I want.

What do you think? What do you recommend me?

Thank you very much!






Re: Global Scoping [message #646728 is a reply to message #646725] Thu, 30 December 2010 15:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i don't understand your question since this works out of the box:

/org.xtext.example.mydsla/src/org/xtext/example/mydsl/MyDslA .xtext
grammar org.xtext.example.mydsl.MyDslA with org.eclipse.xtext.common.Terminals

generate myDslA "http://www.xtext.org/example/mydsl/MyDslA"

ModelA:
	elements+=ElementA*;
	
ElementA:
	"element" name=ID;



/org.xtext.example.mydslb/src/org/xtext/example/mydsl/MyDslB .xtext
grammar org.xtext.example.mydsl.MyDslB with org.eclipse.xtext.common.Terminals

generate myDslB "http://www.xtext.org/example/mydsl/MyDslB"

import "platform:/resource/org.xtext.example.mydsla/src-gen/org/xtext/example/mydsl/MyDslA.ecore" as mydsla

ModelB:
	elements+=ElementB*;
	
ElementB:
	"element" name=ID "refToA" refToA=[mydsla::ElementA]
	;


/org.xtext.example.mydslb/src/org/xtext/example/mydsl/Genera teMyDslB.mwe2
...
			fragment = ecore.EcoreGeneratorFragment {
			 referencedGenModels = "platform:/resource/org.xtext.example.mydsla/src-gen/org/xtext/example/mydsl/MyDslA.genmodel"
			}
...


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Global Scoping [message #646736 is a reply to message #646728] Thu, 30 December 2010 16:47 Go to previous messageGo to next message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
Hi Christian! Thank you for your answer.

I already tried that, but I didn't work.

If I write a .mydslA file with:

 element MyBaseElement



and a .mydslB file with

element MyBaseElement refToA MyBaseElement


I get "Coudn't resolve reference to ElementA 'MyBaseElement'. "

Is there anything else I should do in order to make it work?

Thank you very much.

Re: Global Scoping [message #646743 is a reply to message #646736] Thu, 30 December 2010 17:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

just put both files i an project with xtext nature added.

Then it works,
A least on my Machine (using Xtext 1.0.1) and authomatic build enabled.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Global Scoping [message #646776 is a reply to message #646743] Fri, 31 December 2010 04:05 Go to previous messageGo to next message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
Ok, finally It worked! It was really that simple and out-of-the-box!

The strange part is that it worked only when I exported my Xtext project as "Deployable Plug-ins and Fragments" and installed it in Eclipse.

It has been impossible for me to make it work under the developing ("Run as Eclipse Application") environment.

Any ideas of the reasson of this problem? Maybe someone could give me a hint of what to look for in order to find out how to solve this and make the cross-reference work without the need of exporting my project.

Thank you very much.

[Updated on: Fri, 31 December 2010 04:06]

Report message to a moderator

Re: Global Scoping [message #646795 is a reply to message #646776] Fri, 31 December 2010 10:28 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

Maybe your runtime workspace is corrupt or Some plugins are missing ...
Starting the runtime with console and consoleLog should give you some hints

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 31 December 2010 10:35]

Report message to a moderator

Previous Topic:Is it a bug of resolving the model?
Next Topic:problem with the generated project wizard
Goto Forum:
  


Current Time: Fri Apr 19 02:15:08 GMT 2024

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

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

Back to the top