Bug 153219 - [clean up][quick fix] Make 'Move else clause out of 'else'' a multi-fix
Summary: [clean up][quick fix] Make 'Move else clause out of 'else'' a multi-fix
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 enhancement with 6 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 408332 429238 486625 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-08 23:25 EDT by Philip King-Cherne CLA
Modified: 2016-01-27 13:14 EST (History)
9 users (show)

See Also:


Attachments
Shows a demonstration of the bug. (30.59 KB, image/png)
2007-02-04 17:54 EST, Antony Stubbs CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philip King-Cherne CLA 2006-08-08 23:25:09 EDT
While using either 3.2 or 3.3 (I20060807-2000) I am unable to consistantly use the 'Find similar problems' feature found when right clicking on a problem and slecting 'Quick Fix'.

For certain problems (Such as unused local variables) the feature appears to work fine. Others (Statement unnecessarily nested within else clause) do not... One of two things happen, either no other problems are found (See http://bluescreenofdeath.co.uk/eclipse/test-case.png ) or after a short freeze, no futher problems are found, I am unable to click cancel and a progress bar appears to be stuck (See http://bluescreenofdeath.co.uk/eclipse/exception.png ).

For the latter an exception also appears to occur (See http://bluescreenofdeath.co.uk/eclipse/dotlog.txt ).

I have hosted my 'Configuration' details at http://bluescreenofdeath.co.uk/eclipse/config.txt (This is a recent installation)

This can be reproduced using the following code:

public class Main {
	public static void main(String[] args) {
		boolean a = true;
		if (a)
			return false;
		else
			return true;

		boolean b = true;
		if (b)
			return false;
		else
			return true;

		boolean c = true;
		if (c)
			return false;
		else
			return true;
	}
}

And ensuring that the relevant option is selected for Compiler -> Errors/Warnings -> Uneccessary Code.

If there is any futher information that is needed I'll be happy to provide it.
Comment 1 Antony Stubbs CLA 2007-02-02 01:07:19 EST
I'm also experiencing this problem with trying to apply the quickfix to all the same javadoc problems in my file. happens consistently.
Running 3.2.1.

Got a whole lot of this in the log at the time i clicked "find similar":

!ENTRY org.eclipse.ui.ide 4 4 2007-02-02 19:00:52.037
!MESSAGE Error accessing marker type

!ENTRY org.eclipse.core.resources 4 376 2007-02-02 19:00:52.037
!MESSAGE Marker id: 752226 not found.

!ENTRY org.eclipse.ui.ide 4 4 2007-02-02 19:00:52.037
!MESSAGE Error accessing marker type

!ENTRY org.eclipse.core.resources 4 376 2007-02-02 19:00:52.037
!MESSAGE Marker id: 752226 not found.

!ENTRY org.eclipse.ui.ide 4 4 2007-02-02 19:00:52.052
!MESSAGE Error accessing marker type

!ENTRY org.eclipse.core.resources 4 376 2007-02-02 19:00:52.052
!MESSAGE Marker id: 752226 not found.

!ENTRY org.eclipse.ui.ide 4 4 2007-02-02 19:00:52.052
!MESSAGE Error accessing marker type

!ENTRY org.eclipse.core.resources 4 376 2007-02-02 19:00:52.052
!MESSAGE Marker id: 752226 not found.
Comment 2 Antony Stubbs CLA 2007-02-04 17:54:00 EST
Created attachment 58214 [details]
Shows a demonstration of the bug.

This shows a demonstration of the bug. You can see that Eclipse reports the same error in several places in the document, and provides a 'quick-fix'. However, after clicking on the 'find similar problems' button, there is an extreme short delay (small fraction of a second), and the button is disabled, and the other instances of the problem have not been listed.
Comment 3 Neale Upstone CLA 2007-04-13 10:55:54 EDT
Similarly, I've got a situation where my Problems view shows "Unhandled exception type BlahException" for several instances in the same source file, and "find similar problems" does not find the others in the same file.

I think that the pattern for multiple quickfixes here is ineffective.

What I want to do is to select a group of items in the Problems view, and click "Quick fix" and select the same solution for all of those.
Comment 4 martin.jaeger CLA 2009-06-17 09:40:03 EDT
I even think that this feature was removed for 3.4 and 3.5. If this is the case I will raise a feature request for the "find similar problems" feature again. Do anyone knows if the "find similar problems" feature was removed by intention?
Comment 5 Paul Webster CLA 2009-06-17 10:10:05 EDT
(In reply to comment #4)
> I even think that this feature was removed for 3.4 and 3.5. If this is the case
> I will raise a feature request for the "find similar problems" feature again.
> Do anyone knows if the "find similar problems" feature was removed by
> intention?

It is there.  Select  a marker in the Problems view and use Quick Fix.  That opens a dialog that tries to collect similar problems.

PW
Comment 6 Hitesh CLA 2009-07-09 03:23:21 EDT
The view was reworked in 3.4. Anyways, the feature to look up similar problems is still there and works well. It requires the fix/resolution to be a Multi-fix; see org.eclipse.ui.views.markers. WorkbenchMarkerResolution. findOtherMarkers(IMarker[]).  It really depends on the code providing the resolution to implement it that way (see extension point org.eclipse.ui.ide.markerResolution) .
Comment 7 Hitesh CLA 2010-04-12 03:49:56 EDT
See Comment 6, also the multi-fix is handled by QuickFix without any user intervention. 

I guess the fixes are contributed by JDT. Adding Dani for comment.
Comment 8 Dani Megert CLA 2010-04-12 04:36:12 EDT
>I guess the fixes are contributed by JDT. 
You're right Hitesh.

Multi-fix support is implemented on a case by case basis, depending how safe the quick fix is.

I agree that the 'Move else clause out of 'else'' quick fix could be a multi-fix. Moving to JDT UI.
Comment 9 Dani Megert CLA 2013-05-21 08:32:48 EDT
*** Bug 408332 has been marked as a duplicate of this bug. ***
Comment 10 Noopur Gupta CLA 2014-02-27 13:48:35 EST
*** Bug 429238 has been marked as a duplicate of this bug. ***
Comment 11 Markus Keller CLA 2016-01-27 13:08:14 EST
*** Bug 486625 has been marked as a duplicate of this bug. ***
Comment 12 Markus Keller CLA 2016-01-27 13:14:36 EST
Implementation also has to work with nested if statements, e.g.:

	void foo(boolean a, boolean b) {
		if (a) {
			System.out.println("a");
			return;
		} else {
			System.out.println("b");
			if (b) {
				System.out.println("c");
				return;
			} else {
				System.out.println("d");
			}
		}
	}