use of org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal in project che by eclipse.
the class UnresolvedTypesQuickFixTest method testAmbiguousTypeInSuperClass.
@Test
@Ignore
public void testAmbiguousTypeInSuperClass() throws Exception {
createSomeAmbiguity(false, false);
IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf = new StringBuffer();
buf.append("package test1;\n");
buf.append("import test2.*;\n");
buf.append("import test3.*;\n");
buf.append("public class E extends A {\n");
buf.append(" B b;\n");
buf.append(" C c;\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
CompilationUnit astRoot = getASTRoot(cu);
ArrayList proposals = collectCorrections(cu, astRoot);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0);
String preview1 = getPreviewContent(proposal);
buf = new StringBuffer();
buf.append("package test1;\n");
buf.append("import test2.*;\n");
buf.append("import test2.A;\n");
buf.append("import test3.*;\n");
buf.append("public class E extends A {\n");
buf.append(" B b;\n");
buf.append(" C c;\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 test2.*;\n");
buf.append("import test3.*;\n");
buf.append("import test3.A;\n");
buf.append("public class E extends A {\n");
buf.append(" B b;\n");
buf.append(" C c;\n");
buf.append("}\n");
String expected2 = buf.toString();
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
use of org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal in project che by eclipse.
the class UnresolvedTypesQuickFixTest method testAmbiguousTypeInField.
@Test
@Ignore
public void testAmbiguousTypeInField() throws Exception {
createSomeAmbiguity(true, false);
IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf = new StringBuffer();
buf.append("package test1;\n");
buf.append("import test2.*;\n");
buf.append("import test3.*;\n");
buf.append("public class E {\n");
buf.append(" A a;\n");
buf.append(" B b;\n");
buf.append(" C c;\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
CompilationUnit astRoot = getASTRoot(cu);
ArrayList proposals = collectCorrections(cu, astRoot);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0);
String preview1 = getPreviewContent(proposal);
buf = new StringBuffer();
buf.append("package test1;\n");
buf.append("import test2.*;\n");
buf.append("import test2.A;\n");
buf.append("import test3.*;\n");
buf.append("public class E {\n");
buf.append(" A a;\n");
buf.append(" B b;\n");
buf.append(" C c;\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 test2.*;\n");
buf.append("import test3.*;\n");
buf.append("import test3.A;\n");
buf.append("public class E {\n");
buf.append(" A a;\n");
buf.append(" B b;\n");
buf.append(" C c;\n");
buf.append("}\n");
String expected2 = buf.toString();
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
use of org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal in project che by eclipse.
the class QuickFixTest method assertNumberOfProposals.
protected static void assertNumberOfProposals(List proposals, int expectedProposals) {
if (proposals.size() != expectedProposals) {
StringBuffer buf = new StringBuffer();
buf.append("Wrong number of proposals, is: ").append(proposals.size()).append(", expected: ").append(expectedProposals).append('\n');
for (int i = 0; i < proposals.size(); i++) {
ICompletionProposal curr = (ICompletionProposal) proposals.get(i);
buf.append(" - ").append(curr.getDisplayString()).append('\n');
if (curr instanceof CUCorrectionProposal) {
appendSource(((CUCorrectionProposal) curr), buf);
}
}
assertTrue(buf.toString(), false);
}
}
use of org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal in project che by eclipse.
the class ReorgQuickFixTest method testTodoTasks5.
@Test
public void testTodoTasks5() 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");
buf.append(" /**\n");
buf.append(" Some other text: TODO: XXX\n");
buf.append(" */\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str = "TODO: XXX";
AssistContext context = getCorrectionContext(cu, buf.toString().indexOf(str), 0);
ProblemLocation problem = new ProblemLocation(buf.toString().indexOf(str), str.length(), IProblem.Task, new String[0], true, IJavaModelMarker.TASK_MARKER);
ArrayList proposals = collectCorrections(context, problem);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal = (CUCorrectionProposal) proposals.get(0);
String preview = getPreviewContent(proposal);
buf = new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" /**\n");
buf.append(" Some other text: \n");
buf.append(" */\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
use of org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal in project che by eclipse.
the class ReorgQuickFixTest method testUnusedImports.
@Test
public void testUnusedImports() throws Exception {
IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf = new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Vector;\n");
buf.append("public class E {\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
CompilationUnit astRoot = getASTRoot(cu);
ArrayList proposals = collectCorrections(cu, astRoot);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
Object p1 = proposals.get(0);
if (!(p1 instanceof CUCorrectionProposal)) {
p1 = proposals.get(1);
}
CUCorrectionProposal proposal = (CUCorrectionProposal) p1;
String preview = getPreviewContent(proposal);
buf = new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
Aggregations