Search in sources :

Example 6 with PerformChangeOperation

use of org.eclipse.ltk.core.refactoring.PerformChangeOperation in project che by eclipse.

the class RefactoringSession method apply.

/**
     * @return instance of {@link org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus}.
     * That describes status of the refactoring operation.
     */
public RefactoringResult apply() {
    PerformChangeOperation operation = new PerformChangeOperation(change);
    FinishResult result = internalPerformFinish(operation);
    if (result.isException()) {
        return DtoConverter.toRefactoringResultDto(RefactoringStatus.createErrorStatus("Refactoring failed with Exception."));
    }
    CompositeChange operationChange = (CompositeChange) operation.getUndoChange();
    Change[] changes = operationChange.getChildren();
    RefactoringStatus validationStatus = operation.getValidationStatus();
    if (validationStatus != null) {
        List<ChangeInfo> changesInfo = new ArrayList<>();
        prepareChangesInfo(changes, changesInfo);
        RefactoringResult status = DtoConverter.toRefactoringResultDto(validationStatus);
        status.setChanges(changesInfo);
        return status;
    }
    return DtoConverter.toRefactoringResultDto(new RefactoringStatus());
}
Also used : PerformChangeOperation(org.eclipse.ltk.core.refactoring.PerformChangeOperation) FinishResult(org.eclipse.ltk.internal.ui.refactoring.FinishResult) ChangeInfo(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeInfo) RefactoringResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringResult) ArrayList(java.util.ArrayList) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) MoveCompilationUnitChange(org.eclipse.jdt.internal.corext.refactoring.changes.MoveCompilationUnitChange) UndoTextFileChange(org.eclipse.ltk.core.refactoring.UndoTextFileChange) Change(org.eclipse.ltk.core.refactoring.Change) DynamicValidationStateChange(org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange) RenameCompilationUnitChange(org.eclipse.jdt.internal.corext.refactoring.changes.RenameCompilationUnitChange) RenamePackageChange(org.eclipse.jdt.internal.corext.refactoring.changes.RenamePackageChange) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange)

Aggregations

PerformChangeOperation (org.eclipse.ltk.core.refactoring.PerformChangeOperation)6 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 Change (org.eclipse.ltk.core.refactoring.Change)3 CreateChangeOperation (org.eclipse.ltk.core.refactoring.CreateChangeOperation)3 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)3 ArrayList (java.util.ArrayList)2 ChangeInfo (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeInfo)2 RefactoringResult (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringResult)2 CheckConditionsOperation (org.eclipse.ltk.core.refactoring.CheckConditionsOperation)2 CompositeChange (org.eclipse.ltk.core.refactoring.CompositeChange)2 IResourceChangeEvent (org.eclipse.core.resources.IResourceChangeEvent)1 IResourceChangeListener (org.eclipse.core.resources.IResourceChangeListener)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 CoreException (org.eclipse.core.runtime.CoreException)1 JavaRefactoringDescriptor (org.eclipse.jdt.core.refactoring.descriptors.JavaRefactoringDescriptor)1 DynamicValidationStateChange (org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange)1 MoveCompilationUnitChange (org.eclipse.jdt.internal.corext.refactoring.changes.MoveCompilationUnitChange)1 RenameCompilationUnitChange (org.eclipse.jdt.internal.corext.refactoring.changes.RenameCompilationUnitChange)1 RenamePackageChange (org.eclipse.jdt.internal.corext.refactoring.changes.RenamePackageChange)1 RenameSupport (org.eclipse.jdt.ui.refactoring.RenameSupport)1