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


Java RefactoringStatus.addError方法代码示例

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


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

示例1: 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

示例2: checkFinalConditions

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context)
		throws CoreException, OperationCanceledException {
	RefactoringStatus status = new RefactoringStatus();
	// Consume "rename" tsserver command.
	try {
		rename = tsFile.rename(offset, isFindInComments(), isFindInStrings()).get(1000, TimeUnit.MILLISECONDS);
		RenameInfo info = rename.getInfo();
		if (!info.isCanRename()) {
			// Refactoring cannot be done.
			status.addError(info.getLocalizedErrorMessage());
		}
	} catch (Exception e) {
		status.addError(e.getMessage());
	}
	return status;
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:18,代码来源:TypeScriptRenameProcessor.java

示例3: checkParameterNamesInRippleMethods

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkParameterNamesInRippleMethods() throws JavaModelException {
  RefactoringStatus result = new RefactoringStatus();
  Set<String> newParameterNames = getNewParameterNamesList();
  for (int i = 0; i < fRippleMethods.length; i++) {
    String[] paramNames = fRippleMethods[i].getParameterNames();
    for (int j = 0; j < paramNames.length; j++) {
      if (newParameterNames.contains(paramNames[j])) {
        String[] args =
            new String[] {
              JavaElementUtil.createMethodSignature(fRippleMethods[i]),
              BasicElementLabels.getJavaElementName(paramNames[j])
            };
        String msg =
            Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_already_has, args);
        RefactoringStatusContext context =
            JavaStatusContext.create(
                fRippleMethods[i].getCompilationUnit(), fRippleMethods[i].getNameRange());
        result.addError(msg, context);
      }
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:ChangeSignatureProcessor.java

示例4: checkInitialConditions

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
  if (!fMethod.exists()) {
    String message =
        Messages.format(
            RefactoringCoreMessages.RenameMethodRefactoring_deleted,
            BasicElementLabels.getFileName(fMethod.getCompilationUnit()));
    return RefactoringStatus.createFatalErrorStatus(message);
  }

  RefactoringStatus result = Checks.checkAvailability(fMethod);
  if (result.hasFatalError()) return result;
  result.merge(Checks.checkIfCuBroken(fMethod));
  if (JdtFlags.isNative(fMethod))
    result.addError(RefactoringCoreMessages.RenameMethodRefactoring_no_native);
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:RenameMethodProcessor.java

示例5: checkTypesInCompilationUnit

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:RenameTypeProcessor.java

示例6: addReferenceShadowedError

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private static void addReferenceShadowedError(
    ICompilationUnit cu, SearchMatch newMatch, String newElementName, RefactoringStatus result) {
  // Found a new match with no corresponding old match.
  // -> The new match is a reference which was pointing to another element,
  // but that other element has been shadowed

  // TODO: should not have to filter declarations:
  if (newMatch instanceof MethodDeclarationMatch || newMatch instanceof FieldDeclarationMatch)
    return;
  ISourceRange range = getOldSourceRange(newMatch);
  RefactoringStatusContext context = JavaStatusContext.create(cu, range);
  String message =
      Messages.format(
          RefactoringCoreMessages.RenameAnalyzeUtil_reference_shadowed,
          new String[] {
            BasicElementLabels.getFileName(cu),
            BasicElementLabels.getJavaElementName(newElementName)
          });
  result.addError(message, context);
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:RenameAnalyzeUtil.java

示例7: checkTypeNameConflicts

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkTypeNameConflicts(
    ICompilationUnit iCompilationUnit, Set<String> topLevelTypeNames) throws CoreException {
  RefactoringStatus result = new RefactoringStatus();
  IType[] types = iCompilationUnit.getTypes();

  for (int i = 0; i < types.length; i++) {
    String name = types[i].getElementName();
    if (topLevelTypeNames.contains(name)) {
      String[] keys = {getElementLabel(iCompilationUnit.getParent()), getElementLabel(types[i])};
      String msg =
          Messages.format(RefactoringCoreMessages.RenamePackageRefactoring_contains_type, keys);
      RefactoringStatusContext context = JavaStatusContext.create(types[i]);
      result.addError(msg, context);
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:RenamePackageProcessor.java

示例8: checkMethodInType

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
/**
 * Checks if the new method is already used in the given type.
 *
 * @param type
 * @param methodName
 * @param parameters
 * @return the status
 */
public static RefactoringStatus checkMethodInType(
    ITypeBinding type, String methodName, ITypeBinding[] parameters) {
  RefactoringStatus result = new RefactoringStatus();
  IMethodBinding method =
      org.eclipse.jdt.internal.corext.dom.Bindings.findMethodInType(type, methodName, parameters);
  if (method != null) {
    if (method.isConstructor()) {
      result.addWarning(
          Messages.format(
              RefactoringCoreMessages.Checks_methodName_constructor,
              new Object[] {BasicElementLabels.getJavaElementName(type.getName())}));
    } else {
      result.addError(
          Messages.format(
              RefactoringCoreMessages.Checks_methodName_exists,
              new Object[] {
                BasicElementLabels.getJavaElementName(methodName),
                BasicElementLabels.getJavaElementName(type.getName())
              }),
          JavaStatusContext.create(method));
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:Checks.java

示例9: checkMethodInType

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
/**
 * Checks if the new method is already used in the given type.
 *
 * @param type
 * @param methodName
 * @param parameters
 * @return the status
 */
public static RefactoringStatus checkMethodInType(ITypeBinding type, String methodName, ITypeBinding[] parameters) {
	RefactoringStatus result = new RefactoringStatus();
	IMethodBinding method = org.eclipse.jdt.internal.corext.dom.Bindings.findMethodInType(type, methodName, parameters);
	if (method != null) {
		if (method.isConstructor()) {
			result.addWarning(Messages.format(RefactoringCoreMessages.Checks_methodName_constructor, new Object[] { BasicElementLabels.getJavaElementName(type.getName()) }));
		} else {
			result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_exists, new Object[] { BasicElementLabels.getJavaElementName(methodName), BasicElementLabels.getJavaElementName(type.getName()) }),
					JavaStatusContext.create(method));
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:Checks.java

示例10: checkMethodInHierarchy

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
/**
 * Checks if the new method somehow conflicts with an already existing
 * method in the hierarchy. The following checks are done:
 * <ul>
 * <li>if the new method overrides a method defined in the given type or in
 * one of its super classes.</li>
 * </ul>
 *
 * @param type
 * @param methodName
 * @param returnType
 * @param parameters
 * @return the status
 */
public static RefactoringStatus checkMethodInHierarchy(ITypeBinding type, String methodName, ITypeBinding returnType, ITypeBinding[] parameters) {
	RefactoringStatus result = new RefactoringStatus();
	IMethodBinding method = Bindings.findMethodInHierarchy(type, methodName, parameters);
	if (method != null) {
		boolean returnTypeClash = false;
		ITypeBinding methodReturnType = method.getReturnType();
		if (returnType != null && methodReturnType != null) {
			String returnTypeKey = returnType.getKey();
			String methodReturnTypeKey = methodReturnType.getKey();
			if (returnTypeKey == null && methodReturnTypeKey == null) {
				returnTypeClash = returnType != methodReturnType;
			} else if (returnTypeKey != null && methodReturnTypeKey != null) {
				returnTypeClash = !returnTypeKey.equals(methodReturnTypeKey);
			}
		}
		ITypeBinding dc = method.getDeclaringClass();
		if (returnTypeClash) {
			result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_returnTypeClash, new Object[] { BasicElementLabels.getJavaElementName(methodName), BasicElementLabels.getJavaElementName(dc.getName()) }),
					JavaStatusContext.create(method));
		} else {
			if (method.isConstructor()) {
				result.addWarning(Messages.format(RefactoringCoreMessages.Checks_methodName_constructor, new Object[] { BasicElementLabels.getJavaElementName(dc.getName()) }));
			} else {
				result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_overrides, new Object[] { BasicElementLabels.getJavaElementName(methodName), BasicElementLabels.getJavaElementName(dc.getName()) }),
						JavaStatusContext.create(method));
			}
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:45,代码来源:Checks.java

示例11: analyzeSelection

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus analyzeSelection(RefactoringStatus status) {
	fInputFlowContext = new FlowContext(0, fMaxVariableId + 1);
	fInputFlowContext.setConsiderAccessMode(true);
	fInputFlowContext.setComputeMode(FlowContext.ARGUMENTS);

	InOutFlowAnalyzer flowAnalyzer = new InOutFlowAnalyzer(fInputFlowContext);
	fInputFlowInfo = flowAnalyzer.perform(getSelectedNodes());

	if (fInputFlowInfo.branches()) {
		String canHandleBranchesProblem = canHandleBranches();
		if (canHandleBranchesProblem != null) {
			status.addFatalError(canHandleBranchesProblem, JavaStatusContext.create(fCUnit, getSelection()));
			fReturnKind = ERROR;
			return status;
		}
	}
	if (fInputFlowInfo.isValueReturn()) {
		fReturnKind = RETURN_STATEMENT_VALUE;
	} else if (fInputFlowInfo.isVoidReturn() || (fInputFlowInfo.isPartialReturn() && isVoidMethod() && isLastStatementSelected())) {
		fReturnKind = RETURN_STATEMENT_VOID;
	} else if (fInputFlowInfo.isNoReturn() || fInputFlowInfo.isThrow() || fInputFlowInfo.isUndefined()) {
		fReturnKind = NO;
	}

	if (fReturnKind == UNDEFINED) {
		status.addError(RefactoringCoreMessages.FlowAnalyzer_execution_flow, JavaStatusContext.create(fCUnit, getSelection()));
		fReturnKind = NO;
	}
	computeInput();
	computeExceptions();
	computeOutput(status);
	if (status.hasFatalError()) {
		return status;
	}

	adjustArgumentsAndMethodLocals();
	compressArrays();
	return status;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:40,代码来源:ExtractMethodAnalyzer.java

示例12: checkTypes

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
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]));
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:ReplaceInvocationsRefactoring.java

示例13: checkTypes

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
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, JavaElementLabels.getElementLabel(types[i], JavaElementLabels.ALL_DEFAULT)),
          JavaStatusContext.create(overridden[0]));
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:InlineMethodRefactoring.java

示例14: logMalfunctioningParticipant

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private void logMalfunctioningParticipant(
    RefactoringStatus status, ParticipantDescriptor descriptor, Throwable e) {
  status.addError(
      Messages.format(
          RefactoringCoreMessages.ParticipantExtensionPoint_participant_removed,
          descriptor.getName()));
  RefactoringCorePlugin.logRemovedParticipant(descriptor, e);
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:ParticipantExtensionPoint.java

示例15: reportProblemNodes

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:RefactoringAnalyzeUtil.java


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