|Providing quick fixes when IMarker are not created using Xtext's API [message #1829410]
||Thu, 02 July 2020 22:13
| Emmanuel Chebbi
Registered: February 2018
I have a DSL which is validaded through a custom AbstractDeclarativeValidator. The editor shows error markers and I now wish to provide quick fixes.
Currently the markers are not created through the warning and error methods but "manually" through IFile::createMarker (the main reason is basically that the AST is transformed multiple times and we do not have the original EObjects/EStructuralFeature at the end). The issue is that I don't manage to make the editor aware of my quick fixes (i.e. no little bulb on which we could click).
My first try to solve the issue:
- Declare a custom marker type through the org.eclipse.core.resources.markers extension point
- Declare a custom quick fix provider through the org.eclipse.ui.ide.markerResolution extension point
Result: the Problems view shows that quick fixes are available and allows me to select one however the editor only shows the warning/error icons.
Result: the quick fix is shown in the editor and can be triggered but only when the editor has just been created. If I type anything the validator is called again and the bare warning/error icons are shown again: quick fixes are not available anymore. If I close the editor then open it again then the quick fix is shown as expected, until I type something.
- Extend DefaultQuickfixProvider to provide the quick fixes
- Create the Marker with some attributes I've found after digging into Xtext's source code:
val marker = file.createMarker(MyMarkers.MY_WARNING) // also tried MarkerTypes.NORMAL_VALIDATION here
marker.setAttribute(IMarker.MESSAGE, "My warning message")
marker.setAttribute(Issue.URI_KEY, URI.createPlatformResourceURI(file.fullPath.toString, true).toString)
marker.setAttribute(IMarker.LOCATION, "line: " + 0 + " " + file.fullPath.toString())
I can only guess that some internal state is not set up properly and that my quick fixes are somehow discarded on refresh.
- An old bug talks about the IResourceUIValidatorExtension interface which looks very promising. This interface is still available in Xtext's source code but I can't make it work. I tried:
- To create a bindIResourceUIValidatorExtension() method in MyDslUiModule
- To make my validator extend the interface
- To add breakpoints everywhere in MarkerUpdaterImpl
- I searched for a relevant extension point but found nothing
Result: nothing happens, the methods/classes don't seem to be used anymore.
I'm running out of new ideas so would anyone have any advise to help me solve the issue?
Powered by FUDForum
. Page generated in 0.02110 seconds