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:

    entityDefs += EntityDefinition*
   entities += (E1 | E2)*

    {E1Def} 'Entity' name='E1' '{' attributes += (Attribute)* '}' |
    {E2Def} 'Entity' name='E2' '{' attributes += (Attribute)* '}' |

    ename='E1' name=INTID '{'
           (attrList) += (Attr)*

    ename='E2' name=INTID '{'
           (attrList) += (Attr)*

    name=[AttributeDefinition] ':' value=Value

    '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:On adding XtextAntlrGeneratorFragment2 in Workflow .Iam getting exception
Next Topic:On using XtextAntlrGeneratorFragment2 in work flow getting java.lang.IllegalStateException
Goto Forum:

Current Time: Tue Oct 15 04:45:33 GMT 2019

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

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

Back to the top