Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Provide Quick-fix for unrelated object while validation
Provide Quick-fix for unrelated object while validation [message #1805704] Mon, 22 April 2019 09:39
Himanshu Patel is currently offline Himanshu PatelFriend
Messages: 3
Registered: April 2019
Junior Member
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.
Previous Topic:1001 tips and tricks for Xtext
Next Topic:Terminal rules vs parser rules priority
Goto Forum:
  


Current Time: Thu Apr 25 06:19:35 GMT 2024

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

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

Back to the top