Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 332133

Summary: [quick fix] light bulb shown but no quick fix for "undefined operator" problems
Product: [Eclipse Project] JDT Reporter: Deepak Azad <deepakazad>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P4 CC: markus.kell.r
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Deepak Azad CLA 2010-12-08 09:28:51 EST
build >=3.6

In the following snippet a light bulb is shown on the error marker but no quick fix is actually available.

public class Snippet {
	static void foo(int a, long b) {
		System.out.println(b == true); // error on this line 
	}
}
Comment 1 Markus Keller CLA 2010-12-08 10:26:52 EST
For performance reasons the lightbulb calculation is just an optimistic guess, and in this case, we do have quick fixes for some cases of invalid operators, but we cannot easily distinguish them from cases where we don't have a fix.

Sorry, we just have to live with that.
Comment 2 Deepak Azad CLA 2010-12-08 11:47:08 EST
(In reply to comment #1)
> For performance reasons the lightbulb calculation is just an optimistic guess,
I see! That explains why I get frustrated/puzzled with the light bulb from time to time.

> and in this case, we do have quick fixes for some cases of invalid operators,
> but we cannot easily distinguish them from cases where we don't have a fix.
> 
> Sorry, we just have to live with that.
Ok, the example in comment 0 was not good as a quick fix is not even possible. I was actually looking at something like the following snippet, which has 2 errors. Possibly quick fixes to add parenthesis could be offered in these cases.

	static void foo(int a, long b) {
		System.out.println((a == b) == b == 0);
		System.out.println( b & 0 > 0 && true);
	}

I guess the right thing to do is to find cases where a quick fix can be offered but is not, and fix these cases.
Comment 3 Markus Keller CLA 2010-12-08 12:04:25 EST
Yep, reopening as request for new quick fixes to add parentheses. See LocalCorrectionsSubProcessor#getInvalidOperatorProposals(..).