Search in sources :

Example 6 with WranglerRpcParsingException

use of org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException in project erlide_eclipse by erlang.

the class RefactoringRpcMessage method parseRefactoringMessage.

@Override
protected void parseRefactoringMessage(final OtpErlangTuple tuple) throws WranglerRpcParsingException {
    resultTuple = tuple;
    final OtpErlangObject wranglerResult = tuple.elementAt(1);
    if ("ok".equals(tuple.elementAt(0).toString())) {
        if (wranglerResult instanceof OtpErlangList) {
            changedFiles = parseFileList((OtpErlangList) wranglerResult);
            setSuccessful();
            return;
        }
    } else {
        final OtpErlangString msg = (OtpErlangString) wranglerResult;
        if ("warning".equals(tuple.elementAt(0).toString())) {
            setWarning(msg.stringValue());
        } else if ("question".equals(tuple.elementAt(0).toString())) {
            setQuestion(msg.stringValue());
        } else {
            setUnsuccessful(msg.stringValue());
        }
        return;
    }
    throw new WranglerRpcParsingException(tuple.toString());
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) WranglerRpcParsingException(org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)

Example 7 with WranglerRpcParsingException

use of org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException in project erlide_eclipse by erlang.

the class ExpressionSearchAction method callRefactoring.

@Override
protected IResultParser callRefactoring() throws WranglerRpcParsingException {
    final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
    final WranglerRefactoringBackend backend = WranglerBackendManager.getRefactoringBackend();
    final RpcResult result = backend.callWithoutParser(WranglerRefactoringBackend.UNLIMITED_TIMEOUT, "expr_search_eclipse", "sxxi", sel.getFilePath(), sel.getSelectionRange().getStartPos(), sel.getSelectionRange().getEndPos(), GlobalParameters.getTabWidth());
    if (result.isOk()) {
        return new ExpressionSearchParser(result.getValue());
    }
    throw new WranglerRpcParsingException("RPC error");
}
Also used : WranglerRefactoringBackend(org.erlide.wrangler.refactoring.backend.internal.WranglerRefactoringBackend) IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) RpcResult(org.erlide.runtime.rpc.RpcResult) WranglerRpcParsingException(org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)

Example 8 with WranglerRpcParsingException

use of org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException in project erlide_eclipse by erlang.

the class GenFunRefactoringMessage method parseRefactoringMessage.

@Override
protected void parseRefactoringMessage(final OtpErlangTuple resultTuple) throws WranglerException {
    final OtpErlangObject wranglerResult = resultTuple.elementAt(1);
    final String state = resultTuple.elementAt(0).toString();
    if ("ok".equals(state)) {
        if (wranglerResult instanceof OtpErlangList) {
            changedFiles = parseFileList((OtpErlangList) wranglerResult);
            setSuccessful();
            return;
        }
    } else if ("error".equals(state)) {
        final OtpErlangString msg = (OtpErlangString) wranglerResult;
        setUnsuccessful(msg.stringValue());
        return;
    } else if ("multiple_instances".equals(state)) {
        parameters = new HashMap<>();
        final OtpErlangTuple pars = (OtpErlangTuple) wranglerResult;
        setState("", RefactoringState.MULTI_INSTANCES);
        parameters.put(GenFunReturnParameterName.parName, pars.elementAt(0));
        parameters.put(GenFunReturnParameterName.funName, pars.elementAt(1));
        parameters.put(GenFunReturnParameterName.arity, pars.elementAt(2));
        parameters.put(GenFunReturnParameterName.funDefPos, pars.elementAt(3));
        parameters.put(GenFunReturnParameterName.exp, pars.elementAt(4));
        parameters.put(GenFunReturnParameterName.sideEffect, pars.elementAt(5));
        parameters.put(GenFunReturnParameterName.dupsInFun, pars.elementAt(6));
        parameters.put(GenFunReturnParameterName.logCmd, pars.elementAt(7));
    } else if ("unknown_side_effect".equals(state)) {
        parameters = new HashMap<>();
        final OtpErlangTuple pars = (OtpErlangTuple) wranglerResult;
        setState("", RefactoringState.UNKNOWN_SIDE_EFFECT);
        parameters.put(GenFunReturnParameterName.parName, pars.elementAt(0));
        parameters.put(GenFunReturnParameterName.funName, pars.elementAt(1));
        parameters.put(GenFunReturnParameterName.arity, pars.elementAt(2));
        parameters.put(GenFunReturnParameterName.funDefPos, pars.elementAt(3));
        parameters.put(GenFunReturnParameterName.exp, pars.elementAt(4));
        parameters.put(GenFunReturnParameterName.noOfClauses, pars.elementAt(5));
        parameters.put(GenFunReturnParameterName.dupsInFun, pars.elementAt(6));
        parameters.put(GenFunReturnParameterName.dupsInClause, pars.elementAt(7));
        parameters.put(GenFunReturnParameterName.logCmd, pars.elementAt(8));
    } else if ("more_than_one_clause".equals(state)) {
        parameters = new HashMap<>();
        final OtpErlangTuple pars = (OtpErlangTuple) wranglerResult;
        setState("", RefactoringState.MORE_THAN_ONE_CLAUSE);
        parameters.put(GenFunReturnParameterName.parName, pars.elementAt(0));
        parameters.put(GenFunReturnParameterName.funName, pars.elementAt(1));
        parameters.put(GenFunReturnParameterName.arity, pars.elementAt(2));
        parameters.put(GenFunReturnParameterName.funDefPos, pars.elementAt(3));
        parameters.put(GenFunReturnParameterName.exp, pars.elementAt(4));
        parameters.put(GenFunReturnParameterName.sideEffect, pars.elementAt(5));
        parameters.put(GenFunReturnParameterName.dupsInFun, pars.elementAt(6));
        parameters.put(GenFunReturnParameterName.dupsInClause, pars.elementAt(7));
        parameters.put(GenFunReturnParameterName.logCmd, pars.elementAt(8));
    } else {
        throw new WranglerRpcParsingException(resultTuple.toString());
    }
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) HashMap(java.util.HashMap) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) WranglerRpcParsingException(org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)

Aggregations

WranglerRpcParsingException (org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)8 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)5 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)5 RpcResult (org.erlide.runtime.rpc.RpcResult)4 WranglerRefactoringBackend (org.erlide.wrangler.refactoring.backend.internal.WranglerRefactoringBackend)4 IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)4 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)3 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)2 OtpErlangFloat (com.ericsson.otp.erlang.OtpErlangFloat)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 WranglerWarningException (org.erlide.wrangler.refactoring.core.exception.WranglerWarningException)1 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)1 ErlRange (org.erlide.wrangler.refactoring.util.ErlRange)1 IErlRange (org.erlide.wrangler.refactoring.util.IErlRange)1 IRange (org.erlide.wrangler.refactoring.util.IRange)1