private RefactoringStatus checkRelatedMethods() throws CoreException { RefactoringStatus result = new RefactoringStatus(); for (Iterator<IMethod> iter = fMethodsToRename.iterator(); iter.hasNext(); ) { IMethod method = iter.next(); result.merge( Checks.checkIfConstructorName( method, getNewElementName(), method.getDeclaringType().getElementName())); String[] msgData = new String[] { BasicElementLabels.getJavaElementName(method.getElementName()), BasicElementLabels.getJavaElementName( method.getDeclaringType().getFullyQualifiedName('.')) }; if (!method.exists()) { result.addFatalError( Messages.format(RefactoringCoreMessages.RenameMethodRefactoring_not_in_model, msgData)); continue; } if (method.isBinary()) result.addFatalError( Messages.format(RefactoringCoreMessages.RenameMethodRefactoring_no_binary, msgData)); if (method.isReadOnly()) result.addFatalError( Messages.format(RefactoringCoreMessages.RenameMethodRefactoring_no_read_only, msgData)); if (JdtFlags.isNative(method)) result.addError( Messages.format(RefactoringCoreMessages.RenameMethodRefactoring_no_native_1, msgData)); } return result; }
@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; }