Bug 110438 [quick assist] surround with runnable: bug with control statement bodies
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)
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
        context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
        proposals= collectAssists(context, FILTER_EQ);
        
        assertNumberOfProposals(proposals, 1);
        assertCorrectLabels(proposals);
        
        proposal= (CUCorrectionProposal) proposals.get(0);
        preview= getPreviewContent(proposal);
        buf= new StringBuffer();
        buf.append("package test1;\n");
        buf.append("class A {\n");
        buf.append("    static String get() {\n");
        buf.append("        return \"a\";\n");
        buf.append("    }\n");
        buf.append("}\n");
        buf.append("public class E {\n");
        buf.append("    public void foo() {\n");
        buf.append("        \"a\".equals(A.get());\n");
        buf.append("    }\n");
        buf.append("}\n");
        assertEqualString(preview, buf.toString());
    }
    public void testInvertEquals7() throws Exception {
        IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
        StringBuffer buf= new StringBuffer();
        buf.append("package test1;\n");
        buf.append("public class E {\n");
        buf.append("    public void foo() {\n");