Bug 140584 - [quick assist] Add semicolon after Surround With > runnable if stmt
Summary: [quick assist] Add semicolon after Surround With > runnable if stmt
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 241653 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-05-08 11:06 EDT by Markus Keller CLA
Modified: 2008-07-22 09:26 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 2006-05-08 11:06:07 EDT
I20060505-1306, follow-up to bug 139932.

	public void foo() {
		int i= 10;
		System.out.println(i);
	}

- select any line, e.g. "int i= 10;"
- Surround With > runnable
- result is:
	public void foo() {
		int i;
		new Runnable() {
			public void run() {
				i = 10;
			}
		}		
		System.out.println(i);
	}

-> missing ";" after "new Runnable() {[..]}"
Comment 1 Dani Megert CLA 2006-05-09 04:44:41 EDT
Used to work in 3.1.x
Comment 2 Martin Aeschlimann CLA 2006-05-09 08:00:07 EDT
Benno, can you comment? I thought this was once discussed and there where reasosn for not having a semicolon in the template?
Comment 3 Benno Baumgartner CLA 2006-05-10 04:50:54 EDT
The reason for me not to have this implemented was my belive, that this is an enhancement request and there where enough bugs to fix. I would have to think about this again if this is a regression against 3.1.x, of course. However, I can not  bring 3.1.2 to insert this semicolon, the result produced by 3.1.2 is:

new Runnable() {
	public void run() {
		int i = 10;
	}
}
System.out.println(i);

With the only difference that the var decl is not splited. I can't see a regression here and I can't find a bug report ever requested that feature.

Workaround is to define two templates: Runnable expr and Runnable stmt, with the only difference that the second one ends with a semicolon.
Comment 4 Martin Aeschlimann CLA 2006-05-10 06:07:27 EDT
not for 3.2
Comment 5 Benno Baumgartner CLA 2007-04-25 06:11:57 EDT
Sorry guys, this is a tough one. I need a use case for this request.

I don't understand why you would want to have code like:

public void foo() {
     int i;
     new Runnable() {
         public void run() {
              i = 10;
         }
     };
     System.out.println(i);
}
Yes, it would compile, but it is useless... 

My point of view is if you want to have a statement then define another template which does assign the new runnable to a local variable.
Comment 6 Benno Baumgartner CLA 2008-07-16 06:35:34 EDT
Wontfix, workaround:

> My point of view is if you want to have a statement then define another
> template which does assign the new runnable to a local variable.



Comment 7 Markus Keller CLA 2008-07-22 09:11:42 EDT
*** Bug 241653 has been marked as a duplicate of this bug. ***
Comment 8 Markus Keller CLA 2008-07-22 09:25:26 EDT
We should really fix this.