/** * {@inheritDoc} */ public Refactoring createRefactoring(final RefactoringDescriptor descriptor) throws CoreException { return new MoveInstanceMethodRefactoring(new MoveInstanceMethodProcessor(null, null)); } }
@Override public final RefactoringStatus checkInitialConditions(final IProgressMonitor monitor) throws CoreException, OperationCanceledException { Assert.isNotNull(monitor); final RefactoringStatus status= new RefactoringStatus(); try { monitor.beginTask("", 4); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.MoveInstanceMethodProcessor_checking); status.merge(Checks.checkIfCuBroken(fMethod)); if (!status.hasError()) { checkMethodDeclaration(new SubProgressMonitor(monitor, 1), status); if (status.isOK()) { final MethodDeclaration declaration= ASTNodeSearchUtil.getMethodDeclarationNode(fMethod, fSourceRewrite.getRoot()); checkGenericTypes(new SubProgressMonitor(monitor, 1), declaration, status); checkMethodBody(new SubProgressMonitor(monitor, 1), declaration, status); checkPossibleTargets(new SubProgressMonitor(monitor, 1), declaration, status); } } } finally { monitor.done(); } return status; }
fSourceRewrite.clearASTAndImportRewrites(); final TextChangeManager manager= new TextChangeManager(); final CompilationUnitRewrite targetRewrite= fMethod.getCompilationUnit().equals(getTargetType().getCompilationUnit()) ? fSourceRewrite : new CompilationUnitRewrite(getTargetType().getCompilationUnit()); final MethodDeclaration declaration= ASTNodeSearchUtil.getMethodDeclarationNode(fMethod, fSourceRewrite.getRoot()); final SearchResultGroup[] references= computeMethodReferences(new SubProgressMonitor(monitor, 1), status); final Map rewrites= new HashMap(2); rewrites.put(fSourceRewrite.getCu(), fSourceRewrite); adjustor.adjustVisibility(new SubProgressMonitor(monitor, 1)); final IDocument document= new Document(fMethod.getCompilationUnit().getBuffer().getContents()); final boolean target= createMethodCopy(document, declaration, sourceRewrite, rewrites, adjustor.getAdjustments(), status, new SubProgressMonitor(monitor, 1)); createMethodJavadocReferences(rewrites, declaration, references, target, status, new SubProgressMonitor(monitor, 1)); if (!fSourceRewrite.getCu().equals(targetRewrite.getCu())) createMethodImports(targetRewrite, declaration, new SubProgressMonitor(monitor, 1), status); boolean removable= false; if (fInline) { removable= createMethodDelegator(rewrites, declaration, references, adjustor.getAdjustments(), target, status, new SubProgressMonitor(monitor, 1)); if (fRemove && removable) { fSourceRewrite.getASTRewrite().remove(declaration, fSourceRewrite.createGroupDescription(RefactoringCoreMessages.MoveInstanceMethodProcessor_remove_original_method)); createMethodDelegation(declaration, rewrites, adjustor.getAdjustments(), status, new SubProgressMonitor(monitor, 1)); createMethodSignature(document, declaration, sourceRewrite, rewrites); ICompilationUnit unit= null; CompilationUnitRewrite rewrite= null;
status.merge(Checks.checkIfCuBroken(fMethod)); if (!status.hasError()) { checkGenericTarget(new SubProgressMonitor(monitor, 1), status); if (status.isOK()) { final IType type= getTargetType(); if (type != null) { if (type.isBinary() || type.isReadOnly() || !fMethod.exists() || fMethod.isBinary() || fMethod.isReadOnly()) if (!type.exists() || type.isBinary() || type.isReadOnly()) status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveInstanceMethodProcessor_no_binary, JavaStatusContext.create(fMethod))); checkConflictingTarget(new SubProgressMonitor(monitor, 1), status); checkConflictingMethod(new SubProgressMonitor(monitor, 1), status); status.merge(Checks.validateModifiesFiles(computeModifiedFiles(fMethod.getCompilationUnit(), type.getCompilationUnit()), null)); monitor.worked(1); if (!status.hasFatalError()) fChangeManager= createChangeManager(status, new SubProgressMonitor(monitor, 1));
fSourceRewrite.clearASTAndImportRewrites(); final TextChangeManager manager= new TextChangeManager(); final CompilationUnitRewrite targetRewrite= fMethod.getCompilationUnit().equals(getTargetType().getCompilationUnit()) ? fSourceRewrite : new CompilationUnitRewrite(getTargetType().getCompilationUnit()); final MethodDeclaration declaration= ASTNodeSearchUtil.getMethodDeclarationNode(fMethod, fSourceRewrite.getRoot()); final SearchResultGroup[] references= computeMethodReferences(new SubProgressMonitor(monitor, 1), status); final Map<ICompilationUnit, CompilationUnitRewrite> rewrites= new HashMap<>(2); rewrites.put(fSourceRewrite.getCu(), fSourceRewrite); adjustor.adjustVisibility(new SubProgressMonitor(monitor, 1)); final IDocument document= new Document(fMethod.getCompilationUnit().getBuffer().getContents()); createMethodCopy(document, declaration, sourceRewrite, rewrites, adjustor.getAdjustments(), status, new SubProgressMonitor(monitor, 1)); createMethodJavadocReferences(rewrites, declaration, references, status, new SubProgressMonitor(monitor, 1)); if (!fSourceRewrite.getCu().equals(targetRewrite.getCu())) createMethodImports(targetRewrite, declaration, new SubProgressMonitor(monitor, 1), status); boolean removable= false; if (fInline) { String binaryRefsDescription= Messages.format(RefactoringCoreMessages.ReferencesInBinaryContext_ref_in_binaries_description , BasicElementLabels.getJavaElementName(getMethod().getElementName())); ReferencesInBinaryContext binaryRefs= new ReferencesInBinaryContext(binaryRefsDescription); removable= createMethodDelegator(rewrites, declaration, references, adjustor.getAdjustments(), binaryRefs, status, new SubProgressMonitor(monitor, 1)); binaryRefs.addErrorIfNecessary(status); if (fRemove && removable) { createMethodDelegation(declaration, rewrites, adjustor.getAdjustments(), status, new SubProgressMonitor(monitor, 1)); createMethodSignature(document, declaration, sourceRewrite, rewrites); ICompilationUnit unit= null; CompilationUnitRewrite rewrite= null;
status.merge(Checks.checkIfCuBroken(fMethod)); if (!status.hasError()) { checkGenericTarget(new SubProgressMonitor(monitor, 1), status); if (status.isOK()) { final IType type= getTargetType(); if (type != null) { if (type.isBinary() || type.isReadOnly() || !fMethod.exists() || fMethod.isBinary() || fMethod.isReadOnly()) if (!type.exists() || type.isBinary() || type.isReadOnly()) status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveInstanceMethodProcessor_no_binary, JavaStatusContext.create(fMethod))); checkConflictingTarget(new SubProgressMonitor(monitor, 1), status); checkConflictingMethod(new SubProgressMonitor(monitor, 1), status); Checks.addModifiedFilesToChecker(computeModifiedFiles(fMethod.getCompilationUnit(), type.getCompilationUnit()), context); fChangeManager= createChangeManager(status, new SubProgressMonitor(monitor, 1));
fSourceRewrite.clearASTAndImportRewrites(); final TextChangeManager manager= new TextChangeManager(); final CompilationUnitRewrite targetRewrite= fMethod.getCompilationUnit().equals(getTargetType().getCompilationUnit()) ? fSourceRewrite : new CompilationUnitRewrite(getTargetType().getCompilationUnit()); final MethodDeclaration declaration= ASTNodeSearchUtil.getMethodDeclarationNode(fMethod, fSourceRewrite.getRoot()); final SearchResultGroup[] references= computeMethodReferences(new SubProgressMonitor(monitor, 1), status); final Map<ICompilationUnit, CompilationUnitRewrite> rewrites= new HashMap<>(2); rewrites.put(fSourceRewrite.getCu(), fSourceRewrite); adjustor.adjustVisibility(new SubProgressMonitor(monitor, 1)); final IDocument document= new Document(fMethod.getCompilationUnit().getBuffer().getContents()); createMethodCopy(document, declaration, sourceRewrite, rewrites, adjustor.getAdjustments(), status, new SubProgressMonitor(monitor, 1)); createMethodJavadocReferences(rewrites, declaration, references, status, new SubProgressMonitor(monitor, 1)); if (!fSourceRewrite.getCu().equals(targetRewrite.getCu())) createMethodImports(targetRewrite, declaration, new SubProgressMonitor(monitor, 1), status); boolean removable= false; if (fInline) { String binaryRefsDescription= Messages.format(RefactoringCoreMessages.ReferencesInBinaryContext_ref_in_binaries_description , BasicElementLabels.getJavaElementName(getMethod().getElementName())); ReferencesInBinaryContext binaryRefs= new ReferencesInBinaryContext(binaryRefsDescription); removable= createMethodDelegator(rewrites, declaration, references, adjustor.getAdjustments(), binaryRefs, status, new SubProgressMonitor(monitor, 1)); binaryRefs.addErrorIfNecessary(status); if (fRemove && removable) { createMethodDelegation(declaration, rewrites, adjustor.getAdjustments(), status, new SubProgressMonitor(monitor, 1)); createMethodSignature(document, declaration, sourceRewrite, rewrites); ICompilationUnit unit= null; CompilationUnitRewrite rewrite= null;
status.merge(Checks.checkIfCuBroken(fMethod)); if (!status.hasError()) { checkGenericTarget(new SubProgressMonitor(monitor, 1), status); if (status.isOK()) { final IType type= getTargetType(); if (type != null) { if (type.isBinary() || type.isReadOnly() || !fMethod.exists() || fMethod.isBinary() || fMethod.isReadOnly()) if (!type.exists() || type.isBinary() || type.isReadOnly()) status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveInstanceMethodProcessor_no_binary, JavaStatusContext.create(fMethod))); checkConflictingTarget(new SubProgressMonitor(monitor, 1), status); checkConflictingMethod(new SubProgressMonitor(monitor, 1), status); Checks.addModifiedFilesToChecker(computeModifiedFiles(fMethod.getCompilationUnit(), type.getCompilationUnit()), context); fChangeManager= createChangeManager(status, new SubProgressMonitor(monitor, 1));
public final RefactoringStatus checkInitialConditions(final IProgressMonitor monitor) throws CoreException, OperationCanceledException { Assert.isNotNull(monitor); final RefactoringStatus status= new RefactoringStatus(); try { monitor.beginTask("", 4); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.MoveInstanceMethodProcessor_checking); status.merge(Checks.checkIfCuBroken(fMethod)); if (!status.hasError()) { checkMethodDeclaration(new SubProgressMonitor(monitor, 1), status); if (status.isOK()) { final MethodDeclaration declaration= ASTNodeSearchUtil.getMethodDeclarationNode(fMethod, fSourceRewrite.getRoot()); checkGenericTypes(new SubProgressMonitor(monitor, 1), declaration, status); checkMethodBody(new SubProgressMonitor(monitor, 1), declaration, status); checkPossibleTargets(new SubProgressMonitor(monitor, 1), declaration, status); } } } finally { monitor.done(); } return status; }
public static void startMoveMethodRefactoring(final IMethod method, final Shell shell) throws JavaModelException { final MoveInstanceMethodRefactoring refactoring= new MoveInstanceMethodRefactoring(new MoveInstanceMethodProcessor(method, JavaPreferencesSettings.getCodeGenerationSettings(method.getJavaProject()))); new RefactoringStarter().activate(refactoring, new MoveInstanceMethodWizard(refactoring), shell, RefactoringMessages.MoveInstanceMethodAction_dialog_title, RefactoringSaveHelper.SAVE_JAVA_ONLY_UPDATES); }
@Override public final RefactoringStatus checkInitialConditions(final IProgressMonitor monitor) throws CoreException, OperationCanceledException { Assert.isNotNull(monitor); final RefactoringStatus status= new RefactoringStatus(); try { monitor.beginTask("", 4); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.MoveInstanceMethodProcessor_checking); status.merge(Checks.checkIfCuBroken(fMethod)); if (!status.hasError()) { checkMethodDeclaration(new SubProgressMonitor(monitor, 1), status); if (status.isOK()) { final MethodDeclaration declaration= ASTNodeSearchUtil.getMethodDeclarationNode(fMethod, fSourceRewrite.getRoot()); checkGenericTypes(new SubProgressMonitor(monitor, 1), declaration, status); checkMethodBody(new SubProgressMonitor(monitor, 1), declaration, status); checkPossibleTargets(new SubProgressMonitor(monitor, 1), declaration, status); } } } finally { monitor.done(); } return status; }
@Override public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); MoveInstanceMethodProcessor processor= new MoveInstanceMethodProcessor(arguments, status); return new MoveRefactoring(processor); }
@Override public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); MoveInstanceMethodProcessor processor= new MoveInstanceMethodProcessor(arguments, status); return new MoveRefactoring(processor); }
public static void startMoveMethodRefactoring(final IMethod method, final Shell shell) { MoveInstanceMethodProcessor processor= new MoveInstanceMethodProcessor(method, JavaPreferencesSettings.getCodeGenerationSettings(method.getJavaProject())); Refactoring refactoring= new MoveRefactoring(processor); MoveInstanceMethodWizard wizard= new MoveInstanceMethodWizard(processor, refactoring); new RefactoringStarter().activate(wizard, shell, RefactoringMessages.MoveInstanceMethodAction_dialog_title, RefactoringSaveHelper.SAVE_REFACTORING); }
public static void startMoveMethodRefactoring(final IMethod method, final Shell shell) { MoveInstanceMethodProcessor processor= new MoveInstanceMethodProcessor(method, JavaPreferencesSettings.getCodeGenerationSettings(method.getJavaProject())); Refactoring refactoring= new MoveRefactoring(processor); MoveInstanceMethodWizard wizard= new MoveInstanceMethodWizard(processor, refactoring); new RefactoringStarter().activate(wizard, shell, RefactoringMessages.MoveInstanceMethodAction_dialog_title, RefactoringSaveHelper.SAVE_REFACTORING); }