org.eclipse.ltk.core.refactoring.Refactoring Java Examples
The following examples show how to use
org.eclipse.ltk.core.refactoring.Refactoring.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RefactoringWizardOpenOperation_NonForking.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * CHANGED to protected * CHANGED do not fork as we are keeping the resource lock. */ protected RefactoringStatus checkInitialConditions(Refactoring refactoring, Shell parent, String title, IRunnableContext context) throws InterruptedException { try { CheckConditionsOperation cco = new CheckConditionsOperation(refactoring, CheckConditionsOperation.INITIAL_CONDITONS); WorkbenchRunnableAdapter workbenchRunnableAdapter = new WorkbenchRunnableAdapter(cco, ResourcesPlugin .getWorkspace().getRoot()); /* CHANGE: don't fork (or use busyCursorWhile) as this will cause a deadlock */ if (context == null) { PlatformUI.getWorkbench().getProgressService().run(false, true, workbenchRunnableAdapter); } else if (context instanceof IProgressService) { ((IProgressService) context).run(false, true, workbenchRunnableAdapter); } else { context.run(false, true, workbenchRunnableAdapter); } return cco.getStatus(); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, parent, title, RefactoringUIMessages.RefactoringUI_open_unexpected_exception); return RefactoringStatus .createFatalErrorStatus(RefactoringUIMessages.RefactoringUI_open_unexpected_exception); } }
Example #2
Source File: BinaryRefactoringHistoryWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected RefactoringStatus refactoringPerformed(final Refactoring refactoring, final IProgressMonitor monitor) { try { monitor.beginTask("", 120); //$NON-NLS-1$ final RefactoringStatus status= super.refactoringPerformed(refactoring, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); if (!status.hasFatalError()) { if (fSourceFolder != null) { try { fSourceFolder.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); } catch (CoreException exception) { JavaPlugin.log(exception); } } } return status; } finally { monitor.done(); } }
Example #3
Source File: ChangeBuilder.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * Creates a refactoring (or returns a previously created refactoring). */ public Refactoring createRefactoring() throws RefactoringException { if (refactoring != null) { return refactoring; } RefactoringStatus status = new RefactoringStatus(); D descriptor = createDescriptor(); try { refactoring = descriptor.createRefactoring(status); } catch (CoreException e) { throw new RefactoringException(e); } if (refactoring == null) { throw new RefactoringException( String.format( "The refactoring descriptor (%s) was unable to create a refactoring.", descriptor.getClass().getSimpleName())); } if (status.hasError()) { throw new RefactoringException( status.getMessageMatchingSeverity(RefactoringStatus.ERROR)); } return refactoring; }
Example #4
Source File: MoveHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static MoveDestinationsResponse getInstanceMethodDestinations(CodeActionParams params) { final ICompilationUnit unit = JDTUtils.resolveCompilationUnit(params.getTextDocument().getUri()); if (unit == null) { return new MoveDestinationsResponse("Cannot find the compilation unit associated with " + params.getTextDocument().getUri()); } MethodDeclaration methodDeclaration = getSelectedMethodDeclaration(unit, params); if (methodDeclaration == null) { return new MoveDestinationsResponse("The selected element is not a method."); } IMethodBinding methodBinding = methodDeclaration.resolveBinding(); if (methodBinding == null || !(methodBinding.getJavaElement() instanceof IMethod)) { return new MoveDestinationsResponse("The selected element is not a method."); } IMethod method = (IMethod) methodBinding.getJavaElement(); MoveInstanceMethodProcessor processor = new MoveInstanceMethodProcessor(method, PreferenceManager.getCodeGenerationSettings(method.getJavaProject().getProject())); Refactoring refactoring = new MoveRefactoring(processor); CheckConditionsOperation check = new CheckConditionsOperation(refactoring, CheckConditionsOperation.INITIAL_CONDITONS); try { check.run(new NullProgressMonitor()); if (check.getStatus().hasFatalError()) { return new MoveDestinationsResponse(check.getStatus().getMessageMatchingSeverity(RefactoringStatus.FATAL)); } IVariableBinding[] possibleTargets = processor.getPossibleTargets(); LspVariableBinding[] targets = Stream.of(possibleTargets).map(target -> new LspVariableBinding(target)).toArray(LspVariableBinding[]::new); return new MoveDestinationsResponse(targets); } catch (CoreException e) { JavaLanguageServerPlugin.log(e); } return new MoveDestinationsResponse("Cannot find any target to move the method to."); }
Example #5
Source File: MoveRefactoringContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); JavaMoveProcessor processor= new JavaMoveProcessor(arguments, status); return new MoveRefactoring(processor); }
Example #6
Source File: RefactoringExecutionHelper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates a new refactoring execution helper. * * @param refactoring the refactoring * @param stopSeverity a refactoring status constant from {@link RefactoringStatus} * @param saveMode a save mode from {@link RefactoringSaveHelper} * @param parent the parent shell * @param context the runnable context */ public RefactoringExecutionHelper(Refactoring refactoring, int stopSeverity, int saveMode, Shell parent, IRunnableContext context) { super(); Assert.isNotNull(refactoring); Assert.isNotNull(parent); Assert.isNotNull(context); fRefactoring= refactoring; fStopSeverity= stopSeverity; fParent= parent; fExecContext= context; fSaveMode= saveMode; }
Example #7
Source File: RenameMethodWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public RenameMethodWizard(Refactoring refactoring) { super(refactoring, RefactoringMessages.RenameMethodWizard_defaultPageTitle, RefactoringMessages.RenameMethodWizard_inputPage_description, JavaPluginImages.DESC_WIZBAN_REFACTOR_METHOD, IJavaHelpContextIds.RENAME_METHOD_WIZARD_PAGE); }
Example #8
Source File: ReplaceTypeCodeWithStateStrategyDescriptor.java From JDeodorant with MIT License | 5 votes |
@Override public Refactoring createRefactoring(RefactoringStatus status) throws CoreException { Refactoring refactoring = new ReplaceTypeCodeWithStateStrategy(sourceFile, sourceCompilationUnit, sourceTypeDeclaration, typeCheckElimination); RefactoringStatus refStatus = new RefactoringStatus(); status.merge(refStatus); return refactoring; }
Example #9
Source File: CopyRefactoringContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public final Refactoring createRefactoring(final JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); JavaCopyProcessor processor= new JavaCopyProcessor(arguments, status); return new CopyRefactoring(processor); }
Example #10
Source File: ExtractClassRefactoringDescriptor.java From JDeodorant with MIT License | 5 votes |
@Override public Refactoring createRefactoring(RefactoringStatus status) throws CoreException { Refactoring refactoring = new ExtractClassRefactoring(sourceFile, sourceCompilationUnit, sourceTypeDeclaration, extractedFieldFragments, extractedMethods, delegateMethods, extractedTypeName); RefactoringStatus refStatus = new RefactoringStatus(); status.merge(refStatus); return refactoring; }
Example #11
Source File: RenameCuWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public RenameCuWizard(Refactoring refactoring) { super(refactoring, RefactoringMessages.RenameCuWizard_defaultPageTitle, RefactoringMessages.RenameCuWizard_inputPage_description, JavaPluginImages.DESC_WIZBAN_REFACTOR_CU, IJavaHelpContextIds.RENAME_CU_WIZARD_PAGE); }
Example #12
Source File: RenameUserInterfaceStarter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean activate(Refactoring refactoring, Shell parent, int saveMode) throws CoreException { RenameProcessor processor= (RenameProcessor)refactoring.getAdapter(RenameProcessor.class); Object[] elements= processor.getElements(); RenameSelectionState state= elements.length == 1 ? new RenameSelectionState(elements[0]) : null; boolean executed= super.activate(refactoring, parent, saveMode); INameUpdating nameUpdating= (INameUpdating)refactoring.getAdapter(INameUpdating.class); if (executed && nameUpdating != null && state != null) { Object newElement= nameUpdating.getNewElement(); if (newElement != null) { state.restore(newElement); } } return executed; }
Example #13
Source File: RenameJavaProjectRefactoringContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenameJavaProjectProcessor processor= new RenameJavaProjectProcessor(arguments, status); return new RenameRefactoring(processor); }
Example #14
Source File: RefactoringExecutionStarter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static void startCopyRefactoring(IResource[] resources, IJavaElement[] javaElements, Shell shell) throws JavaModelException { ICopyPolicy copyPolicy= ReorgPolicyFactory.createCopyPolicy(resources, javaElements); if (copyPolicy.canEnable()) { JavaCopyProcessor processor= new JavaCopyProcessor(copyPolicy); Refactoring refactoring= new CopyRefactoring(processor); RefactoringWizard wizard= new ReorgCopyWizard(processor, refactoring); processor.setNewNameQueries(new NewNameQueries(wizard)); processor.setReorgQueries(new ReorgQueries(wizard)); new RefactoringStarter().activate(wizard, shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, processor.getSaveMode()); } }
Example #15
Source File: RenameTypeParameterRefactoringContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenameTypeParameterProcessor processor= new RenameTypeParameterProcessor(arguments, status); return new RenameRefactoring(processor); }
Example #16
Source File: MoveStaticMembersRefactoringContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); MoveStaticMembersProcessor processor= new MoveStaticMembersProcessor(arguments, status); return new MoveRefactoring(processor); }
Example #17
Source File: ReplaceConditionalWithPolymorphismDescriptor.java From JDeodorant with MIT License | 5 votes |
@Override public Refactoring createRefactoring(RefactoringStatus status) throws CoreException { Refactoring refactoring = new ReplaceConditionalWithPolymorphism(sourceFile, sourceCompilationUnit, sourceTypeDeclaration, typeCheckElimination); RefactoringStatus refStatus = new RefactoringStatus(); status.merge(refStatus); return refactoring; }
Example #18
Source File: MoveMethodRefactoringDescriptor.java From JDeodorant with MIT License | 5 votes |
@Override public Refactoring createRefactoring(RefactoringStatus status) throws CoreException { Refactoring refactoring = new MoveMethodRefactoring(sourceCompilationUnit, targetCompilationUnit, sourceTypeDeclaration, targetTypeDeclaration, sourceMethod, additionalMethodsToBeMoved, leaveDelegate, movedMethodName); RefactoringStatus refStatus = new RefactoringStatus(); status.merge(refStatus); return refactoring; }
Example #19
Source File: AbstractResourceRelocationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void performRefactoring(RefactoringDescriptor descriptor, IProgressMonitor monitor) throws Exception { project.refreshLocal(IResource.DEPTH_INFINITE, null); project.build(IncrementalProjectBuilder.FULL_BUILD, null); RefactoringStatus status = new RefactoringStatus(); Refactoring refactoring = descriptor.createRefactoring(status); refactoring.checkAllConditions(monitor); Assert.assertTrue(status.isOK()); Change change = refactoring.createChange(monitor); change.perform(monitor); project.refreshLocal(IResource.DEPTH_INFINITE, null); project.build(IncrementalProjectBuilder.FULL_BUILD, null); }
Example #20
Source File: RenameInputWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void updateForcePreview() { boolean forcePreview= false; Refactoring refactoring= getRefactoring(); ITextUpdating tu= (ITextUpdating) refactoring.getAdapter(ITextUpdating.class); IQualifiedNameUpdating qu= (IQualifiedNameUpdating)refactoring.getAdapter(IQualifiedNameUpdating.class); if (tu != null) { forcePreview= tu.getUpdateTextualMatches(); } if (qu != null) { forcePreview |= qu.getUpdateQualifiedNames(); } getRefactoringWizard().setForcePreviewReview(forcePreview); }
Example #21
Source File: RenameTypeRefactoringContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenameTypeProcessor processor= new RenameTypeProcessor(arguments, status); return new RenameRefactoring(processor); }
Example #22
Source File: RenamePackageWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public RenamePackageWizard(Refactoring refactoring) { super(refactoring, RefactoringMessages.RenamePackageWizard_defaultPageTitle, RefactoringMessages.RenamePackageWizard_inputPage_description, JavaPluginImages.DESC_WIZBAN_REFACTOR_PACKAGE, IJavaHelpContextIds.RENAME_PACKAGE_WIZARD_PAGE); }
Example #23
Source File: IntroduceParameterObjectContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { if (descriptor instanceof IntroduceParameterObjectDescriptor) { IntroduceParameterObjectProcessor processor= new IntroduceParameterObjectProcessor((IntroduceParameterObjectDescriptor) descriptor); return new ProcessorBasedRefactoring(processor); } return null; }
Example #24
Source File: RenameFieldRefactoringContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenameFieldProcessor processor= new RenameFieldProcessor(arguments, status); return new RenameRefactoring(processor); }
Example #25
Source File: ExtractCloneRefactoringDescriptor.java From JDeodorant with MIT License | 5 votes |
@Override public Refactoring createRefactoring(RefactoringStatus status) throws CoreException { Refactoring refactoring = new ExtractCloneRefactoring(mappers); RefactoringStatus refStatus = new RefactoringStatus(); status.merge(refStatus); return refactoring; }
Example #26
Source File: ExtractInterfaceRefactoringContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); ExtractInterfaceProcessor processor= new ExtractInterfaceProcessor(arguments, status); return new ProcessorBasedRefactoring(processor); }
Example #27
Source File: ExtractClassContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { if (!(descriptor instanceof ExtractClassDescriptor)) { status.addFatalError(RefactoringCoreMessages.ExtractClassContribution_error_unknown_descriptor); return null; } return new ExtractClassRefactoring((ExtractClassDescriptor) descriptor); }
Example #28
Source File: RenameCompilationUnitRefactoringContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); RenameCompilationUnitProcessor processor= new RenameCompilationUnitProcessor(arguments, status); return new RenameRefactoring(processor); }
Example #29
Source File: MoveMethodRefactoringContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @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); }
Example #30
Source File: DeleteRefactoringContribution.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException { JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor)); JavaDeleteProcessor processor= new JavaDeleteProcessor(arguments, status); return new DeleteRefactoring(processor); }