Search in sources :

Example 1 with FinishResult

use of org.eclipse.ltk.internal.ui.refactoring.FinishResult 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

ArrayList (java.util.ArrayList)1 ChangeInfo (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeInfo)1 RefactoringResult (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringResult)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 Change (org.eclipse.ltk.core.refactoring.Change)1 CompositeChange (org.eclipse.ltk.core.refactoring.CompositeChange)1 PerformChangeOperation (org.eclipse.ltk.core.refactoring.PerformChangeOperation)1 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)1 UndoTextFileChange (org.eclipse.ltk.core.refactoring.UndoTextFileChange)1 FinishResult (org.eclipse.ltk.internal.ui.refactoring.FinishResult)1