Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 114570 - Apply multiple quickfixes sometimes results in error
Summary: Apply multiple quickfixes sometimes results in error
Status: RESOLVED DUPLICATE of bug 114754
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 114754
Blocks: 23889
  Show dependency tree
 
Reported: 2005-11-01 12:12 EST by Michael Valenta CLA
Modified: 2005-11-07 10:29 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 Michael Valenta CLA 2005-11-01 12:12:28 EST
I was using the multi-select quickfix to fix improper static references to 
IStatus in the org.eclipse.team.cvs.core plugin. Basically, we had a bunch of 
CVSStatus.WARNING references that should be IStatus.WARNING references. The 
multi-quickfix support made this easy but in one case, the substituted 
reference was wrong (i.e. it was CVIStatusARNING instead of IStatus.WARNING). 
I had a similar problem occur when I fixed CVSStatus.ERROR references.
Comment 1 Dirk Baeumer CLA 2005-11-02 04:37:11 EST
Michael, do you have a test case for this. 

We had a discussion with Tod about multi applying quick fixes and the problem is
that the problem markers have to be adjusted after every quick fix. This is not
under control of JDT (so far). It has to be ensured by Platform/UI which
actually "spins" the loop for the multi quick fixes.
Comment 2 Dirk Baeumer CLA 2005-11-02 05:39:09 EST
OK, here is a test case:

- take org.eclipse.team.cvs.core version I20051031
- enable compiler warning to warn about "Indirect access to static member"
- open UpdateListener and focus problems view to the selected element
- apply multi quick fix to the indirect access problems
Comment 3 Dirk Baeumer CLA 2005-11-02 06:54:12 EST
I have tracked this down and the problem is that the JDT/UI infrastructure is
getting out of sync with the content of the compilation unit. The current
implementation brings the cached AST in sync using the reconcile. When the user
requests quick fix through the editor, we make sure that the editor is
reconciled hence we have an accurate AST.

However, when we run the quick fix in a loop triggered by multi applying them
the code still relies on reconcile to bring the AST in sync with the content of
the CU. However automatic reconcile is trigger n ms (I think 500ms) after the
last document change has occured. This means that some quick fixes compute their
changes on an AST that doesn't match the content of the CU. Hence they compute
textual changes at wrong positions (setting a breakpoint and interrupting the
loop for some time produces the correct matches).

As a side node: the problem already existed if the user changes the document and
quickly enough (< 500 ms) triggered the quick fix from the problems view.

JDT/Core has added API in M3 to broadcast the AST during reconcile. This will
allow IMarkerResolutionGenerator to reconcile the CU which would bring the AST
back in sync with the content. However using this new API is a bigger change
which can demange a lot of other editor infrastructure. Aditionally I would like
to discuss the consequences of such a change with Dani and Martin first. I
therefore opt to disable the Multi Quick Fix support for M3 in Platform/UI again.
Comment 4 Tod Creasey CLA 2005-11-02 07:08:44 EST
I would really hate to eliminate this feature in M3 - it is proving really
popular. Would I would be willing to do is to put in a workaround in M3 for your
issue to be resolved in M4.

We could either add in a delay in recomputation or do something more interesting
with a Job if this is possible at the UI level.
Comment 5 Michael Valenta CLA 2005-11-02 08:32:43 EST
My impression with using multi-quickfix is that there were a lot of kinks that 
need to be worked out. In some cases I got the problem stated above and in 
others it failed part way through due to previous changes. I think it would be 
worthwhile investigating having explicit API that supports batching which 
would eliminate both types of failures. 

Having said that, neither failure was so drastic that I would suggest 
disabling the feature. It is possible that this failure could result in code 
that was wrong but compiled and this would be a major problem but I think this 
is highly unlikely. Perhaps we should popup a warning in M3 that states that 
this feature is a work-in-progress and users should inpsect all changes to 
make sure they are correct (tha's what I did when I committed the fixes).
Comment 6 Dirk Baeumer CLA 2005-11-02 09:24:38 EST
IMO such a dialog will scare users (and will give the impression of a "half
baked feature"). 

Regarding how likely it is that this occurs: it will happen if two quick fixes
touch the same CU and the quick fix applied second changes code after code
touched by the first quick fix.

If you look at the new Clean Up action (available from source) we added for M3
you can see that we invested a lot for being able to multi apply quick fixes and
we had to tweak every quick fix that is currently supported. The problem is not
only to sync the AST with the CU. One of the major changes was that we are able
to reuse a created AST and that we detect case where both manipulate the same
textual region. Multi Quick fix will otherwise simply not scale.

So I am more in favour to disable for M3 and come up with a better API for M4 to
support applying multiple quick fixes. We can leverage and learn form the work
that Benno has done in JDT/UI during M3.
Comment 7 Martin Aeschlimann CLA 2005-11-04 18:14:48 EST
IMO it is a bug of the new UI in how it uses the marker resolution extension
point. It collects all the proposal first, but applies some of them after some
other changes have been made. The JDT UI quick fixes could be changed to handle
that, but I suspect that many other contributed resolutions will fail.

- Executing a quick fix might influence the fix for a second problem in the same
file. It might even make the fix unnecessary.
   -> After executing a fix, you platform UI should request the fix for the next
problem again)
- The action to fix more than one problem might be different than the fix for
one problem (see bug 111571)
Comment 8 Tod Creasey CLA 2005-11-07 08:13:50 EST
I agree Martin - you can't move on this until I have resolved Bug 114754
Comment 9 Martin Aeschlimann CLA 2005-11-07 09:51:26 EST
moving to platform.ui.
Comment 10 Tod Creasey CLA 2005-11-07 09:56:15 EST
Martin how do you want me to resolve this - as a dup of Bug 114754? This is
going to be obsolete when Bug 114754 is done - I can open one about you using
the new mechanism then.
Comment 11 Martin Aeschlimann CLA 2005-11-07 10:23:25 EST
Sure, mark it as dup of Bug 114754.
Comment 12 Tod Creasey CLA 2005-11-07 10:29:30 EST

*** This bug has been marked as a duplicate of 114754 ***