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

Bug 324391

Summary: [content assist] Still too many semicolons after constructor completion
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: TextAssignee: Dani Megert <daniel_megert>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, stephan.herrmann
Version: 3.7   
Target Milestone: 3.7 M2   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Markus Keller CLA 2010-09-03 06:49:01 EDT
Follow-up to bug 280801 (AnonymousTypeCompletionProposal 1.93)

public class Try {
	void foo(Object o) {
		take(null, (String) o);
	}

	private void take(Runnable r, String s) {
	}
}

Replace 'null' with 'new Runna' and accept the proposal. Result:

		take(new Runnable() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				
			}
		};,, (String) o);
// too much      ^^
Comment 1 Markus Keller CLA 2010-09-03 07:15:50 EDT
>         };,, (String) o);
> // too much      ^^

Grr.., I meant:

          };,, (String) o);
  too much ^^


This heuristic will continue to cause trouble. I saw that AnonymousTypeCompletionProposal#createNewBody(..) already creates an AST, and I think that should be used to find out whether the enclosing statement is missing a ';' or not.

Even harder example:
		take(null,
				(String) o);
Comment 2 Dani Megert CLA 2010-09-03 09:03:32 EDT
I've fixed the ',' case. We can see whether more work is needed in the future but at this time I don't have time to rewrite the heuristic based on the AST.

Please reopen if you have more cases that disturb you in your daily work.
Comment 3 Dani Megert CLA 2010-09-03 09:03:44 EDT
Fix is in AnonymousTypeCompletionProposal.
Comment 4 Dani Megert CLA 2010-09-15 02:07:04 EDT
Verified in I20100914-0100.
Comment 5 Stephan Herrmann CLA 2011-09-13 07:55:19 EDT
(In reply to comment #2)
> Please reopen if you have more cases that disturb you in your daily work.

Not during daily work but while verifying bug 292087 I came across this:

Before completion:

class Bug324391 {
	private Runnable jobs[] = {
		new Run|
	};
}


After completion:

class Bug324391 {
	private Runnable jobs[] = {
		new Runnable() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				
			}
		};	
	};
}

Compiler says:
Syntax error on token ";", , expected
Comment 6 Dani Megert CLA 2011-09-13 08:40:22 EDT
.
Comment 7 Dani Megert CLA 2011-09-13 08:40:40 EDT
Please file a new bug.