Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 110438 - [quick assist] surround with runnable: bug with control statement bodies
Summary: [quick assist] surround with runnable: bug with control statement bodies
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M3   Edit
Assignee: Benno Baumgartner CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-23 09:54 EDT by Martin Aeschlimann CLA
Modified: 2005-11-01 09:20 EST (History)
0 users

See Also:


Attachments
proposed fix (1.30 KB, patch)
2005-09-23 12:22 EDT, Benno Baumgartner CLA
no flags Details | Diff
Test (2.27 KB, patch)
2005-09-23 12:22 EDT, Benno Baumgartner CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2005-09-23 09:54:09 EDT
20050925

Surround the body ('g.drawImage(...)') of the if-statement:
class E {
	public void paint(Graphics g) {
		if (g != null)
			g.drawImage(null, 0, 0, 0, 0, null);
	}
}

-> Use ASTNodes.isControlStatementBody to detect if a block has to be introduced
for a statement.



java.lang.IllegalArgumentException: Node does not exist
	at org.eclipse.jdt.core.dom.rewrite.ListRewrite.insertAfter(ListRewrite.java:172)
	at
org.eclipse.jdt.internal.ui.text.correction.SurroundWithRunnableProposal.getRewrite(SurroundWithRunnableProposal.java:194)
	at
org.eclipse.jdt.internal.ui.text.correction.ASTRewriteCorrectionProposal.addEdits(ASTRewriteCorrectionProposal.java:61)
	at
org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.initializeTextChange(CUCorrectionProposal.java:141)
	at
org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.performChange(CUCorrectionProposal.java:278)
	at
org.eclipse.jdt.internal.ui.text.correction.LinkedCorrectionProposal.performChange(LinkedCorrectionProposal.java:231)
	at
org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.apply(CUCorrectionProposal.java:309)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:685)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertSelectedProposalWithMask(CompletionProposalPopup.java:631)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:1034)
	at
org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:637)
	at
org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:414)
	at
org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:51)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:884)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:908)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:893)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:676)
	at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5111)
	at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:4849)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:884)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:908)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:893)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:921)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:917)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1231)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3157)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3058)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3830)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1679)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2821)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1755)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1719)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:368)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106)
	at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:377)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:164)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:338)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)
Comment 1 Benno Baumgartner CLA 2005-09-23 12:22:25 EDT
Created attachment 27446 [details]
proposed fix
Comment 2 Benno Baumgartner CLA 2005-09-23 12:22:44 EDT
Created attachment 27447 [details]
Test
Comment 3 Martin Aeschlimann CLA 2005-10-11 04:38:26 EDT
patches released for I20051011
Comment 4 Benno Baumgartner CLA 2005-11-01 09:20:55 EST
Verified using I20051031-2000