Provide Quick-fix for unrelated object while validation [message #1805704] |
Mon, 22 April 2019 05:39 |
Eclipse User |
|
|
|
I have an Xtext grammar which looks like:
Model:
entityDefs += EntityDefinition*
entities += (E1 | E2)*
EntityDefinition:
{E1Def} 'Entity' name='E1' '{' attributes += (Attribute)* '}' |
{E2Def} 'Entity' name='E2' '{' attributes += (Attribute)* '}' |
E1:
ename='E1' name=INTID '{'
(attrList) += (Attr)*
E2:
ename='E2' name=INTID '{'
(attrList) += (Attr)*
Attr:
name=[AttributeDefinition] ':' value=Value
Attribute:
'attribute' name=[AttributeDefinition] '=' id=INT
// Skipping the definitions of AttributeDefinition
Now I want to validate when an entity is defined before using or not. Whenever the user of this language tries to create an entity before defining it beforehand, I show an error. To show the error at correct position, I need to pass the E1 or E2 object in the error.
However, I also need to provide a quick-fix for this error. In the quick-fix, I want to create an empty EntityDefinition and append it to Models.entityDefs. The problem is that for using model object in quick-fix, I need to pass the model object in the error function in validation, but doing so gives me the following exception.
The sources EClass 'Model' does not expose the feature 'E1.ename'.
Is there a way to get the EMF model inside Quick-fix provider? Or is there a way to pass model object without any running into exceptions in validation?
Please help me in achieving this.
|
|
|
Powered by
FUDForum. Page generated in 0.02889 seconds