Search in sources :

Example 46 with RefactoringStatus

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

the class Checks method validateModifiesFiles.

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

Example 47 with RefactoringStatus

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

the class ChangeSignatureProcessor method checkCompilationofDeclaringCu.

private RefactoringStatus checkCompilationofDeclaringCu() throws CoreException {
    ICompilationUnit cu = getCu();
    TextChange change = fChangeManager.get(cu);
    String newCuSource = change.getPreviewContent(new NullProgressMonitor());
    CompilationUnit newCUNode = new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(newCuSource, cu, true, false, null);
    IProblem[] problems = RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, fBaseCuRewrite.getRoot());
    RefactoringStatus result = new RefactoringStatus();
    for (int i = 0; i < problems.length; i++) {
        IProblem problem = problems[i];
        if (shouldReport(problem, newCUNode))
            result.addEntry(new RefactoringStatusEntry((problem.isError() ? RefactoringStatus.ERROR : RefactoringStatus.WARNING), problem.getMessage(), new JavaStringStatusContext(newCuSource, SourceRangeFactory.create(problem))));
    }
    return result;
}
Also used : CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RefactoringASTParser(org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser) RefactoringStatusEntry(org.eclipse.ltk.core.refactoring.RefactoringStatusEntry) TextChange(org.eclipse.ltk.core.refactoring.TextChange) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) JavaStringStatusContext(org.eclipse.jdt.internal.corext.refactoring.base.JavaStringStatusContext) IProblem(org.eclipse.jdt.core.compiler.IProblem)

Example 48 with RefactoringStatus

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

the class JavaMoveProcessor method initialize.

private RefactoringStatus initialize(JavaRefactoringArguments arguments) {
    setReorgQueries(new NullReorgQueries());
    final RefactoringStatus status = new RefactoringStatus();
    fMovePolicy = ReorgPolicyFactory.createMovePolicy(status, arguments);
    if (fMovePolicy != null && !status.hasFatalError()) {
        final CreateTargetExecutionLog log = ReorgPolicyFactory.loadCreateTargetExecutionLog(arguments);
        if (log != null && !status.hasFatalError()) {
            fMovePolicy.setDestinationCheck(false);
            fCreateTargetQueries = new MonitoringCreateTargetQueries(new LoggedCreateTargetQueries(log), log);
        }
        status.merge(fMovePolicy.initialize(arguments));
    }
    return status;
}
Also used : RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus)

Example 49 with RefactoringStatus

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

the class SelfEncapsulateFieldRefactoring method checkInitialConditions.

//----activation checking ----------------------------------------------------------
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
    if (fVisibility < 0)
        fVisibility = (fField.getFlags() & (Flags.AccPublic | Flags.AccProtected | Flags.AccPrivate));
    RefactoringStatus result = new RefactoringStatus();
    result.merge(Checks.checkAvailability(fField));
    if (result.hasFatalError())
        return result;
    fRoot = new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(fField.getCompilationUnit(), true, pm);
    ISourceRange sourceRange = fField.getNameRange();
    ASTNode node = NodeFinder.perform(fRoot, sourceRange.getOffset(), sourceRange.getLength());
    if (node == null) {
        return mappingErrorFound(result, node);
    }
    fFieldDeclaration = (VariableDeclarationFragment) ASTNodes.getParent(node, VariableDeclarationFragment.class);
    if (fFieldDeclaration == null) {
        return mappingErrorFound(result, node);
    }
    if (fFieldDeclaration.resolveBinding() == null) {
        if (!processCompilerError(result, node))
            result.addFatalError(RefactoringCoreMessages.SelfEncapsulateField_type_not_resolveable);
        return result;
    }
    computeUsedNames();
    return result;
}
Also used : RefactoringASTParser(org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser) ASTNode(org.eclipse.jdt.core.dom.ASTNode) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) ISourceRange(org.eclipse.jdt.core.ISourceRange)

Example 50 with RefactoringStatus

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

the class ChangeSignatureProcessor method checkNativeMethods.

private RefactoringStatus checkNativeMethods() throws JavaModelException {
    RefactoringStatus result = new RefactoringStatus();
    for (int i = 0; i < fRippleMethods.length; i++) {
        if (JdtFlags.isNative(fRippleMethods[i])) {
            String message = Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_native, new String[] { JavaElementUtil.createMethodSignature(fRippleMethods[i]), BasicElementLabels.getJavaElementName(fRippleMethods[i].getDeclaringType().getFullyQualifiedName('.')) });
            result.addError(message, JavaStatusContext.create(fRippleMethods[i]));
        }
    }
    return result;
}
Also used : 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