Search in sources :

Example 16 with IErlSelection

use of org.erlide.wrangler.refactoring.selection.IErlSelection in project erlide_eclipse by erlang.

the class FoldAgainstMacro method checkInitialConditions.

@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
    final IErlSelection selection = GlobalParameters.getWranglerSelection();
    /*
         * if (!((selection instanceof IErlMemberSelection) && (selection
         * .getKind() == SelectionKind.FUNCTION || selection.getKind() ==
         * SelectionKind.FUNCTION_CLAUSE))) return RefactoringStatus
         * .createFatalErrorStatus("Please select an expression!");
         */
    final IErlMemberSelection sel = (IErlMemberSelection) selection;
    ExpressionPosRpcMessage m = new ExpressionPosRpcMessage();
    m = (ExpressionPosRpcMessage) WranglerBackendManager.getRefactoringBackend().callWithParser(m, "fold_against_macro_eclipse", "siixi", sel.getFilePath(), sel.getMemberRange().getStartLine(), sel.getMemberRange().getStartCol(), sel.getSearchPath(), GlobalParameters.getTabWidth());
    if (m.isSuccessful()) {
        syntaxTree = m.getSyntaxTree();
        positions = m.getPositionDefinitions(sel.getDocument());
        selectedPositions = new ArrayList<>();
    } else {
        return RefactoringStatus.createFatalErrorStatus(m.getMessageString());
    }
    return new RefactoringStatus();
}
Also used : IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection) ExpressionPosRpcMessage(org.erlide.wrangler.refactoring.backend.internal.ExpressionPosRpcMessage)

Example 17 with IErlSelection

use of org.erlide.wrangler.refactoring.selection.IErlSelection in project erlide_eclipse by erlang.

the class FoldLocalExpressionRefactoring method checkFinalConditions.

@Override
public RefactoringStatus checkFinalConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
    final IErlSelection sel = GlobalParameters.getWranglerSelection();
    final IRefactoringRpcMessage message = run(sel);
    if (message.isSuccessful()) {
        changedFiles = message.getRefactoringChangeset();
        return new RefactoringStatus();
    }
    return RefactoringStatus.createFatalErrorStatus(message.getMessageString());
}
Also used : IRefactoringRpcMessage(org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection)

Example 18 with IErlSelection

use of org.erlide.wrangler.refactoring.selection.IErlSelection in project erlide_eclipse by erlang.

the class FoldRemoteExpressionRefactoring method checkFinalConditions.

@Override
public RefactoringStatus checkFinalConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
    final IErlSelection sel = GlobalParameters.getWranglerSelection();
    final IRefactoringRpcMessage message = run(sel);
    if (message.isSuccessful()) {
        changedFiles = message.getRefactoringChangeset();
        return new RefactoringStatus();
    }
    return RefactoringStatus.createFatalErrorStatus(message.getMessageString());
}
Also used : IRefactoringRpcMessage(org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection)

Example 19 with IErlSelection

use of org.erlide.wrangler.refactoring.selection.IErlSelection in project erlide_eclipse by erlang.

the class MergeForAllRefactoring method checkInitialConditions.

@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
    final IErlSelection selection = GlobalParameters.getWranglerSelection();
    /*
         * if (!((selection instanceof IErlMemberSelection) && (selection
         * .getKind() == SelectionKind.FUNCTION || selection.getKind() ==
         * SelectionKind.FUNCTION_CLAUSE))) return RefactoringStatus
         * .createFatalErrorStatus("Please select an expression!");
         */
    final IErlMemberSelection sel = (IErlMemberSelection) selection;
    ExpressionPosRpcMessage m = new ExpressionPosRpcMessage();
    m = (ExpressionPosRpcMessage) WranglerBackendManager.getRefactoringBackend().callWithParser(m, "merge_forall_eclipse", "sxi", sel.getFilePath(), sel.getSearchPath(), GlobalParameters.getTabWidth());
    if (m.isSuccessful()) {
        positions = m.getPositionDefinitions(sel.getDocument());
        selectedPositions = new ArrayList<>();
    } else {
        return RefactoringStatus.createFatalErrorStatus(m.getMessageString());
    }
    return new RefactoringStatus();
}
Also used : IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection) ExpressionPosRpcMessage(org.erlide.wrangler.refactoring.backend.internal.ExpressionPosRpcMessage)

Example 20 with IErlSelection

use of org.erlide.wrangler.refactoring.selection.IErlSelection in project erlide_eclipse by erlang.

the class MergeLetRefactoring method checkFinalConditions.

@Override
public RefactoringStatus checkFinalConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
    final IErlSelection sel = GlobalParameters.getWranglerSelection();
    final IRefactoringRpcMessage message = run(sel);
    if (message.isSuccessful()) {
        changedFiles = message.getRefactoringChangeset();
        return new RefactoringStatus();
    }
    return RefactoringStatus.createFatalErrorStatus(message.getMessageString());
}
Also used : IRefactoringRpcMessage(org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection)

Aggregations

IErlSelection (org.erlide.wrangler.refactoring.selection.IErlSelection)22 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)19 IRefactoringRpcMessage (org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage)14 RefactoringWorkflowController (org.erlide.wrangler.refactoring.core.RefactoringWorkflowController)5 IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)5 ExpressionPosRpcMessage (org.erlide.wrangler.refactoring.backend.internal.ExpressionPosRpcMessage)4 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)2 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)2 OtpErlangBoolean (com.ericsson.otp.erlang.OtpErlangBoolean)1 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 Shell (org.eclipse.swt.widgets.Shell)1