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


Java RefactoringStatus类代码示例

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


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

示例1: checkName

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
/**
 * Returns a fatal error in case the name is empty. In all other cases, an
 * error based on the given status is returned.
 *
 * @param name
 *            a name
 * @param status
 *            a status
 * @return RefactoringStatus based on the given status or the name, if
 *         empty.
 */
public static RefactoringStatus checkName(String name, IStatus status) {
	RefactoringStatus result = new RefactoringStatus();
	if ("".equals(name)) {
		return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.Checks_Choose_name);
	}

	if (status.isOK()) {
		return result;
	}

	switch (status.getSeverity()) {
		case IStatus.ERROR:
			return RefactoringStatus.createFatalErrorStatus(status.getMessage());
		case IStatus.WARNING:
			return RefactoringStatus.createWarningStatus(status.getMessage());
		case IStatus.INFO:
			return RefactoringStatus.createInfoStatus(status.getMessage());
		default: //no nothing
			return new RefactoringStatus();
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:33,代码来源:Checks.java

示例2: checkParameterNames

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
/**
 * Checks if the parameter names are valid.
 *
 * @return validation status
 */
public RefactoringStatus checkParameterNames() {
	RefactoringStatus result = new RefactoringStatus();
	for (Iterator<ParameterInfo> iter = fParameterInfos.iterator(); iter.hasNext();) {
		ParameterInfo parameter = iter.next();
		result.merge(Checks.checkIdentifier(parameter.getNewName(), fCUnit));
		for (Iterator<ParameterInfo> others = fParameterInfos.iterator(); others.hasNext();) {
			ParameterInfo other = others.next();
			if (parameter != other && other.getNewName().equals(parameter.getNewName())) {
				result.addError(Messages.format(RefactoringCoreMessages.ExtractMethodRefactoring_error_sameParameter, BasicElementLabels.getJavaElementName(other.getNewName())));
				return result;
			}
		}
		if (parameter.isRenamed() && fUsedNames.contains(parameter.getNewName())) {
			result.addError(Messages.format(RefactoringCoreMessages.ExtractMethodRefactoring_error_nameInUse, BasicElementLabels.getJavaElementName(parameter.getNewName())));
			return result;
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:25,代码来源:ExtractMethodRefactoring.java

示例3: checkFinalConditions

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException {
	pm.beginTask(RefactoringCoreMessages.ExtractMethodRefactoring_checking_new_name, 2);
	pm.subTask(EMPTY);

	RefactoringStatus result = checkMethodName();
	result.merge(checkParameterNames());
	result.merge(checkVarargOrder());
	pm.worked(1);
	if (pm.isCanceled()) {
		throw new OperationCanceledException();
	}

	BodyDeclaration node = fAnalyzer.getEnclosingBodyDeclaration();
	if (node != null) {
		fAnalyzer.checkInput(result, fMethodName, fDestination);
		pm.worked(1);
	}
	pm.done();
	return result;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:ExtractMethodRefactoring.java

示例4: initialize

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
public RefactoringStatus initialize(ASTNode invocation, int severity) {
  RefactoringStatus result = new RefactoringStatus();
  fInvocation = invocation;
  fLocals = new ArrayList<VariableDeclarationStatement>(3);

  checkMethodDeclaration(result, severity);
  if (result.getSeverity() >= severity) return result;

  initializeRewriteState();
  initializeTargetNode();
  flowAnalysis();

  fContext =
      new CallContext(fInvocation, fInvocationScope, fTargetNode.getNodeType(), fImportRewrite);

  try {
    computeRealArguments();
    computeReceiver();
  } catch (BadLocationException exception) {
    JavaPlugin.log(exception);
  }
  checkInvocationContext(result, severity);

  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:CallInliner.java

示例5: checkTempTypeForLocalTypeUsage

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
private RefactoringStatus checkTempTypeForLocalTypeUsage() {
  VariableDeclarationStatement vds = getTempDeclarationStatement();
  if (vds == null)
    return RefactoringStatus.createFatalErrorStatus(
        RefactoringCoreMessages.PromoteTempToFieldRefactoring_cannot_promote);
  Type type = vds.getType();
  ITypeBinding binding = type.resolveBinding();
  if (binding == null)
    return RefactoringStatus.createFatalErrorStatus(
        RefactoringCoreMessages.PromoteTempToFieldRefactoring_cannot_promote);

  IMethodBinding declaringMethodBinding = getMethodDeclaration().resolveBinding();
  ITypeBinding[] methodTypeParameters =
      declaringMethodBinding == null
          ? new ITypeBinding[0]
          : declaringMethodBinding.getTypeParameters();
  LocalTypeAndVariableUsageAnalyzer analyzer =
      new LocalTypeAndVariableUsageAnalyzer(methodTypeParameters);
  type.accept(analyzer);
  boolean usesLocalTypes = !analyzer.getUsageOfEnclosingNodes().isEmpty();
  fTempTypeUsesClassTypeVariables = analyzer.getClassTypeVariablesUsed();
  if (usesLocalTypes)
    return RefactoringStatus.createFatalErrorStatus(
        RefactoringCoreMessages.PromoteTempToFieldRefactoring_uses_type_declared_locally);
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:PromoteTempToFieldRefactoring.java

示例6: loadCopyParticipants

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
/**
 * Loads the copy participants for the given element.
 *
 * @param status a refactoring status to report status if problems occurred while loading the
 *     participants
 * @param processor the processor that will own the participants
 * @param element the element to be copied or a corresponding descriptor
 * @param arguments the copy arguments describing the copy operation
 * @param filter a participant filter to exclude certain participants, or <code>null</code> if no
 *     filtering is desired
 * @param affectedNatures an array of project natures affected by the refactoring
 * @param shared a list of shared participants
 * @return an array of copy participants
 * @since 3.2
 */
public static CopyParticipant[] loadCopyParticipants(
    RefactoringStatus status,
    RefactoringProcessor processor,
    Object element,
    CopyArguments arguments,
    IParticipantDescriptorFilter filter,
    String affectedNatures[],
    SharableParticipants shared) {
  RefactoringParticipant[] participants =
      fgCopyInstance.getParticipants(
          status, processor, element, arguments, filter, affectedNatures, shared);
  CopyParticipant[] result = new CopyParticipant[participants.length];
  System.arraycopy(participants, 0, result, 0, participants.length);
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:ParticipantManager.java

示例7: checkOverridden

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm)
    throws JavaModelException {
  pm.beginTask("", 9); // $NON-NLS-1$
  pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden);
  MethodDeclaration decl = fSourceProvider.getDeclaration();
  IMethod method = (IMethod) decl.resolveBinding().getJavaElement();
  if (method == null || Flags.isPrivate(method.getFlags())) {
    pm.worked(8);
    return;
  }
  IType type = method.getDeclaringType();
  ITypeHierarchy hierarchy = type.newTypeHierarchy(new SubProgressMonitor(pm, 6));
  checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1));
  checkSuperClasses(
      status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1));
  checkSuperInterfaces(
      status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1));
  pm.setTaskName(""); // $NON-NLS-1$
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:InlineMethodRefactoring.java

示例8: helperPass

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
private void helperPass(ICompilationUnit cu, IMethod[] methods, boolean testCompilation)
		throws JavaModelException, CoreException, Exception, IOException {
	Refactoring refactoring = getRefactoring(methods);

	RefactoringStatus initialStatus = refactoring.checkInitialConditions(new NullProgressMonitor());
	getLogger().info("Initial status: " + initialStatus);

	RefactoringStatus finalStatus = refactoring.checkFinalConditions(new NullProgressMonitor());
	getLogger().info("Final status: " + finalStatus);

	assertTrue("Precondition was supposed to pass.", initialStatus.isOK() && finalStatus.isOK());
	performChange(refactoring, false);

	String outputTestFileName = getOutputTestFileName("A");
	String actual = cu.getSource();

	if (testCompilation)
		assertTrue("Actual output should compile.", compiles(actual));

	if (this.replaceExpectedWithActual)
		setFileContents(outputTestFileName, actual);

	String expected = getFileContents(outputTestFileName);
	assertEqualLines(expected, actual);
}
 
开发者ID:ponder-lab,项目名称:Common-Eclipse-Java-Refactoring-Framework,代码行数:26,代码来源:RefactoringTest.java

示例9: validateNewElementName

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
/**
 * Validates if the a name is valid. This method does not change the name settings on the
 * refactoring. It is intended to be used in a wizard to validate user input.
 *
 * @param newName the name to validate
 * @return returns the resulting status of the validation
 */
public RefactoringStatus validateNewElementName(String newName) {
  Assert.isNotNull(newName, "new name"); // $NON-NLS-1$
  IContainer c = fResource.getParent();
  if (c == null)
    return RefactoringStatus.createFatalErrorStatus(
        RefactoringCoreMessages.RenameResourceProcessor_error_no_parent);

  if (!c.getFullPath().isValidSegment(newName))
    return RefactoringStatus.createFatalErrorStatus(
        RefactoringCoreMessages.RenameResourceProcessor_error_invalid_name);

  if (c.findMember(newName) != null)
    return RefactoringStatus.createFatalErrorStatus(
        RefactoringCoreMessages.RenameResourceProcessor_error_resource_already_exists);

  RefactoringStatus result =
      RefactoringStatus.create(c.getWorkspace().validateName(newName, fResource.getType()));
  if (!result.hasFatalError())
    result.merge(
        RefactoringStatus.create(
            c.getWorkspace().validatePath(createNewPath(newName), fResource.getType())));
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:RenameResourceProcessor.java

示例10: checkPreConditions

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public RefactoringStatus checkPreConditions(
    IJavaProject project, ICompilationUnit[] compilationUnits, IProgressMonitor monitor)
    throws CoreException {
  RefactoringStatus superStatus = super.checkPreConditions(project, compilationUnits, monitor);
  if (superStatus.hasFatalError()) return superStatus;

  return PotentialProgrammingProblemsFix.checkPreConditions(
      project,
      compilationUnits,
      monitor,
      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),
      false);
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:PotentialProgrammingProblemsCleanUp.java

示例11: checkExceptions

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
/**
 * #44: Ensure that exception types between the source and target methods
 * match.
 *
 * @param sourceMethod
 *            The source method.
 * @return The corresponding {@link RefactoringStatus}.
 * @throws JavaModelException
 *             If there is trouble retrieving exception types from
 *             sourceMethod.
 */
private RefactoringStatus checkExceptions(IMethod sourceMethod) throws JavaModelException {
	RefactoringStatus status = new RefactoringStatus();

	IMethod targetMethod = getTargetMethod(sourceMethod, Optional.empty());

	if (targetMethod != null) {
		Set<String> sourceMethodExceptionTypeSet = getExceptionTypeSet(sourceMethod);
		Set<String> targetMethodExceptionTypeSet = getExceptionTypeSet(targetMethod);

		if (!sourceMethodExceptionTypeSet.equals(targetMethodExceptionTypeSet)) {
			RefactoringStatusEntry entry = addError(status, sourceMethod, PreconditionFailure.ExceptionTypeMismatch,
					sourceMethod, targetMethod);
			addUnmigratableMethod(sourceMethod, entry);
		}
	}

	return status;
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:30,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java

示例12: checkMethodDeclaration

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
private void checkMethodDeclaration(RefactoringStatus result, int severity) {
  MethodDeclaration methodDeclaration = fSourceProvider.getDeclaration();
  // it is not allowed to inline constructor invocation only if it is used for class instance
  // creation
  // if constructor is invoked from another constructor then we can inline such invocation
  if (fInvocation.getNodeType() != ASTNode.CONSTRUCTOR_INVOCATION
      && methodDeclaration.isConstructor()) {
    result.addEntry(
        new RefactoringStatusEntry(
            severity,
            RefactoringCoreMessages.CallInliner_constructors,
            JavaStatusContext.create(fCUnit, fInvocation)));
  }
  if (fSourceProvider.hasSuperMethodInvocation()
      && fInvocation.getNodeType() == ASTNode.METHOD_INVOCATION) {
    Expression receiver = ((MethodInvocation) fInvocation).getExpression();
    if (receiver instanceof ThisExpression) {
      result.addEntry(
          new RefactoringStatusEntry(
              severity,
              RefactoringCoreMessages.CallInliner_super_into_this_expression,
              JavaStatusContext.create(fCUnit, fInvocation)));
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:CallInliner.java

示例13: checkValidClassesInDeclaringTypeHierarchy

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
private RefactoringStatus checkValidClassesInDeclaringTypeHierarchy(IMethod sourceMethod,
		final ITypeHierarchy declaringTypeHierarchy) throws JavaModelException {
	RefactoringStatus status = new RefactoringStatus();

	IType[] allDeclaringTypeSuperclasses = declaringTypeHierarchy
			.getAllSuperclasses(sourceMethod.getDeclaringType());

	// is the source method overriding anything in the declaring type
	// hierarchy? If so, don't allow the refactoring to proceed #107.
	if (Stream.of(allDeclaringTypeSuperclasses).parallel().anyMatch(c -> {
		IMethod[] methods = c.findMethods(sourceMethod);
		return methods != null && methods.length > 0;
	}))
		addErrorAndMark(status, PreconditionFailure.SourceMethodOverridesMethod, sourceMethod);

	return status;
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:18,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java

示例14: check

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
/**
 * Checks the condition of all registered condition checkers and returns a merge status result.
 *
 * @param pm a progress monitor or <code>null</code> if no progress reporting is desired
 * @return the combined status result
 * @throws CoreException if an error occurs during condition checking
 */
public RefactoringStatus check(IProgressMonitor pm) throws CoreException {
  if (pm == null) pm = new NullProgressMonitor();
  RefactoringStatus result = new RefactoringStatus();
  mergeResourceOperationAndValidateEdit();
  List values = new ArrayList(fCheckers.values());
  Collections.sort(
      values,
      new Comparator() {
        public int compare(Object o1, Object o2) {
          // Note there can only be one ResourceOperationChecker. So it
          // is save to not test the case that both objects are
          // ResourceOperationChecker
          if (o1 instanceof ResourceChangeChecker) return -1;
          if (o2 instanceof ResourceChangeChecker) return 1;
          return 0;
        }
      });
  pm.beginTask("", values.size()); // $NON-NLS-1$
  for (Iterator iter = values.iterator(); iter.hasNext(); ) {
    IConditionChecker checker = (IConditionChecker) iter.next();
    result.merge(checker.check(new SubProgressMonitor(pm, 1)));
    if (pm.isCanceled()) throw new OperationCanceledException();
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:CheckConditionsContext.java

示例15: checkIfOverridesAnother

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入依赖的package包/类
public static RefactoringStatus checkIfOverridesAnother(IMethod method, ITypeHierarchy hierarchy)
    throws JavaModelException {
  IMethod overrides = MethodChecks.overridesAnotherMethod(method, hierarchy);
  if (overrides == null) return null;

  RefactoringStatusContext context = JavaStatusContext.create(overrides);
  String message =
      Messages.format(
          RefactoringCoreMessages.MethodChecks_overrides,
          new String[] {
            JavaElementUtil.createMethodSignature(overrides),
            JavaElementLabels.getElementLabel(
                overrides.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)
          });
  return RefactoringStatus.createStatus(
      RefactoringStatus.FATAL,
      message,
      context,
      Corext.getPluginId(),
      RefactoringStatusCodes.OVERRIDES_ANOTHER_METHOD,
      overrides);
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:MethodChecks.java


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