Search in sources :

Example 41 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString 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)

Example 42 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.

the class StateDataToRecordRpcMessage method parseRefactoringMessage.

@Override
protected void parseRefactoringMessage(final OtpErlangTuple resultTuple) throws WranglerException {
    final OtpErlangObject wranglerResult = resultTuple.elementAt(1);
    if (!"ok".equals(resultTuple.elementAt(0).toString())) {
        final OtpErlangString msg = (OtpErlangString) wranglerResult;
        setUnsuccessful(msg.stringValue());
    } else {
        if ("non_tuple".equals(wranglerResult.toString())) {
            fieldCount = 1;
        } else {
            try {
                fieldCount = ((OtpErlangLong) ((OtpErlangTuple) wranglerResult).elementAt(1)).intValue();
            } catch (final OtpErlangRangeException e) {
                throw new WranglerException(e.getMessage());
            }
        }
        stateFuns = resultTuple.elementAt(2);
        setSuccessful();
    }
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) WranglerException(org.erlide.wrangler.refactoring.exception.WranglerException) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 43 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.

the class ErlModule method getIncludeFiles.

@Override
public Collection<ErlangIncludeFile> getIncludeFiles() throws ErlModelException {
    if (!isStructureKnown()) {
        open(null);
    }
    final List<ErlangIncludeFile> r = Lists.newArrayList();
    synchronized (getModelLock()) {
        for (final IErlElement m : internalGetChildren()) {
            if (m instanceof IErlAttribute) {
                final IErlAttribute a = (IErlAttribute) m;
                final OtpErlangObject v = a.getValue();
                if (v instanceof OtpErlangString) {
                    final String s = ((OtpErlangString) v).stringValue();
                    if ("include".equals(a.getName())) {
                        r.add(new ErlangIncludeFile(false, s));
                    } else if ("include_lib".equals(a.getName())) {
                        r.add(new ErlangIncludeFile(true, s));
                    }
                }
            }
        }
    }
    return r;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) ErlangIncludeFile(org.erlide.engine.model.erlang.ErlangIncludeFile) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) IErlAttribute(org.erlide.engine.model.erlang.IErlAttribute) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 44 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.

the class ErlOtpExternalReferenceEntryList method mkOtpStructureMap.

private void mkOtpStructureMap(final OtpErlangList input) {
    if (input == null) {
        return;
    }
    for (final OtpErlangObject o : input) {
        final OtpErlangTuple t = (OtpErlangTuple) o;
        final String lib = ((OtpErlangString) t.elementAt(0)).stringValue();
        final OtpErlangList dirs = (OtpErlangList) t.elementAt(1);
        final String group = OtpErlang.asString(t.elementAt(2));
        final ErlExternalReferenceEntry extLib = new ErlExternalReferenceEntry(this, getLibName(lib), new Path(lib), true, false);
        extLib.setGroup(group);
        addChild(extLib);
        for (final OtpErlangObject dir : dirs.elements()) {
            final OtpErlangTuple tdir = (OtpErlangTuple) dir;
            final String dname = ((OtpErlangString) tdir.elementAt(0)).stringValue();
            final OtpErlangList files = (OtpErlangList) tdir.elementAt(1);
            final ErlExternalReferenceEntry subdir = new ErlExternalReferenceEntry(extLib, getLibName(dname), new Path(dname), true, includePath(dname));
            extLib.addChild(subdir);
            for (final OtpErlangObject fn : files.elements()) {
                final String sfn = ((OtpErlangString) fn).stringValue();
                final IErlModule ext = new ErlModule(subdir, getModuleName(sfn), sfn, Charsets.ISO_8859_1, null);
                subdir.addChild(ext);
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IErlModule(org.erlide.engine.model.root.IErlModule) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) IErlModule(org.erlide.engine.model.root.IErlModule) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 45 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.

the class ErlangCompletionService method getModules0.

List<String> getModules0(final IOtpRpc backend, final int offset, final String prefix, final CompletionFlag kind) throws ErlModelException {
    final List<String> result = Lists.newArrayList();
    final boolean includes = kind == CompletionFlag.INCLUDES || kind == CompletionFlag.INCLUDE_LIBS;
    final List<String> names = ErlangEngine.getInstance().getModelUtilService().findUnitsWithPrefix(prefix, project, kind != CompletionFlag.INCLUDES, includes);
    final OtpErlangObject res = ErlangEngine.getInstance().getOtpDocService().getModules(backend, prefix, names, includes);
    if (res instanceof OtpErlangList) {
        final OtpErlangList resList = (OtpErlangList) res;
        for (final OtpErlangObject o : resList) {
            if (o instanceof OtpErlangString) {
                final OtpErlangString s = (OtpErlangString) o;
                result.add(s.stringValue());
            }
        }
    }
    return result;
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Aggregations

OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)56 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)36 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)31 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)22 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)15 ArrayList (java.util.ArrayList)9 RpcResult (org.erlide.runtime.rpc.RpcResult)8 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)7 RpcException (org.erlide.runtime.rpc.RpcException)7 Test (org.junit.Test)7 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)6 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)5 IPath (org.eclipse.core.runtime.IPath)5 ErlModelException (org.erlide.engine.model.ErlModelException)5 IErlElement (org.erlide.engine.model.IErlElement)5 WranglerRpcParsingException (org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)5 IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)5 CoreException (org.eclipse.core.runtime.CoreException)4 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)4 Map (java.util.Map)3