Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324391 - [content assist] Still too many semicolons after constructor completion
Summary: [content assist] Still too many semicolons after constructor completion
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.7 M2   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-03 06:49 EDT by Markus Keller CLA
Modified: 2011-09-13 08:40 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.