Search in sources :

Example 16 with IErlMemberSelection

use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection 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 17 with IErlMemberSelection

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

the class MergeLetRefactoring 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_let_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 18 with IErlMemberSelection

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

the class QuickCheckStateRefactoring method checkInitialConditions.

@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
    // FIXME: what kind of preconditions do I need?
    final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
    final StateDataToRecordRpcMessage message = runFirst(sel);
    if (!message.isSuccessful()) {
        return RefactoringStatus.createFatalErrorStatus(message.getMessageString());
    }
    fieldCount = message.getFieldCount();
    stateFuns = message.getStateFuns();
    return new RefactoringStatus();
}
Also used : StateDataToRecordRpcMessage(org.erlide.wrangler.refactoring.backend.internal.StateDataToRecordRpcMessage) IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus)

Example 19 with IErlMemberSelection

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

the class RenameFunctionRefactoring method run.

@Override
public IRefactoringRpcMessage run(final IErlSelection selection) {
    final IErlMemberSelection sel = (IErlMemberSelection) selection;
    final IErlRange memberRange = sel.getSelectionRange();
    return WranglerBackendManager.getRefactoringBackend().call("rename_fun_eclipse", "siisxi", sel.getFilePath(), memberRange.getStartLine(), memberRange.getStartCol(), userInput, sel.getSearchPath(), GlobalParameters.getTabWidth());
}
Also used : IErlRange(org.erlide.wrangler.refactoring.util.IErlRange) IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection)

Aggregations

IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)19 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)6 RpcResult (org.erlide.runtime.rpc.RpcResult)6 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)5 IErlSelection (org.erlide.wrangler.refactoring.selection.IErlSelection)5 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)4 ExpressionPosRpcMessage (org.erlide.wrangler.refactoring.backend.internal.ExpressionPosRpcMessage)4 WranglerRefactoringBackend (org.erlide.wrangler.refactoring.backend.internal.WranglerRefactoringBackend)4 WranglerRpcParsingException (org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)4 IErlRange (org.erlide.wrangler.refactoring.util.IErlRange)4 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)2 CostumWorkflowRefactoringWithPositionsSelection (org.erlide.wrangler.refactoring.core.CostumWorkflowRefactoringWithPositionsSelection)2 WranglerRefactoring (org.erlide.wrangler.refactoring.core.WranglerRefactoring)2 SelectionInputPage (org.erlide.wrangler.refactoring.ui.wizardpages.SelectionInputPage)2 OtpErlangException (com.ericsson.otp.erlang.OtpErlangException)1 OtpErlangFloat (com.ericsson.otp.erlang.OtpErlangFloat)1 OtpErlangInt (com.ericsson.otp.erlang.OtpErlangInt)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 ArrayList (java.util.ArrayList)1