Bug 109730 Surround with runnable quick assist
Version: 3.1.0 Build id: I20050906-1200 Until now surround with runnable was only a text templat. This patches add a quick assist for surround with runnable. Variable declarations are made final and initializers are split off if required. Surround with runnable does not guarantee to generate syntactically correct code in every situation. i.e.: int i = 10, j = i; System.out.println(i); System.out.println(j); Applying surround with runnable on System.out.println(i); results in final int i = 10; int j = i; Runnable runnable = new Runnable() { public void run() { System.out.println(i); } } System.out.println(j);
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
		String preview1= getPreviewContent(proposal);
		buf= new StringBuffer();
		buf.append("package test1;\n");
		buf.append("import java.util.Vector;\n");				
		buf.append("public class E {\n");
		buf.append("    private Object[] objects;\n");
		buf.append("    public Vector goo() {\n");
		buf.append("        return null;\n");
		buf.append("    }\n");		
		buf.append("    public void foo() {\n");
		buf.append("        objects = goo().toArray();\n");
		buf.append("    }\n");
		buf.append("}\n");
		String expected1= buf.toString();
		
		proposal= (CUCorrectionProposal) proposals.get(1);
		String preview2= getPreviewContent(proposal);
		buf= new StringBuffer();
		buf.append("package test1;\n");
		buf.append("import java.util.Vector;\n");				
		buf.append("public class E {\n");
		buf.append("    public Vector goo() {\n");
		buf.append("        return null;\n");
		buf.append("    }\n");		
		buf.append("    public void foo() {\n");
		buf.append("        Object[] objects = goo().toArray();\n");
		buf.append("    }\n");
		buf.append("}\n");
		String expected2= buf.toString();