if (proposal.getVariableKind() == NewVariableCompletionProposal.FIELD) { assertTrue("2 field proposals", doField); doField= false;  buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append("    private int i;\n"); buf.append("\n"); buf.append("    void foo() {\n"); buf.append("        for (i= 0;;) {\n"); buf.append("        }\n"); buf.append("    }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } else if (proposal.getVariableKind() == NewVariableCompletionProposal.LOCAL) { assertTrue("2 local proposals", doLocal); doLocal= false;  buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append("    void foo() {\n"); buf.append("        for (int i = 0;;) {\n"); buf.append("        }\n"); buf.append("    }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } else if (proposal.getVariableKind() == NewVariableCompletionProposal.PARAM) { assertTrue("2 param proposals", doParam); doParam= false;  buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append("    void foo(int i) {\n"); buf.append("        for (i= 0;;) {\n"); buf.append("        }\n"); buf.append("    }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } else { assertTrue("unknown type", false); } }
proposal= (CUCorrectionProposal) proposals.get(2); String preview3= proposal.getCompilationUnitChange().getPreviewContent();  buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append("    void foo(int i) {\n"); buf.append("        for (i= 0;;) {\n"); buf.append("        }\n"); buf.append("    }\n"); buf.append("}\n"); String expected3= buf.toString();  assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 });
	public void testVarInForInitializer() 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("    void foo() {\n");		buf.append("        for (i= 0;;) {\n");		buf.append("        }\n");				buf.append("    }\n");		buf.append("}\n");		ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);				CompilationUnit astRoot= AST.parseCompilationUnit(cu, true);		ArrayList proposals= collectCorrections(cu, astRoot);		assertNumberOf("proposals", proposals.size(), 3);		assertCorrectLabels(proposals);				boolean doField= true, doParam= true, doLocal= true;		for (int i= 0; i < proposals.size(); i++) {			NewVariableCompletionProposal proposal= (NewVariableCompletionProposal) proposals.get(i);			String preview= proposal.getCompilationUnitChange().getPreviewContent();			if (proposal.getVariableKind() == NewVariableCompletionProposal.FIELD) {				assertTrue("2 field proposals", doField);				doField= false;								buf= new StringBuffer();				buf.append("package test1;\n");				buf.append("public class E {\n");				buf.append("    private int i;\n");				buf.append("\n");				buf.append("    void foo() {\n");				buf.append("        for (i= 0;;) {\n");				buf.append("        }\n");						buf.append("    }\n");				buf.append("}\n");				assertEqualString(preview, buf.toString());			} else if (proposal.getVariableKind() == NewVariableCompletionProposal.LOCAL) {				assertTrue("2 local proposals", doLocal);				doLocal= false;								buf= new StringBuffer();				buf.append("package test1;\n");				buf.append("public class E {\n");				buf.append("    void foo() {\n");				buf.append("        for (int i = 0;;) {\n");				buf.append("        }\n");						buf.append("    }\n");				buf.append("}\n");				assertEqualString(preview, buf.toString());			} else if (proposal.getVariableKind() == NewVariableCompletionProposal.PARAM) {				assertTrue("2 param proposals", doParam);				doParam= false;								buf= new StringBuffer();				buf.append("package test1;\n");				buf.append("public class E {\n");				buf.append("    void foo(int i) {\n");				buf.append("        for (i= 0;;) {\n");				buf.append("        }\n");						buf.append("    }\n");				buf.append("}\n");				assertEqualString(preview, buf.toString());			} else {				assertTrue("unknown type", false);			}		}	}	