Search in sources :

Example 91 with RefactoringStatus

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

the class ResourceChangeChecker method createFrom.

private static RefactoringStatus createFrom(IStatus status) {
    if (status.isOK())
        return new RefactoringStatus();
    if (!status.isMultiStatus()) {
        switch(status.getSeverity()) {
            case IStatus.OK:
                return new RefactoringStatus();
            case IStatus.INFO:
                return RefactoringStatus.createInfoStatus(status.getMessage());
            case IStatus.WARNING:
                return RefactoringStatus.createWarningStatus(status.getMessage());
            case IStatus.ERROR:
                return RefactoringStatus.createErrorStatus(status.getMessage());
            case IStatus.CANCEL:
                return RefactoringStatus.createFatalErrorStatus(status.getMessage());
            default:
                return RefactoringStatus.createFatalErrorStatus(status.getMessage());
        }
    } else {
        IStatus[] children = status.getChildren();
        RefactoringStatus result = new RefactoringStatus();
        for (int i = 0; i < children.length; i++) {
            result.merge(createFrom(children[i]));
        }
        return result;
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus)

Example 92 with RefactoringStatus

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

the class ValidateEditChecker method check.

/**
	 * {@inheritDoc}
	 */
public RefactoringStatus check(IProgressMonitor monitor) throws CoreException {
    IResource[] resources = (IResource[]) fFiles.toArray(new IResource[fFiles.size()]);
    RefactoringStatus result = new RefactoringStatus();
    IStatus status = Resources.checkInSync(resources);
    if (!status.isOK())
        result.merge(RefactoringStatus.create(status));
    status = Resources.makeCommittable(resources, fContext);
    if (!status.isOK()) {
        result.merge(RefactoringStatus.create(status));
        if (!result.hasFatalError()) {
            result.addFatalError(RefactoringCoreMessages.ValidateEditChecker_failed);
        }
    }
    return result;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IResource(org.eclipse.core.resources.IResource)

Example 93 with RefactoringStatus

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

the class MoveResourceChange method performSourceRestore.

private void performSourceRestore(IProgressMonitor monitor) throws CoreException {
    monitor.beginTask(RefactoringCoreMessages.MoveResourceChange_progress_restore_source, 3);
    try {
        fRestoreSourceChange.initializeValidationData(new SubProgressMonitor(monitor, 1));
        RefactoringStatus restoreStatus = fRestoreSourceChange.isValid(new SubProgressMonitor(monitor, 1));
        if (!restoreStatus.hasFatalError()) {
            fRestoreSourceChange.perform(new SubProgressMonitor(monitor, 1));
        }
    } finally {
        monitor.done();
    }
}
Also used : RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 94 with RefactoringStatus

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

the class ModificationStampValidationState method isValid.

public RefactoringStatus isValid(boolean needsSaving, boolean resilientForDerived) throws CoreException {
    RefactoringStatus result = super.isValid(needsSaving, resilientForDerived);
    if (result.hasFatalError())
        return result;
    ModificationStamp currentStamp = getModificationStamp();
    // not be dirty
    if (fModificationStamp.getValue() != currentStamp.getValue() || // the stamp is a null stamp then the king must be equal as well.
    (fModificationStamp.isFileStamp() && fModificationStamp.getValue() == IResource.NULL_STAMP && !currentStamp.isFileStamp()) || (fModificationStamp.isDocumentStamp() && fModificationStamp.getValue() == IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP && !currentStamp.isDocumentStamp()) || (fModificationStamp.isFileStamp() && currentStamp.isFileStamp() && isDirty(fFile))) {
        result.addFatalError(Messages.format(RefactoringCoreMessages.TextChanges_error_content_changed, BasicElementLabels.getPathLabel(fFile.getFullPath(), false)));
    }
    return result;
}
Also used : RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus)

Example 95 with RefactoringStatus

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

the class Changes method validateModifiesFiles.

public static RefactoringStatus validateModifiesFiles(IFile[] filesToModify) {
    RefactoringStatus result = new RefactoringStatus();
    IStatus status = Resources.checkInSync(filesToModify);
    if (!status.isOK())
        result.merge(RefactoringStatus.create(status));
    status = Resources.makeCommittable(filesToModify, null);
    if (!status.isOK()) {
        result.merge(RefactoringStatus.create(status));
        if (!result.hasFatalError()) {
            result.addFatalError(RefactoringCoreMessages.Changes_validateEdit);
        }
    }
    return result;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus)

Aggregations

RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)251 IType (org.eclipse.jdt.core.IType)62 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)53 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)30 IMethod (org.eclipse.jdt.core.IMethod)29 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)28 IJavaElement (org.eclipse.jdt.core.IJavaElement)28 Test (org.junit.Test)26 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)24 ArrayList (java.util.ArrayList)23 BaseTest (org.eclipse.che.plugin.java.server.che.BaseTest)21 RenameRefactoring (org.eclipse.ltk.core.refactoring.participants.RenameRefactoring)19 RenameJavaElementDescriptor (org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor)18 IFile (org.eclipse.core.resources.IFile)16 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)16 ASTNode (org.eclipse.jdt.core.dom.ASTNode)16 CoreException (org.eclipse.core.runtime.CoreException)15 IField (org.eclipse.jdt.core.IField)15 IStatus (org.eclipse.core.runtime.IStatus)14 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)13