|Accessing model context in quickfix [message #987066]
||Fri, 23 November 2012 04:32
| Cedric Moonen
Registered: August 2009
In one of my quickfix rules, I need to supply multiple fixes depending on my model (calling the accept method on the acceptor several times depending on the current state of my model). The only problem is that I have no clue how to access the model element which is in error/warning.
The only arguments which are passed to the quickfix method are an Issue and a IssueResolutionAcceptor. I can pass custom arguments to the Issue while creating it in my validator class but those can only be Strings.
Is there a way to retrieve my model element in the quickfix method ?
|Re: Accessing model context in quickfix [message #987362 is a reply to message #987328]
||Mon, 26 November 2012 04:57
| Jan Koehnlein
Registered: July 2009
in the Quickfix API there is a strict separation on whether the model is
available or not. We have to make that separation because some of the
elements, e.g. the Issues and the IModifcation objects, are persisted
and available without any editor opened. The are needed e.g. to show the
lightbulbs in the problems view.
In the method annotated with @Fix is called when there it is *not*
available, so all decisions you want not make here must be based on
what's in the Issue. The issue has a String array "data" that can be
populated by the validation rule creating the issue to transfer more
information. It is of type String, as it has to be persisted in the
absence of any model.
Hope that clarifies things a bit
Am 26.11.12 08:26, schrieb Cedric Moonen:
> Thanks for your reply. However, I'm not sure you understood what I want
> to do. What I really want is to be access some 'model context' (so,
> similar as the IModificationContext) but not within the 'apply' method
> of a ISemanticModification.
> I want to access that context within the fix method itself: at the
> beginning of my method I would like to retrieve some information from
> the model to be able to know how many quick fixes I have to create (and
> the text I have to display for each of them).
> Unfortunately, I didn't find a way to access that information. I tried
> to look at how Xtext creates the IModificationContext object supplied to
> the ISemanticModification but it is incredibly complex and I'm not too
> sure how to implement this...
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Powered by FUDForum
. Page generated in 0.01718 seconds