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


Java RefactoringStatus.createErrorStatus方法代码示例

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


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

示例1: checkTypesImportedInCu

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkTypesImportedInCu() throws CoreException {
  IImportDeclaration imp = getImportedType(fType.getCompilationUnit(), getNewElementName());

  if (imp == null) return null;

  String msg =
      Messages.format(
          RefactoringCoreMessages.RenameTypeRefactoring_imported,
          new Object[] {
            getNewElementLabel(),
            BasicElementLabels.getPathLabel(
                fType.getCompilationUnit().getResource().getFullPath(), false)
          });
  IJavaElement grandParent = imp.getParent().getParent();
  if (grandParent instanceof ICompilationUnit)
    return RefactoringStatus.createErrorStatus(msg, JavaStatusContext.create(imp));

  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:RenameTypeProcessor.java

示例2: checkStructure

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkStructure(IMember member) throws JavaModelException {
	if (!member.isStructureKnown())
		return RefactoringStatus.createErrorStatus(
				MessageFormat.format(Messages.CUContainsCompileErrors, getElementLabel(member, ALL_FULLY_QUALIFIED),
						getElementLabel(member.getCompilationUnit(), ALL_FULLY_QUALIFIED)),
				JavaStatusContext.create(member.getCompilationUnit()));
	return new RefactoringStatus();
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:9,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java

示例3: checkTypesInPackage

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkTypesInPackage() throws CoreException {
  IType type = Checks.findTypeInPackage(fType.getPackageFragment(), getNewElementName());
  if (type == null || !type.exists()) return null;
  String msg =
      Messages.format(
          RefactoringCoreMessages.RenameTypeRefactoring_exists,
          new String[] {
            getNewElementLabel(),
            JavaElementLabels.getElementLabel(
                fType.getPackageFragment(), JavaElementLabels.ALL_DEFAULT)
          });
  return RefactoringStatus.createErrorStatus(msg, JavaStatusContext.create(type));
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:RenameTypeProcessor.java

示例4: checkEnclosedTypes

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkEnclosedTypes() throws CoreException {
  IType enclosedType = findEnclosedType(fType, getNewElementName());
  if (enclosedType == null) return null;
  String msg =
      Messages.format(
          RefactoringCoreMessages.RenameTypeRefactoring_encloses,
          new String[] {
            BasicElementLabels.getJavaElementName(fType.getFullyQualifiedName('.')),
            getNewElementLabel()
          });
  return RefactoringStatus.createErrorStatus(msg, JavaStatusContext.create(enclosedType));
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:RenameTypeProcessor.java

示例5: checkEnclosingTypes

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkEnclosingTypes() {
  IType enclosingType = findEnclosingType(fType, getNewElementName());
  if (enclosingType == null) return null;

  String msg =
      Messages.format(
          RefactoringCoreMessages.RenameTypeRefactoring_enclosed,
          new String[] {
            BasicElementLabels.getJavaElementName(fType.getFullyQualifiedName('.')),
            getNewElementLabel()
          });
  return RefactoringStatus.createErrorStatus(msg, JavaStatusContext.create(enclosingType));
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:RenameTypeProcessor.java

示例6: checkConstantNameOnChange

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
/**
 * This method performs checks on the constant name which are quick enough to be performed every
 * time the ui input component contents are changed.
 *
 * @return return the resulting status
 * @throws JavaModelException thrown when the operation could not be executed
 */
public RefactoringStatus checkConstantNameOnChange() throws JavaModelException {
  if (Arrays.asList(getExcludedVariableNames()).contains(fConstantName))
    return RefactoringStatus.createErrorStatus(
        Messages.format(
            RefactoringCoreMessages.ExtractConstantRefactoring_another_variable,
            BasicElementLabels.getJavaElementName(getConstantName())));
  return Checks.checkConstantName(fConstantName, fCu);
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:ExtractConstantRefactoring.java

示例7: isUniqueMethodName

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
/**
 * @param methodName
 * @return a <code>RefactoringStatus</code> that identifies whether the the name <code>
 *     newMethodName</code> is available to use as the name of the new factory method within the
 *     factory-owner class (either a to-be- created factory class or the constructor-owning class,
 *     depending on the user options).
 */
private RefactoringStatus isUniqueMethodName(String methodName) {
  ITypeBinding declaringClass = fCtorBinding.getDeclaringClass();
  if (Bindings.findMethodInType(declaringClass, methodName, fCtorBinding.getParameterTypes())
      != null) {
    String format =
        Messages.format(
            RefactoringCoreMessages.IntroduceFactory_duplicateMethodName,
            BasicElementLabels.getJavaElementName(methodName));
    return RefactoringStatus.createErrorStatus(format);
  }
  return new RefactoringStatus();
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:IntroduceFactoryRefactoring.java

示例8: verifyDestination

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
/** {@inheritDoc} */
public RefactoringStatus verifyDestination(IReorgDestination destination)
    throws JavaModelException {
  if (destination instanceof JavaElementDestination) {
    return verifyDestination(((JavaElementDestination) destination).getJavaElement());
  } else if (destination instanceof ResourceDestination) {
    return verifyDestination(((ResourceDestination) destination).getResource());
  }

  return RefactoringStatus.createErrorStatus(
      RefactoringCoreMessages.ReorgPolicyFactory_invalidDestinationKind);
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:ReorgPolicyFactory.java

示例9: createFrom

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private static RefactoringStatus createFrom(IStatus status) {
  if (status.isOK()) return new RefactoringStatus();

  if (!status.isMultiStatus()) {
    switch (status.getSeverity()) {
      case IStatus.OK:
        return new RefactoringStatus();
      case IStatus.INFO:
        return RefactoringStatus.createInfoStatus(status.getMessage());
      case IStatus.WARNING:
        return RefactoringStatus.createWarningStatus(status.getMessage());
      case IStatus.ERROR:
        return RefactoringStatus.createErrorStatus(status.getMessage());
      case IStatus.CANCEL:
        return RefactoringStatus.createFatalErrorStatus(status.getMessage());
      default:
        return RefactoringStatus.createFatalErrorStatus(status.getMessage());
    }
  } else {
    IStatus[] children = status.getChildren();
    RefactoringStatus result = new RefactoringStatus();
    for (int i = 0; i < children.length; i++) {
      result.merge(createFrom(children[i]));
    }
    return result;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:ResourceChangeChecker.java

示例10: checkAnnotations

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkAnnotations(IAnnotatable source, IType sourceType, IAnnotatable target,
		IType targetType) throws JavaModelException {
	// a set of annotations from the source method.
	Set<IAnnotation> sourceAnnotationSet = new HashSet<>(Arrays.asList(source.getAnnotations()));

	// remove any annotations to not consider.
	removeSpecialAnnotations(sourceAnnotationSet, sourceType);

	// a set of source method annotation names.
	Set<String> sourceMethodAnnotationElementNames = getAnnotationElementNames(sourceAnnotationSet);

	// a set of annotations from the target method.
	Set<IAnnotation> targetAnnotationSet = new HashSet<>(Arrays.asList(target.getAnnotations()));

	// remove any annotations to not consider.
	removeSpecialAnnotations(targetAnnotationSet, targetType);

	// a set of target method annotation names.
	Set<String> targetAnnotationElementNames = getAnnotationElementNames(targetAnnotationSet);

	// if the source method annotation names don't match the target method
	// annotation names.
	if (!sourceMethodAnnotationElementNames.equals(targetAnnotationElementNames))
		return RefactoringStatus.createErrorStatus(PreconditionFailure.AnnotationNameMismatch.getMessage(),
				new RefactoringStatusContext() {

					@Override
					public Object getCorrespondingElement() {
						return source;
					}
				});
	else
		// otherwise, we have the same annotations names. Check the values.
		for (IAnnotation sourceAnnotation : sourceAnnotationSet) {
			IMemberValuePair[] sourcePairs = sourceAnnotation.getMemberValuePairs();

			IAnnotation targetAnnotation = target.getAnnotation(sourceAnnotation.getElementName());
			IMemberValuePair[] targetPairs = targetAnnotation.getMemberValuePairs();

			if (sourcePairs.length != targetPairs.length) {
				// TODO: Can perhaps analyze this situation further by
				// looking up default field values.
				logWarning(
						"There may be differences in the length of the value vectors as some annotations may use default field values.");
				return new RefactoringStatus();
			}

			Arrays.parallelSort(sourcePairs, Comparator.comparing(IMemberValuePair::getMemberName));
			Arrays.parallelSort(targetPairs, Comparator.comparing(IMemberValuePair::getMemberName));

			for (int i = 0; i < sourcePairs.length; i++)
				if (!sourcePairs[i].getMemberName().equals(targetPairs[i].getMemberName())
						|| sourcePairs[i].getValueKind() != targetPairs[i].getValueKind()
						|| !(sourcePairs[i].getValue().equals(targetPairs[i].getValue())))
					return RefactoringStatus.createErrorStatus(
							formatMessage(PreconditionFailure.AnnotationValueMismatch.getMessage(),
									sourceAnnotation, targetAnnotation),
							JavaStatusContext.create(findEnclosingMember(sourceAnnotation)));
		}
	return new RefactoringStatus(); // OK.
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:62,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java

示例11: setIntermediaryTypeName

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
/**
 * @param fullyQualifiedTypeName the fully qualified name of the intermediary method
 * @return status for type name. Use {@link #setIntermediaryMethodName(String)} to check for
 *     overridden methods.
 */
public RefactoringStatus setIntermediaryTypeName(String fullyQualifiedTypeName) {
  IType target = null;

  try {
    if (fullyQualifiedTypeName.length() == 0)
      return RefactoringStatus.createFatalErrorStatus(
          RefactoringCoreMessages.IntroduceIndirectionRefactoring_type_not_selected_error);

    // find type (now including secondaries)
    target = getProject().findType(fullyQualifiedTypeName, new NullProgressMonitor());
    if (target == null || !target.exists())
      return RefactoringStatus.createErrorStatus(
          Messages.format(
              RefactoringCoreMessages.IntroduceIndirectionRefactoring_type_does_not_exist_error,
              BasicElementLabels.getJavaElementName(fullyQualifiedTypeName)));
    if (target.isAnnotation())
      return RefactoringStatus.createErrorStatus(
          RefactoringCoreMessages.IntroduceIndirectionRefactoring_cannot_create_in_annotation);
    if (target.isInterface()
        && !(JavaModelUtil.is18OrHigher(target.getJavaProject())
            && JavaModelUtil.is18OrHigher(getProject())))
      return RefactoringStatus.createErrorStatus(
          RefactoringCoreMessages.IntroduceIndirectionRefactoring_cannot_create_on_interface);
  } catch (JavaModelException e) {
    return RefactoringStatus.createFatalErrorStatus(
        RefactoringCoreMessages.IntroduceIndirectionRefactoring_unable_determine_declaring_type);
  }

  if (target.isReadOnly())
    return RefactoringStatus.createErrorStatus(
        RefactoringCoreMessages.IntroduceIndirectionRefactoring_cannot_create_in_readonly);

  if (target.isBinary())
    return RefactoringStatus.createErrorStatus(
        RefactoringCoreMessages.IntroduceIndirectionRefactoring_cannot_create_in_binary);

  fIntermediaryType = target;

  return new RefactoringStatus();
}
 
开发者ID:eclipse,项目名称:che,代码行数:46,代码来源:IntroduceIndirectionRefactoring.java

示例12: adjustVisibility

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus adjustVisibility(
    IMember whoToAdjust,
    ModifierKeyword neededVisibility,
    boolean alsoIncreaseEnclosing,
    IProgressMonitor monitor)
    throws CoreException {

  Map<IMember, IncomingMemberVisibilityAdjustment> adjustments;
  if (isRewriteKept(whoToAdjust.getCompilationUnit())) adjustments = fIntermediaryAdjustments;
  else adjustments = new HashMap<IMember, IncomingMemberVisibilityAdjustment>();

  int existingAdjustments = adjustments.size();
  addAdjustment(whoToAdjust, neededVisibility, adjustments);

  if (alsoIncreaseEnclosing)
    while (whoToAdjust.getDeclaringType() != null) {
      whoToAdjust = whoToAdjust.getDeclaringType();
      addAdjustment(whoToAdjust, neededVisibility, adjustments);
    }

  boolean hasNewAdjustments = (adjustments.size() - existingAdjustments) > 0;
  if (hasNewAdjustments && ((whoToAdjust.isReadOnly() || whoToAdjust.isBinary())))
    return RefactoringStatus.createErrorStatus(
        Messages.format(
            RefactoringCoreMessages
                .IntroduceIndirectionRefactoring_cannot_update_binary_target_visibility,
            new String[] {
              JavaElementLabels.getElementLabel(whoToAdjust, JavaElementLabels.ALL_DEFAULT)
            }),
        JavaStatusContext.create(whoToAdjust));

  RefactoringStatus status = new RefactoringStatus();

  // Don't create a rewrite if it is not necessary
  if (!hasNewAdjustments) return status;

  try {
    monitor.beginTask(RefactoringCoreMessages.MemberVisibilityAdjustor_adjusting, 2);
    Map<ICompilationUnit, CompilationUnitRewrite> rewrites;
    if (!isRewriteKept(whoToAdjust.getCompilationUnit())) {
      CompilationUnitRewrite rewrite =
          new CompilationUnitRewrite(whoToAdjust.getCompilationUnit());
      rewrite.setResolveBindings(false);
      rewrites = new HashMap<ICompilationUnit, CompilationUnitRewrite>();
      rewrites.put(whoToAdjust.getCompilationUnit(), rewrite);
      status.merge(
          rewriteVisibility(
              adjustments,
              rewrites,
              new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)));
      rewrite.attachChange(
          (CompilationUnitChange) fTextChangeManager.get(whoToAdjust.getCompilationUnit()),
          true,
          new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
    }
  } finally {
    monitor.done();
  }
  return status;
}
 
开发者ID:eclipse,项目名称:che,代码行数:61,代码来源:IntroduceIndirectionRefactoring.java

示例13: resolveBindings

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private ITypeBinding[] resolveBindings(
    String[] types, RefactoringStatus[] results, boolean firstPass) throws CoreException {
  // TODO: split types into parameterTypes and returnType
  int parameterCount = types.length - 1;
  ITypeBinding[] typeBindings = new ITypeBinding[types.length];

  StringBuffer cuString = new StringBuffer();
  cuString.append(fStubTypeContext.getBeforeString());
  int offsetBeforeMethodName = appendMethodDeclaration(cuString, types, parameterCount);
  cuString.append(fStubTypeContext.getAfterString());

  // need a working copy to tell the parser where to resolve (package visible) types
  ICompilationUnit wc =
      fMethod
          .getCompilationUnit()
          .getWorkingCopy(
              new WorkingCopyOwner() {
                /*subclass*/
              },
              new NullProgressMonitor());
  try {
    wc.getBuffer().setContents(cuString.toString());
    CompilationUnit compilationUnit =
        new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(wc, true);
    ASTNode method =
        NodeFinder.perform(compilationUnit, offsetBeforeMethodName, METHOD_NAME.length())
            .getParent();
    Type[] typeNodes = new Type[types.length];
    if (method instanceof MethodDeclaration) {
      MethodDeclaration methodDeclaration = (MethodDeclaration) method;
      typeNodes[parameterCount] = methodDeclaration.getReturnType2();
      List<SingleVariableDeclaration> parameters = methodDeclaration.parameters();
      for (int i = 0; i < parameterCount; i++) typeNodes[i] = parameters.get(i).getType();

    } else if (method instanceof AnnotationTypeMemberDeclaration) {
      typeNodes[0] = ((AnnotationTypeMemberDeclaration) method).getType();
    }

    for (int i = 0; i < types.length; i++) {
      Type type = typeNodes[i];
      if (type == null) {
        String msg =
            Messages.format(
                RefactoringCoreMessages.TypeContextChecker_couldNotResolveType,
                BasicElementLabels.getJavaElementName(types[i]));
        results[i] = RefactoringStatus.createErrorStatus(msg);
        continue;
      }
      results[i] = new RefactoringStatus();
      IProblem[] problems = ASTNodes.getProblems(type, ASTNodes.NODE_ONLY, ASTNodes.PROBLEMS);
      if (problems.length > 0) {
        for (int p = 0; p < problems.length; p++)
          if (isError(problems[p], type)) results[i].addError(problems[p].getMessage());
      }
      ITypeBinding binding = handleBug84585(type.resolveBinding());
      if (firstPass && (binding == null || binding.isRecovered())) {
        types[i] = qualifyTypes(type, results[i]);
      }
      typeBindings[i] = binding;
    }
    return typeBindings;
  } finally {
    wc.discardWorkingCopy();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:66,代码来源:TypeContextChecker.java


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