use of org.eclipse.jdt.internal.ui.text.correction.ProblemLocation in project che by eclipse.
the class QuickFixTest method collectCorrections.
protected static final ArrayList collectCorrections(ICompilationUnit cu, IProblem curr, IInvocationContext context) throws CoreException {
int offset = curr.getSourceStart();
int length = curr.getSourceEnd() + 1 - offset;
if (context == null) {
context = new AssistContext(cu, offset, length);
}
ProblemLocation problem = new ProblemLocation(curr);
ArrayList proposals = collectCorrections(context, problem);
if (!proposals.isEmpty()) {
assertCorrectContext(context, problem);
}
return proposals;
}
use of org.eclipse.jdt.internal.ui.text.correction.ProblemLocation 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.internal.ui.text.correction.ProblemLocation in project che by eclipse.
the class ReorgQuickFixTest method testTodoTasks4.
@Test
public void testTodoTasks4() 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(" 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("}\n");
assertEqualString(preview, buf.toString());
}
use of org.eclipse.jdt.internal.ui.text.correction.ProblemLocation in project che by eclipse.
the class ReorgQuickFixTest method testTodoTasks2.
@Test
public void testTodoTasks2() 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(" // Some other text TODO: XXX\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(" // Some other text \n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
use of org.eclipse.jdt.internal.ui.text.correction.ProblemLocation in project che by eclipse.
the class ReorgQuickFixTest method testTodoTasks7.
@Test
public void testTodoTasks7() 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(" /* TODO: XXX*/;\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(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
Aggregations