Splitting a model into several files? Scoping? [message #654056] |
Sun, 13 February 2011 19:11 |
Michael Missing name 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 |
Parisa Moosavi 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
But what I expected was
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
for this literal
'menu' menu=[Menu|EString]
instead of an output as string
-----------------------------------------------------------------------------------------
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 #1721438 is a reply to message #1721432] |
Wed, 27 January 2016 13:33 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.04535 seconds