org.eclipse.ltk.core.refactoring.RefactoringStatus.addError()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中org.eclipse.ltk.core.refactoring.RefactoringStatus.addError方法的一些代码示例,展示了RefactoringStatus.addError的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RefactoringStatus.addError方法的具体详情如下:
包路径:org.eclipse.ltk.core.refactoring.RefactoringStatus
类名称:RefactoringStatus
方法名:addError

RefactoringStatus.addError介绍

[英]Adds an ERROR entry filled with the given message to this status. If the current severity is OK, INFO or WARNING it will be changed to ERROR. It will remain unchanged otherwise.
[中]将包含给定消息的ERROR条目添加到此状态。如果当前严重性为OKINFOWARNING,则将更改为ERROR。否则将保持不变。

代码示例

代码示例来源:origin: eclipse/eclipse.jdt.ls

public void addErrorIfNecessary(RefactoringStatus status) {
  if (getMatches().size() != 0) {
    status.addError(RefactoringCoreMessages.ReferencesInBinaryContext_binaryRefsNotUpdated, this);
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ltk.core.refactoring

private void logMalfunctioningParticipant(RefactoringStatus status, ParticipantDescriptor descriptor, Throwable e) {
  status.addError(Messages.format(
    RefactoringCoreMessages.ParticipantExtensionPoint_participant_removed,
    descriptor.getName()));
  RefactoringCorePlugin.logRemovedParticipant(descriptor, e);
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

private void checkTypes(RefactoringStatus result, IMethod method, IType[] types, String key, IProgressMonitor pm) {
  pm.beginTask("", types.length); //$NON-NLS-1$
  for (int i= 0; i < types.length; i++) {
    pm.worked(1);
    IMethod[] overridden= types[i].findMethods(method);
    if (overridden != null && overridden.length > 0) {
      result.addError(
        Messages.format(key, BasicElementLabels.getJavaElementName(types[i].getElementName())),
        JavaStatusContext.create(overridden[0]));
    }
  }
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

private void validateFieldNames(RefactoringStatus status, String parameterName, IType type) {
  if (type.getField(parameterName).exists()) {
    Field[] fields= fDescriptor.getFields();
    for (int i= 0; i < fields.length; i++) {
      Field field= fields[i];
      if (parameterName.equals(field.getFieldName())){
        if (!field.isCreateField())
          status.addError(Messages.format(RefactoringCoreMessages.ExtractClassRefactoring_error_field_already_exists, BasicElementLabels.getJavaElementName(parameterName)));
      }
    }
  }
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

@Override
public void updateNode() throws JavaModelException {
  int start= fNode.getStartPosition();
  int length= fNode.getLength();
  String msg= "Cannot update found node: nodeType=" + fNode.getNodeType() + "; "  //$NON-NLS-1$//$NON-NLS-2$
      + fNode.toString() + "[" + start + ", " + length + "] in " + fCuRewrite.getCu();  //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
  JavaPlugin.log(new Exception(msg + ":\n" + fCuRewrite.getCu().getSource().substring(start, start + length))); //$NON-NLS-1$
  fResult.addError(msg, JavaStatusContext.create(fCuRewrite.getCu(), fNode));
}
@Override

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

@Override
public void updateNode() throws JavaModelException {
  int start= fNode.getStartPosition();
  int length= fNode.getLength();
  String msg= "Cannot update found node: nodeType=" + fNode.getNodeType() + "; "  //$NON-NLS-1$//$NON-NLS-2$
      + fNode.toString() + "[" + start + ", " + length + "] in " + fCuRewrite.getCu();  //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
  JavaPlugin.log(new Exception(msg + ":\n" + fCuRewrite.getCu().getSource().substring(start, start + length))); //$NON-NLS-1$
  fResult.addError(msg, JavaStatusContext.create(fCuRewrite.getCu(), fNode));
}
@Override

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

public final boolean visit(final EnumDeclaration node) {
  final String name= node.getName().getIdentifier();
  if (name.equals(getNewElementName())) {
    fStatus.addError(Messages.format(RefactoringCoreMessages.RenameTypeParameterRefactoring_type_parameter_inner_class_clash, new String[] { name}), JavaStatusContext.create(fTypeParameter.getDeclaringMember().getCompilationUnit(), new SourceRange(node)));
    return false;
  }
  return true;
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

public final boolean visit(final TypeDeclaration node) {
    final String name= node.getName().getIdentifier();
    if (name.equals(getNewElementName())) {
      fStatus.addError(Messages.format(RefactoringCoreMessages.RenameTypeParameterRefactoring_type_parameter_inner_class_clash, new String[] { name}), JavaStatusContext.create(fTypeParameter.getDeclaringMember().getCompilationUnit(), new SourceRange(node)));
      return false;
    }
    return true;
  }
}

代码示例来源:origin: eclipse/eclipse.jdt.ls

@Override
  public boolean visit(AbstractTypeDeclaration node) {
    String name= node.getName().getIdentifier();
    if (name.equals(getNewElementName())) {
      fStatus.addError(Messages.format(RefactoringCoreMessages.RenameTypeParameterRefactoring_type_parameter_inner_class_clash, new String[] { name}), JavaStatusContext.create(fTypeParameter.getDeclaringMember().getCompilationUnit(), SourceRangeFactory.create(node)));
      return true;
    }
    return true;
  }
}

代码示例来源:origin: eclipse/eclipse.jdt.ls

private static void addShadowsError(ICompilationUnit cu, SearchMatch oldMatch, RefactoringStatus result) {
  // Old match not found in new matches -> reference has been shadowed
  //TODO: should not have to filter declarations:
  if (oldMatch instanceof MethodDeclarationMatch || oldMatch instanceof FieldDeclarationMatch) {
    return;
  }
  ISourceRange range= new SourceRange(oldMatch.getOffset(), oldMatch.getLength());
  RefactoringStatusContext context= JavaStatusContext.create(cu, range);
  String message= Messages.format(RefactoringCoreMessages.RenameAnalyzeUtil_shadows, BasicElementLabels.getFileName(cu));
  result.addError(message, context);
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

private static void addShadowsError(ICompilationUnit cu, SearchMatch oldMatch, RefactoringStatus result) {
  // Old match not found in new matches -> reference has been shadowed
  
  //TODO: should not have to filter declarations:
  if (oldMatch instanceof MethodDeclarationMatch || oldMatch instanceof FieldDeclarationMatch)
    return;
  ISourceRange range= new SourceRange(oldMatch.getOffset(), oldMatch.getLength());
  RefactoringStatusContext context= JavaStatusContext.create(cu, range);
  String message= Messages.format(RefactoringCoreMessages.RenameAnalyzeUtil_shadows, cu.getElementName()); 
  result.addError(message, context);
}

代码示例来源:origin: eclipse/eclipse.jdt.ls

public static RefactoringStatus reportProblemNodes(String modifiedWorkingCopySource, SimpleName[] problemNodes) {
  RefactoringStatus result = new RefactoringStatus();
  for (int i = 0; i < problemNodes.length; i++) {
    RefactoringStatusContext context = new JavaStringStatusContext(modifiedWorkingCopySource, SourceRangeFactory.create(problemNodes[i]));
    result.addError(Messages.format(RefactoringCoreMessages.RefactoringAnalyzeUtil_name_collision, BasicElementLabels.getJavaElementName(problemNodes[i].getIdentifier())), context);
  }
  return result;
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

public static RefactoringStatus reportProblemNodes(String modifiedWorkingCopySource, SimpleName[] problemNodes) {
  RefactoringStatus result= new RefactoringStatus();
  for (int i= 0; i < problemNodes.length; i++) {
    RefactoringStatusContext context= new JavaStringStatusContext(modifiedWorkingCopySource, SourceRangeFactory.create(problemNodes[i]));
    result.addError(Messages.format(RefactoringCoreMessages.RefactoringAnalyzeUtil_name_collision, BasicElementLabels.getJavaElementName(problemNodes[i].getIdentifier())), context);
  }
  return result;
}

代码示例来源:origin: eclipse/eclipse.jdt.ls

private void analyzeImportedTypes(IType[] types, RefactoringStatus result, IImportDeclaration imp) throws CoreException {
  for (int i = 0; i < types.length; i++) {
    //could this be a problem (same package imports)?
    if (JdtFlags.isPublic(types[i]) && types[i].getElementName().equals(getNewElementName())) {
      String msg = Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_name_conflict1,
          new Object[] { JavaElementLabels.getElementLabel(types[i], JavaElementLabels.ALL_FULLY_QUALIFIED), BasicElementLabels.getPathLabel(getCompilationUnit(imp).getPath(), false) });
      result.addError(msg, JavaStatusContext.create(imp));
    }
  }
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

private void analyzeImportedTypes(IType[] types, RefactoringStatus result, IImportDeclaration imp) throws CoreException {
  for (int i= 0; i < types.length; i++) {
    //could this be a problem (same package imports)?
    if (JdtFlags.isPublic(types[i]) && types[i].getElementName().equals(getNewElementName())){
      String msg= Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_name_conflict1,
                                    new Object[]{ JavaElementLabels.getElementLabel(types[i], JavaElementLabels.ALL_FULLY_QUALIFIED), BasicElementLabels.getPathLabel(getCompilationUnit(imp).getPath(), false)});
      result.addError(msg, JavaStatusContext.create(imp));
    }
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

private void analyzeImportedTypes(IType[] types, RefactoringStatus result, IImportDeclaration imp) throws CoreException {
  for (int i= 0; i < types.length; i++) {
    //could this be a problem (same package imports)?
    if (JdtFlags.isPublic(types[i]) && types[i].getElementName().equals(getNewElementName())){
      String msg= Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_name_conflict1,
                                    new Object[]{ JavaElementLabels.getElementLabel(types[i], JavaElementLabels.ALL_FULLY_QUALIFIED), BasicElementLabels.getPathLabel(getCompilationUnit(imp).getPath(), false)});
      result.addError(msg, JavaStatusContext.create(imp));
    }
  }
}

代码示例来源:origin: eclipse/eclipse.jdt.ls

private RefactoringStatus checkNewAccessor(IMethod existingAccessor, String newAccessorName) throws CoreException{
  RefactoringStatus result= new RefactoringStatus();
  IMethod accessor= JavaModelUtil.findMethod(newAccessorName, existingAccessor.getParameterTypes(), false, fField.getDeclaringType());
  if (accessor == null || !accessor.exists()) {
    return null;
  }
  String message= Messages.format(RefactoringCoreMessages.RenameFieldRefactoring_already_exists,
      new String[]{JavaElementUtil.createMethodSignature(accessor), BasicElementLabels.getJavaElementName(fField.getDeclaringType().getFullyQualifiedName('.'))});
  result.addError(message, JavaStatusContext.create(accessor));
  return result;
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

private RefactoringStatus checkTypesInCompilationUnit() {
  RefactoringStatus result= new RefactoringStatus();
  if (! Checks.isTopLevel(fType)){ //the other case checked in checkTypesInPackage
    IType siblingType= fType.getDeclaringType().getType(getNewElementName());
    if (siblingType.exists()){
      String msg= Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_member_type_exists,
        new String[] { getNewElementLabel(), BasicElementLabels.getJavaElementName(fType.getDeclaringType().getFullyQualifiedName('.'))});
      result.addError(msg, JavaStatusContext.create(siblingType));
    }
  }
  return result;
}

代码示例来源:origin: eclipse/eclipse.jdt.ls

private RefactoringStatus checkTypesInCompilationUnit() {
  RefactoringStatus result = new RefactoringStatus();
  if (!Checks.isTopLevel(fType)) { //the other case checked in checkTypesInPackage
    IType siblingType = fType.getDeclaringType().getType(getNewElementName());
    if (siblingType.exists()) {
      String msg = Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_member_type_exists,
          new String[] { getNewElementLabel(), BasicElementLabels.getJavaElementName(fType.getDeclaringType().getFullyQualifiedName('.')) });
      result.addError(msg, JavaStatusContext.create(siblingType));
    }
  }
  return result;
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

private RefactoringStatus checkClass() {
  RefactoringStatus status= new RefactoringStatus();
  IType type= fDescriptor.getType();
  if (!fDescriptor.isCreateTopLevel()) {
    if (type.getType(fDescriptor.getClassName()).exists()) {
      status.addError(Messages.format(RefactoringCoreMessages.ExtractClassRefactoring_errror_nested_name_clash, new Object[] { BasicElementLabels.getJavaElementName(fDescriptor.getClassName()), BasicElementLabels.getJavaElementName(type.getElementName()) }));
    }
  } else {
    status.merge(checkPackageClass());
  }
  return status;
}

相关文章