Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Splitting a model into several files? Scoping?
icon5.gif  Splitting a model into several files? Scoping? [message #654056] Sun, 13 February 2011 19:11 Go to next message
Michael Missing name is currently offline Michael Missing nameFriend
Messages: 14
Registered: December 2010
Junior Member
Hi all,

for a newbie scoping does not exactly seem to be the easiest part to understand. So maybe somebody can help...

My model contains applications, and applications contain entities with attributes. Attributes can refer to entities:

Attribute:
type=AttributeTypeReference name=ID ";";

AttributeTypeReference:
referenced=[AttributeType|QualifiedName];

AttributeType:
DataType | Entity;

QualifiedName:
ID ("." ID)*;

I want to split an application's definition into several files:

file 1:

app A {
entity A1 {
String x;
}
}

file 2:

app A { // same applications as above
entity A2 {
A.A1 x; // reference to the same application's reference
B.B1 y; // qualified reference to another application's entity
}
}

file 3:

app B {
entity B1 {
...
}
}

While the qualified reference "B.B1 y;" is perfectly fine, I would like to avoid having to qualify the reference "A.A1 x;" since this is referring to the same application. Insted I would like to write:

app A { // same applications as above
entity A2 {
A1 x; // reference to the same application's reference
B.B1 y; // qualified reference to another application's entity
}
}

After playing around with ScopeProviders for several hours I came up with the clever idea that somebody might already have solved this?

[Updated on: Sun, 13 February 2011 19:12]

Report message to a moderator

Re: Splitting a model into several files? Scoping? [message #1721413 is a reply to message #654056] Wed, 27 January 2016 09:55 Go to previous messageGo to next message
Parisa Moosavi is currently offline Parisa MoosaviFriend
Messages: 81
Registered: June 2015
Member
I have imported two different ecore model to xtext with Ecore2Xtext. In both of them cross-reference is done with literals like this:
'page' page=[gcore::Page|EString]


In runtime the output as follows
page "gcoreI.EditPerson"


But what I expected was
page gcoreI.EditPerson


therefor I changed the literal to
'page' page=[gcore::Page|QualifiedName]

and in addition to that I defined the QualifiedName production rules.
QualifiedName:
ID ("." ID)*;


----------------------------------------------------------------------------------------------------
But in another grammar I have changed only the following configuration
	//fragment = scoping.ImportURIScopingFragment auto-inject {}
	//fragment = exporting.SimpleNamesFragment auto-inject {}

to this configuration
			fragment = scoping.ImportNamespacesScopingFragment auto-inject {}
			fragment = exporting.QualifiedNamesFragment auto-inject {}


to have this output
menu DefaultMenu

for this literal
'menu' menu=[Menu|EString]


instead of an output as string
menu "DefaultMenu"

-----------------------------------------------------------------------------------------
Although in both of them I wanted to have cross-reference and document-cross-reference like an id instead of String, but I should have used two different method?
-> one of them with workflow
-> the other with production rule

[Updated on: Wed, 27 January 2016 09:59]

Report message to a moderator

Re: Splitting a model into several files? Scoping? [message #1721415 is a reply to message #1721413] Wed, 27 January 2016 10:10 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 this. Through qualifiednameprovider you define how objects are put to the xtext index. Through the grammar how they are serialized: Id string FQN ...
So what is your actual problem


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Splitting a model into several files? Scoping? [message #1721432 is a reply to message #1721415] Wed, 27 January 2016 13:14 Go to previous messageGo to next message
Parisa Moosavi is currently offline Parisa MoosaviFriend
Messages: 81
Registered: June 2015
Member
Actually I don't undrestand many many behaviors and things of Xtext !
For example
For a production rule like this
StyleSetting returns StyleSetting:
	'StyleSetting'
	'{'
  		'fontColor' fontColor=[RGBColor]
		'backColor' backColor=[RGBColor]
                ....
	'}';

why in runtime I don't have any auto completion list for fontColor
index.php/fa/24775/0/
but for backColor I have a auto completion?
index.php/fa/24776/0/
Re: Splitting a model into several files? Scoping? [message #1721438 is a reply to message #1721432] Wed, 27 January 2016 13:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i asume you did a manual scope adaptation. sice xtext creates objects lazy your scoping method may never be called.
=> define the scope methodlike scope_Context_referenceName(AncestorOfContext ctx, EReference r)
or change your grammar to

StyleSetting returns StyleSetting:
	{StyleSetting}'StyleSetting'
	'{'
  		'fontColor' fontColor=[RGBColor]
		'backColor' backColor=[RGBColor]
                ....
	'}';


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Splitting a model into several files? Scoping? [message #1721446 is a reply to message #1721438] Wed, 27 January 2016 14:30 Go to previous message
Parisa Moosavi is currently offline Parisa MoosaviFriend
Messages: 81
Registered: June 2015
Member
I will test what you suggested later.

I didn't change or define anything because I don't know how or why should I define lazy scoping at all.
But if I change the rule to
StyleSetting returns StyleSetting:
	'StyleSetting'
	'{'
		'fontColor' fontColor=[RGBColor|EString]
		'backColor' backColor=[RGBColor|EString]
                ....
	'}';


I mean with EString it works perfectly !
Previous Topic:Calling parser/generator programmatically
Next Topic:global validation
Goto Forum:
  


Current Time: Fri Apr 19 05:58:38 GMT 2024

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

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

Back to the top