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


Java RefactoringStatus.addWarning方法代码示例

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


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

示例1: checkNewElementName

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
public RefactoringStatus checkNewElementName(String newName) throws JavaModelException {
  RefactoringStatus result = Checks.checkFieldName(newName, fCu);
  if (!Checks.startsWithLowerCase(newName))
    if (fIsComposite) {
      final String nameOfParent =
          JavaElementLabels.getElementLabel(
              fLocalVariable.getParent(), JavaElementLabels.ALL_DEFAULT);
      final String nameOfType =
          JavaElementLabels.getElementLabel(
              fLocalVariable.getAncestor(IJavaElement.TYPE), JavaElementLabels.ALL_DEFAULT);
      result.addWarning(
          Messages.format(
              RefactoringCoreMessages.RenameTempRefactoring_lowercase2,
              new String[] {
                BasicElementLabels.getJavaElementName(newName), nameOfParent, nameOfType
              }));
    } else {
      result.addWarning(RefactoringCoreMessages.RenameTempRefactoring_lowercase);
    }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:RenameLocalVariableProcessor.java

示例2: checkNestedHierarchy

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkNestedHierarchy(IType type) throws CoreException {
  IType[] nestedTypes = type.getTypes();
  if (nestedTypes == null) return null;
  RefactoringStatus result = new RefactoringStatus();
  for (int i = 0; i < nestedTypes.length; i++) {
    IField otherField = nestedTypes[i].getField(getNewElementName());
    if (otherField.exists()) {
      String msg =
          Messages.format(
              RefactoringCoreMessages.RenameFieldRefactoring_hiding,
              new String[] {
                BasicElementLabels.getJavaElementName(fField.getElementName()),
                BasicElementLabels.getJavaElementName(getNewElementName()),
                BasicElementLabels.getJavaElementName(nestedTypes[i].getFullyQualifiedName('.'))
              });
      result.addWarning(msg, JavaStatusContext.create(otherField));
    }
    result.merge(checkNestedHierarchy(nestedTypes[i]));
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:RenameFieldProcessor.java

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

示例4: checkDirtyFile

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private void checkDirtyFile(RefactoringStatus result, IFile file) {
  if (!file.exists()) return;
  ITextFileBuffer buffer =
      FileBuffers.getTextFileBufferManager()
          .getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
  if (buffer != null && buffer.isDirty()) {
    String message = RefactoringCoreMessages.DeleteResourcesProcessor_warning_unsaved_file;
    if (buffer.isStateValidated() && buffer.isSynchronized()) {
      result.addWarning(
          Messages.format(message, BasicElementLabels.getPathLabel(file.getFullPath(), false)));
    } else {
      result.addFatalError(
          Messages.format(message, BasicElementLabels.getPathLabel(file.getFullPath(), false)));
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:DeleteResourcesProcessor.java

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

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

示例7: reportNonEnumerizableInputConstants

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
/**
 * @return
 */
RefactoringStatus reportNonEnumerizableInputConstants() {
	final RefactoringStatus ret = new RefactoringStatus();
	final Collection enumerizableElements = Util
			.flattenForest(this.computer.getEnumerizationForest());
	for (final Iterator it = this.fieldsToRefactor.iterator(); it.hasNext();) {
		final IField field = (IField) it.next();
		if (!enumerizableElements.contains(field)) {
			String message = Messages.ConvertConstantsToEnumRefactoring_RefactoringNotPossible;
			ret.addWarning(MessageFormat.format(message,
					new Object[] { field.getElementName() }));
		}
	}
	return ret;
}
 
开发者ID:ponder-lab,项目名称:Constants-to-Enum-Eclipse-Plugin,代码行数:18,代码来源:ConvertConstantsToEnumRefactoring.java

示例8: checkNewElementName

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
public RefactoringStatus checkNewElementName(String newName) throws CoreException {
  Assert.isNotNull(newName, "new name"); // $NON-NLS-1$
  RefactoringStatus result = Checks.checkFieldName(newName, fField);

  if (isInstanceField(fField) && (!Checks.startsWithLowerCase(newName)))
    result.addWarning(
        fIsComposite
            ? Messages.format(
                RefactoringCoreMessages.RenameFieldRefactoring_should_start_lowercase2,
                new String[] {
                  BasicElementLabels.getJavaElementName(newName), getDeclaringTypeLabel()
                })
            : RefactoringCoreMessages.RenameFieldRefactoring_should_start_lowercase);

  if (Checks.isAlreadyNamed(fField, newName))
    result.addError(
        fIsComposite
            ? Messages.format(
                RefactoringCoreMessages.RenameFieldRefactoring_another_name2,
                new String[] {
                  BasicElementLabels.getJavaElementName(newName), getDeclaringTypeLabel()
                })
            : RefactoringCoreMessages.RenameFieldRefactoring_another_name,
        JavaStatusContext.create(fField));

  if (fField.getDeclaringType().getField(newName).exists())
    result.addError(
        fIsComposite
            ? Messages.format(
                RefactoringCoreMessages.RenameFieldRefactoring_field_already_defined2,
                new String[] {
                  BasicElementLabels.getJavaElementName(newName), getDeclaringTypeLabel()
                })
            : RefactoringCoreMessages.RenameFieldRefactoring_field_already_defined,
        JavaStatusContext.create(fField.getDeclaringType().getField(newName)));
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:RenameFieldProcessor.java

示例9: checkNewElementName

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
public RefactoringStatus checkNewElementName(String name) throws CoreException {
  Assert.isNotNull(name);
  RefactoringStatus result = Checks.checkTypeParameterName(name, fTypeParameter);
  if (Checks.startsWithLowerCase(name))
    result.addWarning(
        RefactoringCoreMessages.RenameTypeParameterRefactoring_should_start_lowercase);
  if (Checks.isAlreadyNamed(fTypeParameter, name))
    result.addFatalError(RefactoringCoreMessages.RenameTypeParameterRefactoring_another_name);

  IMember member = fTypeParameter.getDeclaringMember();
  if (member instanceof IType) {
    IType type = (IType) member;
    if (type.getTypeParameter(name).exists())
      result.addFatalError(
          RefactoringCoreMessages
              .RenameTypeParameterRefactoring_class_type_parameter_already_defined);
  } else if (member instanceof IMethod) {
    IMethod method = (IMethod) member;
    if (method.getTypeParameter(name).exists())
      result.addFatalError(
          RefactoringCoreMessages
              .RenameTypeParameterRefactoring_method_type_parameter_already_defined);
  } else {
    JavaPlugin.logErrorMessage(
        "Unexpected sub-type of IMember: " + member.getClass().getName()); // $NON-NLS-1$
    Assert.isTrue(false);
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:RenameTypeParameterProcessor.java

示例10: checkCompileErrorsInAffectedFile

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
public static void checkCompileErrorsInAffectedFile(RefactoringStatus result, IResource resource)
    throws JavaModelException {
  if (hasCompileErrors(resource))
    result.addWarning(
        Messages.format(
            RefactoringCoreMessages.Checks_cu_has_compile_errors,
            BasicElementLabels.getPathLabel(resource.getFullPath(), false)));
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:Checks.java

示例11: checkTempName

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
public static RefactoringStatus checkTempName(String newName, IJavaElement context) {
  RefactoringStatus result = Checks.checkIdentifier(newName, context);
  if (result.hasFatalError()) return result;
  if (!Checks.startsWithLowerCase(newName))
    result.addWarning(RefactoringCoreMessages.ExtractTempRefactoring_convention);
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:Checks.java

示例12: checkEnumConstantName

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
public static RefactoringStatus checkEnumConstantName(String newName, IJavaElement context) {
  RefactoringStatus result = Checks.checkFieldName(newName, context);
  if (result.hasFatalError()) return result;
  for (int i = 0; i < newName.length(); i++) {
    char c = newName.charAt(i);
    if (Character.isLetter(c) && !Character.isUpperCase(c)) {
      result.addWarning(RefactoringCoreMessages.RenameEnumConstRefactoring_convention);
      break;
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:Checks.java

示例13: checkConstantName

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
public static RefactoringStatus checkConstantName(String newName, IJavaElement context) {
  RefactoringStatus result = Checks.checkFieldName(newName, context);
  if (result.hasFatalError()) return result;
  for (int i = 0; i < newName.length(); i++) {
    char c = newName.charAt(i);
    if (Character.isLetter(c) && !Character.isUpperCase(c)) {
      result.addWarning(RefactoringCoreMessages.ExtractConstantRefactoring_convention);
      break;
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:Checks.java

示例14: checkFinalConditions

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException {
  try {
    pm.beginTask(RefactoringCoreMessages.ExtractTempRefactoring_checking_preconditions, 4);

    fCURewrite = new CompilationUnitRewrite(fCu, fCompilationUnitNode);
    fCURewrite.getASTRewrite().setTargetSourceRangeComputer(new NoCommentSourceRangeComputer());

    doCreateChange(new SubProgressMonitor(pm, 2));

    fChange =
        fCURewrite.createChange(
            RefactoringCoreMessages.ExtractTempRefactoring_change_name,
            true,
            new SubProgressMonitor(pm, 1));

    RefactoringStatus result = new RefactoringStatus();
    if (Arrays.asList(getExcludedVariableNames()).contains(fTempName))
      result.addWarning(
          Messages.format(
              RefactoringCoreMessages.ExtractTempRefactoring_another_variable,
              BasicElementLabels.getJavaElementName(fTempName)));

    result.merge(checkMatchingFragments());

    fChange.setKeepPreviewEdits(true);

    if (fCheckResultForCompileProblems) {
      checkNewSource(new SubProgressMonitor(pm, 1), result);
    }

    return result;
  } finally {
    pm.done();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:ExtractTempRefactoring.java

示例15: checkMatchingFragments

import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkMatchingFragments() throws JavaModelException {
  RefactoringStatus result = new RefactoringStatus();
  IASTFragment[] matchingFragments = getMatchingFragments();
  for (int i = 0; i < matchingFragments.length; i++) {
    ASTNode node = matchingFragments[i].getAssociatedNode();
    if (isLeftValue(node) && !isReferringToLocalVariableFromFor((Expression) node)) {
      String msg = RefactoringCoreMessages.ExtractTempRefactoring_assigned_to;
      result.addWarning(msg, JavaStatusContext.create(fCu, node));
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:ExtractTempRefactoring.java


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