本文整理汇总了Java中org.eclipse.jdt.internal.ui.text.correction.ProblemLocation类的典型用法代码示例。如果您正苦于以下问题:Java ProblemLocation类的具体用法?Java ProblemLocation怎么用?Java ProblemLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProblemLocation类属于org.eclipse.jdt.internal.ui.text.correction包,在下文中一共展示了ProblemLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCleanUp
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
public static ICleanUpFix createCleanUp(
CompilationUnit compilationUnit, IProblemLocation[] locations, int problemID) {
ICompilationUnit cu = (ICompilationUnit) compilationUnit.getJavaElement();
if (!JavaModelUtil.is50OrHigher(cu.getJavaProject())) return null;
List<CompilationUnitRewriteOperation> operations =
new ArrayList<CompilationUnitRewriteOperation>();
if (locations == null) {
org.eclipse.jdt.core.compiler.IProblem[] problems = compilationUnit.getProblems();
locations = new IProblemLocation[problems.length];
for (int i = 0; i < problems.length; i++) {
if (problems[i].getID() == problemID) locations[i] = new ProblemLocation(problems[i]);
}
}
createAddNullAnnotationOperations(compilationUnit, locations, operations);
createRemoveRedundantNullAnnotationsOperations(compilationUnit, locations, operations);
if (operations.size() == 0) return null;
CompilationUnitRewriteOperation[] operationsArray =
operations.toArray(new CompilationUnitRewriteOperation[operations.size()]);
return new NullAnnotationsFix(
FixMessages.NullAnnotationsFix_add_annotation_change_name,
compilationUnit,
operationsArray);
}
示例2: createCleanUp
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, IProblemLocation[] locations, int problemID) {
ICompilationUnit cu= (ICompilationUnit) compilationUnit.getJavaElement();
if (!JavaModelUtil.is50OrHigher(cu.getJavaProject()))
return null;
List<CompilationUnitRewriteOperation> operations= new ArrayList<CompilationUnitRewriteOperation>();
if (locations == null) {
org.eclipse.jdt.core.compiler.IProblem[] problems= compilationUnit.getProblems();
locations= new IProblemLocation[problems.length];
for (int i= 0; i < problems.length; i++) {
if (problems[i].getID() == problemID)
locations[i]= new ProblemLocation(problems[i]);
}
}
createAddNullAnnotationOperations(compilationUnit, locations, operations);
createRemoveRedundantNullAnnotationsOperations(compilationUnit, locations, operations);
if (operations.size() == 0)
return null;
CompilationUnitRewriteOperation[] operationsArray= operations.toArray(new CompilationUnitRewriteOperation[operations.size()]);
return new NullAnnotationsFix(FixMessages.NullAnnotationsFix_add_annotation_change_name, compilationUnit, operationsArray);
}
示例3: createCleanUp
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit,
boolean removeUnusedPrivateMethods,
boolean removeUnusedPrivateConstructors,
boolean removeUnusedPrivateFields,
boolean removeUnusedPrivateTypes,
boolean removeUnusedLocalVariables,
boolean removeUnusedImports,
boolean removeUnusedCast) {
IProblem[] problems= compilationUnit.getProblems();
IProblemLocation[] locations= new IProblemLocation[problems.length];
for (int i= 0; i < problems.length; i++) {
locations[i]= new ProblemLocation(problems[i]);
}
return createCleanUp(compilationUnit, locations,
removeUnusedPrivateMethods,
removeUnusedPrivateConstructors,
removeUnusedPrivateFields,
removeUnusedPrivateTypes,
removeUnusedLocalVariables,
removeUnusedImports,
removeUnusedCast);
}
示例4: getJavaAnnotationFixes
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
private ICompletionProposal[] getJavaAnnotationFixes(IJavaAnnotation javaAnnotation) {
ProblemLocation location= new ProblemLocation(position.getOffset(), position.getLength(), javaAnnotation);
ICompilationUnit cu= javaAnnotation.getCompilationUnit();
if (cu == null)
return NO_PROPOSALS;
ISourceViewer sourceViewer= null;
if (viewer instanceof ISourceViewer)
sourceViewer= (ISourceViewer) viewer;
IInvocationContext context= new AssistContext(cu, sourceViewer, location.getOffset(), location.getLength(), SharedASTProvider.WAIT_ACTIVE_ONLY);
if (!SpellingAnnotation.TYPE.equals(javaAnnotation.getType()) && !hasProblem(context.getASTRoot().getProblems(), location))
return NO_PROPOSALS;
ArrayList<IJavaCompletionProposal> proposals= new ArrayList<IJavaCompletionProposal>();
JavaCorrectionProcessor.collectCorrections(context, new IProblemLocation[] { location }, proposals);
Collections.sort(proposals, new CompletionProposalComparator());
return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
示例5: createCleanUp
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, IProblemLocation[] locations, int problemID) {
ICompilationUnit cu= (ICompilationUnit) compilationUnit.getJavaElement();
if (!JavaModelUtil.is50OrHigher(cu.getJavaProject()))
return null;
List<CompilationUnitRewriteOperation> operations= new ArrayList<CompilationUnitRewriteOperation>();
if (locations == null) {
org.eclipse.jdt.core.compiler.IProblem[] problems= compilationUnit.getProblems();
locations= new IProblemLocation[problems.length];
for (int i= 0; i < problems.length; i++) {
if (problems[i].getID() == problemID)
locations[i]= new ProblemLocation(problems[i]);
}
}
createAddNullAnnotationOperations(compilationUnit, locations, operations);
if (operations.size() == 0)
return null;
CompilationUnitRewriteOperation[] operationsArray= operations.toArray(new CompilationUnitRewriteOperation[operations.size()]);
return new MyCURewriteOperationsFix(NullFixMessages.QuickFixes_add_annotation_change_name, compilationUnit, operationsArray);
}
示例6: assertCorrectContext
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
public static void assertCorrectContext(IInvocationContext context, ProblemLocation problem) {
if (problem.getProblemId() != 0) {
if (!JavaCorrectionProcessor.hasCorrections(
context.getCompilationUnit(), problem.getProblemId(), problem.getMarkerType())) {
assertTrue("Problem type not marked with light bulb: " + problem, false);
}
}
}
示例7: testTodoTasks1
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
@Test
public void testTodoTasks1() 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");
assertEqualString(preview, buf.toString());
}
示例8: testTodoTasks2
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
@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());
}
示例9: testTodoTasks3
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
@Test
public void testTodoTasks3() 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");
assertEqualString(preview, buf.toString());
}
示例10: testTodoTasks4
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
@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());
}
示例11: testTodoTasks6
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
@Test
public void testTodoTasks6() 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());
}
示例12: testTodoTasks7
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
@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());
}
示例13: createCleanUp
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
public static ICleanUpFix createCleanUp(
CompilationUnit compilationUnit, boolean addSerialVersionIds) {
IProblem[] problems = compilationUnit.getProblems();
IProblemLocation[] locations = new IProblemLocation[problems.length];
for (int i = 0; i < problems.length; i++) {
locations[i] = new ProblemLocation(problems[i]);
}
return createCleanUp(compilationUnit, locations, addSerialVersionIds);
}
示例14: createCleanUp
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
public static ICleanUpFix createCleanUp(
CompilationUnit compilationUnit, boolean addNLSTag, boolean removeNLSTag)
throws CoreException, JavaModelException {
if (!addNLSTag && !removeNLSTag) return null;
IProblem[] problems = compilationUnit.getProblems();
IProblemLocation[] locations = new IProblemLocation[problems.length];
for (int i = 0; i < problems.length; i++) {
locations[i] = new ProblemLocation(problems[i]);
}
return createCleanUp(compilationUnit, addNLSTag, removeNLSTag, locations);
}
示例15: createCleanUp
import org.eclipse.jdt.internal.ui.text.correction.ProblemLocation; //导入依赖的package包/类
public static ICleanUpFix createCleanUp(
CompilationUnit compilationUnit,
boolean removeUnusedPrivateMethods,
boolean removeUnusedPrivateConstructors,
boolean removeUnusedPrivateFields,
boolean removeUnusedPrivateTypes,
boolean removeUnusedLocalVariables,
boolean removeUnusedImports,
boolean removeUnusedCast) {
IProblem[] problems = compilationUnit.getProblems();
IProblemLocation[] locations = new IProblemLocation[problems.length];
for (int i = 0; i < problems.length; i++) {
locations[i] = new ProblemLocation(problems[i]);
}
return createCleanUp(
compilationUnit,
locations,
removeUnusedPrivateMethods,
removeUnusedPrivateConstructors,
removeUnusedPrivateFields,
removeUnusedPrivateTypes,
removeUnusedLocalVariables,
removeUnusedImports,
removeUnusedCast);
}