Bug 511101 - [Generic Editor] misses quick fix on error markers
Summary: [Generic Editor] misses quick fix on error markers
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.7 M6   Edit
Assignee: Mickael Istria CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 510898
  Show dependency tree
 
Reported: 2017-01-26 10:37 EST by Mickael Istria CLA
Modified: 2021-01-27 03:21 EST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2017-01-26 10:37:11 EST
The Generic Editor shows error markers, but doesn't provide the quickfixes to troubleshoot the errors.
To try it:
* Create a file such as a MANIFEST.MF with errors and quick-fixes available for those errors
* Open With > Generic Editor
* See error markers there, no quickfix proposal
Comment 1 Mickael Istria CLA 2017-01-26 10:45:26 EST
This is the same behavior on the plain text editor. Would it make sense and be an acceptable change to try to enable quick fixes on the default text editor as well if the generic editor can inherit from it?
Comment 2 Andrey Loskutov CLA 2017-01-26 10:53:48 EST
(In reply to Mickael Istria from comment #1)
> This is the same behavior on the plain text editor. Would it make sense and
> be an acceptable change to try to enable quick fixes on the default text
> editor as well if the generic editor can inherit from it?

From the user perspective it doesn't matter in which editor marker appears, but *if* it appears and can be fixed in one editor, why it should not be fixable in another?
Comment 3 Mickael Istria CLA 2017-01-27 07:45:52 EST
That would most likely require to add a dependency on org.eclipse.ui.ide, which defines the marker resolution extension point. I'm not sure this is something we want to allow for the legacy text editor. However, for the Generic Editor, I don't see anything wrong with adding this dependency.
@Dani: WDYT? Can the generic editor depend on the org.eclipse.ui.ide bundle to provide that feature?
Comment 4 Dani Megert CLA 2017-02-01 11:23:45 EST
(In reply to Mickael Istria from comment #3)
> That would most likely require to add a dependency on org.eclipse.ui.ide,
> which defines the marker resolution extension point. I'm not sure this is
> something we want to allow for the legacy text editor. However, for the
> Generic Editor, I don't see anything wrong with adding this dependency.
> @Dani: WDYT? Can the generic editor depend on the org.eclipse.ui.ide bundle
> to provide that feature?

Yep, our Text Editor in 'org.eclipse.ui.editors' does the same.
Comment 5 Eclipse Genie CLA 2017-02-05 23:36:04 EST
New Gerrit change created: https://git.eclipse.org/r/90382
Comment 7 Eclipse Genie CLA 2017-02-22 04:36:39 EST
New Gerrit change created: https://git.eclipse.org/r/91599
Comment 9 Markus Keller CLA 2017-02-27 09:30:36 EST
Please remove the dependency from org.eclipse.ui.genericeditor.tests to org.eclipse.ui.tests.harness.

The eclipse.platform.text repo should not require developers to check out the huge eclipse.platform.ui repo, and especially not the ill-designed test bundles in that repo that clutter runtime workspaces with bad contributions.
Comment 10 Markus Keller CLA 2017-02-28 12:33:27 EST
org.eclipse.ui.tests.harness.util.DisplayHelper#runEventLoop(Display, long) is responsible for the DNFs on Windows since I20170222-2000:

     [java] org.eclipse.test.EclipseTestRunner$ThreadDump: for thread "main"
     [java] 	at org.eclipse.swt.internal.win32.OS.WaitMessage(Native Method)
     [java] 	at org.eclipse.swt.widgets.Display.sleep(Display.java:4859)
     [java] 	at org.eclipse.ui.tests.harness.util.DisplayHelper.runEventLoop(DisplayHelper.java:147)
     [java] 	at org.eclipse.ui.genericeditor.tests.HoverTest.getHoverShell(HoverTest.java:126)
     [java] 	at org.eclipse.ui.genericeditor.tests.HoverTest.testHover(HoverTest.java:86)

Looks like that method calls Display#sleep() without ensuring that another thread eventually wakes up the main thread.
Comment 11 Mickael Istria CLA 2017-02-28 12:39:56 EST
(In reply to Markus Keller from comment #10)
> org.eclipse.ui.tests.harness.util.DisplayHelper#runEventLoop(Display, long)
> is responsible for the DNFs on Windows since I20170222-2000:

Thanks for checking Markus. Before I implement a waitAndDispatch manually, do you have any idea of another existing method (accessible from platform.text) which could do the same thing in a better way?
Comment 12 Markus Keller CLA 2017-03-08 12:31:21 EST
I don't know what exactly is wrong with DisplayHelper#runEventLoop(..), but in org.eclipse.jdt.text.tests, we've removed all usages of it because it caused trouble.

In your case, the problem could also be the endless loop you implemented in HoverTest#getHoverShell(..) in case the condition never becomes true. A better way to implement this is to use waitForCondition(..).

I've cleaned up a few things, removed the dependency on platform.ui tests, and added a copy of DisplayHelper to org.eclipse.jface.text.tests.util: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=dad356880b62128e58665dd3e641e51ab61e03c0
Comment 13 Markus Keller CLA 2017-03-09 12:08:45 EST
Tests are looking good for I20170308-2000, just two failures due to bug 513394 (firewall dialog):

java.lang.AssertionError
at org.eclipse.ui.genericeditor.tests.HoverTest.getHoverShell(HoverTest.java:142)
at org.eclipse.ui.genericeditor.tests.HoverTest.testHover(HoverTest.java:94)
at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:749)
at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:350)

... and similar for HoverTest.testProblemHover.
Comment 14 Mickael Istria CLA 2017-03-09 12:30:08 EST
Thanks a lot for looking at it Markus, it's much appreciated!
I've opened bug 513399 to consider improving the state of the DisplayHelpers in general some day.
Comment 15 Lars Vogel CLA 2017-05-12 01:52:08 EDT
(In reply to Markus Keller from comment #12)
> I've cleaned up a few things, removed the dependency on platform.ui tests,
> and added a copy of DisplayHelper to org.eclipse.jface.text.tests.util:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=dad356880b62128e58665dd3e641e51ab61e03c0

Incorrect reference, looks like http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=dad356880b62128e58665dd3e641e51ab61e03c0 is the correct one. In master, I still see a dependency to  org.eclipse.ui.tests.harness. Opened Bug 516534 for that.
Comment 16 Christoph Laeubrich CLA 2021-01-26 13:44:43 EST
This is marked as "fixed" but I'm still having trouble with the GenericEditor, is there anything special to consider compared to other editor types?

In the "Problems View" my Quickfix is available and can be applied, but in the Generic editor neither STRG+1 nor clicking on the marker icon works (nothing happens, my code is never called).
Comment 17 Mickael Istria CLA 2021-01-26 14:43:19 EST
Here I see (with Wild Web Developer in a .css file; inserting a "background-colo: blue") a quick-fix accessible by Ctrl+1 or hovering on the error; but on the icon marker only error is shown, no quickfix.
Comment 18 Christoph Laeubrich CLA 2021-01-27 01:50:50 EST
Really strange. I noticed that when i open it in the plain text editor I can CTRL+1 and then get "no suggestions available", CTRL+1 in generic editor for the same file simply do nothing.
Comment 19 Christoph Laeubrich CLA 2021-01-27 02:45:04 EST
The problem is in org.eclipse.ui.internal.genericeditor.markers.MarkerResoltionQuickAssistProcessor.computeQuickAssistProposals(IQuickAssistInvocationContext):


if (invocationContext.getOffset() >= position.getOffset() &&
				invocationContext.getOffset() + Math.max(0, invocationContext.getLength()) <= position.getOffset() + position.getLength() &&
				annotation instanceof MarkerAnnotation) {

for my particular example 
> invocationContext.getOffset() = 609
> position.getOffset() = 598
> invocationContext.getLength() = -1
> position.getLength() = 0

this evaluates to 
> if (609 >= 589 && --> true
> 609 + Math.max(0, -1) <= 589 + 0 && --> false
> annotation instanceof MarkerAnnotation) { --> true
> --> false

and because of this my QuickAssist processor is never called. What indeed works is placing the cursor at the beginning of the line. Clicking at the item seems to never work.
Comment 20 Mickael Istria CLA 2021-01-27 03:00:53 EST
@Christoph Please submit a new bug report for this with the details mentioned in last comment.