当前位置: 首页>>代码示例>>Java>>正文


Java ProblemLocation类代码示例

本文整理汇总了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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:NullAnnotationsFix.java

示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:NullAnnotationsFix.java

示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:UnusedCodeFix.java

示例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()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:ProblemHover.java

示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:NullQuickFixes.java

示例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);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:QuickFixTest.java

示例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());
}
 
开发者ID:eclipse,项目名称:che,代码行数:39,代码来源:ReorgQuickFixTest.java

示例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());
}
 
开发者ID:eclipse,项目名称:che,代码行数:40,代码来源:ReorgQuickFixTest.java

示例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());
}
 
开发者ID:eclipse,项目名称:che,代码行数:39,代码来源:ReorgQuickFixTest.java

示例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());
}
 
开发者ID:eclipse,项目名称:che,代码行数:41,代码来源:ReorgQuickFixTest.java

示例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());
}
 
开发者ID:eclipse,项目名称:che,代码行数:40,代码来源:ReorgQuickFixTest.java

示例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());
}
 
开发者ID:eclipse,项目名称:che,代码行数:40,代码来源:ReorgQuickFixTest.java

示例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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:PotentialProgrammingProblemsFix.java

示例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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:StringFix.java

示例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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:UnusedCodeFix.java


注:本文中的org.eclipse.jdt.internal.ui.text.correction.ProblemLocation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。