| [Solved] Replacing an EStructuralFeature with a placeholder name in Xtext DSL [message #1589503] |
Wed, 28 January 2015 08:40  |
Eclipse User |
|
|
|
Hello,
I have a problem I couldn't find anything about, so I want to ask you.
I created a DSL where I can import an Ecore model.
From this model I reference an EClass and EOperations of that EClass using the ScopeProvider. This works perfectly fine.
But the next step is to reference EStructuralFeatures of that class. This works fine too, but I want to reference the corresponding Setters of those EStructuralFeatures. For example: the feature 'name' shall be called 'setName' in my Xtext document.
I created a simple example project for you to get a proper overview of what I want.
The grammar looks like this:
generate getterSetter "http://www.xtext.org/example/mydsl/GetterSetter"
import "http://www.eclipse.org/emf/2002/Ecore"
Model:
imports+=Import*
greetings+=Greeting*;
FQN:
ID ('.' ID)*;
Import returns Import:
'import' importURI=STRING;
Greeting:
Operation | Setter;
Operation:
'do' c=[EClass|FQN] '->' op=[EOperation] '(' ')';
Setter:
'set' c=[EClass|FQN] '->' feature=[EStructuralFeature] '(' ')';
The example document looks like this:
import "railcab.ecore"
do railcab.Railcab -> start()
set railcab.Railcab -> speed()
do railcab.Railcab -> stop()
And I want the middle line to be:
set railcab.Railcab -> setSpeed()
How can I accomplish that?
Do I have to create a new NameProvider or something else?
Is this even possible?
Or are there any other helpful sources / topics I missed?
Thanks in advance,
Florian
[Updated on: Sun, 15 February 2015 13:49] by Moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04430 seconds