Xtext quick fix provider not run? [message #1776780] |
Tue, 21 November 2017 15:14 |
Steffen Zschaler Messages: 266 Registered: July 2009 |
Senior Member |
|
|
Hi,
I'm building an Xtext language with Xtext 2.12. I want to provide quick fixes in response to an issue identified during validation.
In my validator, I provide an issue code and relevant issue data. In the QuickFixProvider that has been generated in my *.ui project, I have a suitable method with an @Fix(CODE) annotation in which I analyse the issue data and register appropriate resolutions.
Unfortunately, it seems that this method is never invoked. The plugin.xml seems to register org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator against appropriate extension points. I cannot see where this is bound in any of the modules, but it is explicitly mentioned in the extension definition. Looking at the code of that, this should call my fix method (my quickfixprovider is bound as the IssueResolutionProvider in the UI module). I placed a breakpoint in AbstractIssueResolutionProviderAdapter#getResolutions (which, should call out to the actual IssueResolutionProvider---that is my code---to get the quick fixes), but this seems never to be reached.
As a result, when I ask for quick fixes on my issue marker, Eclipse simply tells me that there aren't any.
The documentation (https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#quick-fixes) mentions the need to use QuickfixProviderFragment2 in the MWE2 workflow to generate the QuickFixProvider class. However, this seems outdated as that class is already being generated. It is also not clear to me where I would need to call this fragment in my workflow (I currently use the workflow that Xtext initially generated for me).
What am I missing?
Many thanks,
Steffen
|
|
|
|
|
|
Re: Xtext quick fix provider not run? [message #1776789 is a reply to message #1776784] |
Tue, 21 November 2017 16:02 |
Steffen Zschaler Messages: 266 Registered: July 2009 |
Senior Member |
|
|
Hi Christian,
As I said, I had put a breakpoint into getResolutions, but somehow this didn't get called. I had not put a breakpoint into hasResolutions.
Just tested this with the default DSML. There it seemed to work at first, but I was eventually able to replicate the issue there, too. In doing some more testing, I think I have narrowed the issue down a little more and am beginning to think this is an issue in Xtext. Here's what happens in more detail:
1. I choose to "validate" my model and the error marker is created.
2. In the errors list, this is shown with a lightbulb icon (I assume this means that hasResolutions has returned successfully for it).
3. When I click on the error marker in the Problems view, and select to see quick fixes, Eclipse tells me that there are no quick fixes. When I try and access quick fixes directly through the editor, this doesn't seem to happen. I only saw this for the default DSML so far, for my default there is still the warning marker on the same model element, which overlaps the error marker so that I cannot actually see the error marker in the editor.
So, the problem seems to be with getResolutions doing subtly different things depending on where it is called from. I will try and debug this some more to see what's going on.
BTW, is there a way in which in a validator I can remove an existing marker? In my example, I initially create a warning marker to flag that a more expensive validation is available, but has not been run for every edit. When the user explicitly invokes "validate", I would like to remove that warning and, possibly, replace it with an error marker if needed.
Many thanks,
Steffen
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06737 seconds