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


Java IProblemLocation.getProblemId方法代码示例

本文整理汇总了Java中org.eclipse.jdt.ui.text.java.IProblemLocation.getProblemId方法的典型用法代码示例。如果您正苦于以下问题:Java IProblemLocation.getProblemId方法的具体用法?Java IProblemLocation.getProblemId怎么用?Java IProblemLocation.getProblemId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.ui.text.java.IProblemLocation的用法示例。


在下文中一共展示了IProblemLocation.getProblemId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCorrections

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
@Override
public IJavaCompletionProposal[] getCorrections(IInvocationContext context,
    IProblemLocation[] locations) throws CoreException {
  for (final IProblemLocation problem : locations) {
    if ((problem.getProblemId() == IProblem.UnresolvedVariable
        || problem.getProblemId() == IProblem.UndefinedType)
        && Utils.isAPGAS(problem.getProblemArguments()[0])) {
      if (!apgasInBuildPath(context.getCompilationUnit().getJavaProject())) {
        return getAddAPGASToBuildPathProposals(context);
      }
    } else if (problem.getProblemId() == IProblem.UndefinedMethod
        && Utils.isAPGAS(problem.getProblemArguments()[1])) {
      if (!apgasInBuildPath(context.getCompilationUnit().getJavaProject())) {
        return getAddAPGASToBuildPathProposals(context);
      } else {
        return getImportStaticConstructsProposal(context);
      }
    }
  }
  return null;
}
 
开发者ID:x10-lang,项目名称:apgas,代码行数:22,代码来源:APGASQuickfixProcessor.java

示例2: canFix

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) {
  if (IProblem.UnqualifiedFieldAccess == problem.getProblemId())
    return isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS)
        && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS);

  if (CodeStyleFix.isIndirectStaticAccess(problem))
    return isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS)
        && isEnabled(
            CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS);

  if (CodeStyleFix.isNonStaticAccess(problem))
    return isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS)
        && isEnabled(
            CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS);

  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:CodeStyleCleanUp.java

示例3: createUnusedTypeParameterFix

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
public static UnusedCodeFix createUnusedTypeParameterFix(
    CompilationUnit compilationUnit, IProblemLocation problemLoc) {
  if (problemLoc.getProblemId() == IProblem.UnusedTypeParameter) {
    SimpleName name = getUnusedName(compilationUnit, problemLoc);
    if (name != null) {
      IBinding binding = name.resolveBinding();
      if (binding != null) {
        String label = FixMessages.UnusedCodeFix_RemoveUnusedTypeParameter_description;
        RemoveUnusedTypeParameterOperation operation =
            new RemoveUnusedTypeParameterOperation(name);
        return new UnusedCodeFix(
            label,
            compilationUnit,
            new CompilationUnitRewriteOperation[] {operation},
            getCleanUpOptions(binding, false));
      }
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:UnusedCodeFix.java

示例4: createRemoveUnusedCastFix

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
public static UnusedCodeFix createRemoveUnusedCastFix(
    CompilationUnit compilationUnit, IProblemLocation problem) {
  if (problem.getProblemId() != IProblem.UnnecessaryCast) return null;

  ASTNode selectedNode = problem.getCoveringNode(compilationUnit);

  ASTNode curr = selectedNode;
  while (curr instanceof ParenthesizedExpression) {
    curr = ((ParenthesizedExpression) curr).getExpression();
  }

  if (!(curr instanceof CastExpression)) return null;

  return new UnusedCodeFix(
      FixMessages.UnusedCodeFix_RemoveCast_description,
      compilationUnit,
      new CompilationUnitRewriteOperation[] {new RemoveCastOperation((CastExpression) curr)});
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:UnusedCodeFix.java

示例5: getCorrections

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
public IJavaCompletionProposal[] getCorrections(
    IInvocationContext context, IProblemLocation[] locations) throws CoreException {
  if (locations == null || locations.length == 0) {
    return null;
  }

  HashSet<Integer> handledProblems = new HashSet<Integer>(locations.length);
  ArrayList<ICommandAccess> resultingCollections = new ArrayList<ICommandAccess>();
  for (int i = 0; i < locations.length; i++) {
    IProblemLocation curr = locations[i];
    Integer id = new Integer(curr.getProblemId());
    if (handledProblems.add(id)) {
      process(context, curr, resultingCollections);
    }
  }
  return resultingCollections.toArray(new IJavaCompletionProposal[resultingCollections.size()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:QuickFixProcessor.java

示例6: addUnusedMemberProposal

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
public static void addUnusedMemberProposal(
    IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
  int problemId = problem.getProblemId();
  UnusedCodeFix fix = UnusedCodeFix.createUnusedMemberFix(context.getASTRoot(), problem, false);
  if (fix != null) {
    addProposal(context, proposals, fix);
  }

  if (problemId == IProblem.LocalVariableIsNeverUsed) {
    fix = UnusedCodeFix.createUnusedMemberFix(context.getASTRoot(), problem, true);
    addProposal(context, proposals, fix);
  }

  if (problemId == IProblem.ArgumentIsNeverUsed) {
    JavadocTagsSubProcessor.getUnusedAndUndocumentedParameterOrExceptionProposals(
        context, problem, proposals);
  }

  if (problemId == IProblem.UnusedPrivateField) {
    GetterSetterCorrectionSubProcessor.addGetterSetterProposal(
        context, problem, proposals, IProposalRelevance.GETTER_SETTER_UNUSED_PRIVATE_FIELD);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:LocalCorrectionsSubProcessor.java

示例7: addRemoveRedundantAnnotationProposal

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
public static void addRemoveRedundantAnnotationProposal(
    IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
  NullAnnotationsFix fix =
      NullAnnotationsFix.createRemoveRedundantNullAnnotationsFix(context.getASTRoot(), problem);
  if (fix == null) return;

  Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
  Map<String, String> options = new Hashtable<String, String>();
  FixCorrectionProposal proposal =
      new FixCorrectionProposal(
          fix,
          new NullAnnotationsCleanUp(options, problem.getProblemId()),
          IProposalRelevance.REMOVE_REDUNDANT_NULLNESS_ANNOTATION,
          image,
          context);
  proposals.add(proposal);
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:NullAnnotationsCorrectionProcessor.java

示例8: canFix

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) {
  int id = problem.getProblemId();
  if (id == this.handledProblemID) {
    // FIXME search specifically: return param (which??)
    //			if (QuickFixes.hasExplicitNullnessAnnotation(compilationUnit, problem.getOffset()))
    //				return false;
    return true;
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:NullAnnotationsCleanUp.java

示例9: createAddFieldQualifierFix

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
public static CompilationUnitRewriteOperationsFix createAddFieldQualifierFix(
    CompilationUnit compilationUnit, IProblemLocation problem) {
  if (IProblem.UnqualifiedFieldAccess != problem.getProblemId()) return null;

  AddThisQualifierOperation operation =
      getUnqualifiedFieldAccessResolveOperation(compilationUnit, problem);
  if (operation == null) return null;

  String groupName = operation.getDescription();
  return new CodeStyleFix(
      groupName, compilationUnit, new CompilationUnitRewriteOperation[] {operation});
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:CodeStyleFix.java

示例10: createCleanUp

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
public static ICleanUpFix createCleanUp(
    CompilationUnit compilationUnit,
    IProblemLocation[] problems,
    boolean addThisQualifier,
    boolean changeNonStaticAccessToStatic,
    boolean changeIndirectStaticAccessToDirect) {

  if (!addThisQualifier && !changeNonStaticAccessToStatic && !changeIndirectStaticAccessToDirect)
    return null;

  List<CompilationUnitRewriteOperation> operations =
      new ArrayList<CompilationUnitRewriteOperation>();
  if (addThisQualifier) {
    for (int i = 0; i < problems.length; i++) {
      IProblemLocation problem = problems[i];
      if (problem.getProblemId() == IProblem.UnqualifiedFieldAccess) {
        AddThisQualifierOperation operation =
            getUnqualifiedFieldAccessResolveOperation(compilationUnit, problem);
        if (operation != null) operations.add(operation);
      }
    }
  }

  addToStaticAccessOperations(
      compilationUnit,
      problems,
      changeNonStaticAccessToStatic,
      changeIndirectStaticAccessToDirect,
      operations);

  if (operations.isEmpty()) return null;

  CompilationUnitRewriteOperation[] operationsArray =
      operations.toArray(new CompilationUnitRewriteOperation[operations.size()]);
  return new CodeStyleFix(FixMessages.CodeStyleFix_change_name, compilationUnit, operationsArray);
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:CodeStyleFix.java

示例11: createAddOverrideAnnotationOperations

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
private static void createAddOverrideAnnotationOperations(
    CompilationUnit compilationUnit,
    boolean addOverrideInterfaceAnnotation,
    IProblemLocation[] locations,
    List<CompilationUnitRewriteOperation> result) {
  for (int i = 0; i < locations.length; i++) {
    IProblemLocation problem = locations[i];
    int problemId = problem.getProblemId();

    if (isMissingOverrideAnnotationProblem(problemId)) {
      if (!isMissingOverrideAnnotationInterfaceProblem(problemId)
          || addOverrideInterfaceAnnotation) {
        ASTNode selectedNode = problem.getCoveringNode(compilationUnit);
        if (selectedNode != null) {

          ASTNode declaringNode = getDeclaringNode(selectedNode);
          if (declaringNode instanceof BodyDeclaration) {
            BodyDeclaration declaration = (BodyDeclaration) declaringNode;
            AnnotationRewriteOperation operation =
                new AnnotationRewriteOperation(declaration, OVERRIDE);
            result.add(operation);
          }
        }
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:Java50Fix.java

示例12: canFix

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) {
  if (problem.getProblemId() == IProblem.UnnecessaryCast)
    return isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_CASTS);

  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:UnnecessaryCodeCleanUp.java

示例13: canFix

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) {
  int id = problem.getProblemId();
  if (id == IProblem.AbstractMethodMustBeImplemented
      || id == IProblem.EnumConstantMustImplementAbstractMethod)
    return isEnabled(CleanUpConstants.ADD_MISSING_METHODES) || isEnabled(MAKE_TYPE_ABSTRACT);

  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:UnimplementedCodeCleanUp.java

示例14: canFix

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) {
  if (problem.getProblemId() == IProblem.MissingSerialVersion)
    return (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID)
            && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED))
        || (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID)
            && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT));

  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:PotentialProgrammingProblemsCleanUp.java

示例15: containsMatchingProblem

import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入方法依赖的package包/类
private static boolean containsMatchingProblem(IProblemLocation[] locations, int problemId) {
  if (locations != null) {
    for (int i = 0; i < locations.length; i++) {
      IProblemLocation location = locations[i];
      if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(location.getMarkerType())
          && location.getProblemId() == problemId) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:QuickAssistProcessor.java


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