Search in sources :

Example 26 with OtpErlangAtom

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

the class ErlideXref method modules.

public static List<String> modules(final IOtpRpc backend) {
    final List<String> result = new ArrayList<>();
    try {
        final OtpErlangObject res = backend.call(ErlideXref.ERLIDE_XREF, "modules", "");
        if (Util.isOk(res)) {
            final OtpErlangTuple t = (OtpErlangTuple) res;
            final OtpErlangList l = (OtpErlangList) t.elementAt(1);
            for (final OtpErlangObject i : l) {
                if (i instanceof OtpErlangAtom) {
                    final OtpErlangAtom m = (OtpErlangAtom) i;
                    result.add(m.atomValue());
                }
            }
        }
    } catch (final RpcException e) {
        ErlLogger.error(e);
    }
    return result;
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) ArrayList(java.util.ArrayList) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 27 with OtpErlangAtom

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

the class ErlideIndent method fixIndentPrefs.

private List<OtpErlangTuple> fixIndentPrefs(final Map<String, String> m) {
    final List<OtpErlangTuple> result = new ArrayList<>(m.size());
    for (final Map.Entry<String, String> e : m.entrySet()) {
        final OtpErlangAtom a = new OtpErlangAtom(e.getKey());
        final String s = e.getValue();
        int n;
        if ("false".equals(s)) {
            n = 0;
        } else if ("true".equals(s)) {
            n = 1;
        } else {
            n = Integer.parseInt(s);
        }
        final OtpErlangLong l = new OtpErlangLong(n);
        final OtpErlangTuple t = new OtpErlangTuple(new OtpErlangObject[] { a, l });
        result.add(t);
    }
    return result;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) ArrayList(java.util.ArrayList) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) Map(java.util.Map)

Example 28 with OtpErlangAtom

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

the class ModelInternalUtils method addUnitNamesWithPrefix.

private void addUnitNamesWithPrefix(final String prefix, final List<String> result, final Collection<IErlModule> modules, final boolean external, final boolean includes) {
    for (final IErlModule module : modules) {
        String moduleName = includes ? module.getName() : module.getModuleName();
        if (external && includes) {
            moduleName = getIncludeLibPath(module);
        }
        boolean nameMatches = moduleName.startsWith(prefix);
        if (!nameMatches && prefix.startsWith("'")) {
            nameMatches = moduleName.startsWith(prefix.substring(1));
        }
        if (nameMatches && (includes || !module.getName().endsWith(".hrl"))) {
            if (!result.contains(moduleName)) {
                final String name = new OtpErlangAtom(moduleName).toString();
                result.add(name);
            }
        }
    }
}
Also used : IErlModule(org.erlide.engine.model.root.IErlModule) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 29 with OtpErlangAtom

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

the class IOServer method handleMessage.

private void handleMessage(final OtpErlangObject msg) {
    final OtpErlangTuple tuple = (OtpErlangTuple) msg;
    final String tag = ((OtpErlangAtom) tuple.elementAt(0)).atomValue();
    if ("io_request".equals(tag)) {
        final OtpErlangPid from = (OtpErlangPid) tuple.elementAt(1);
        final OtpErlangObject replyAs = tuple.elementAt(2);
        final OtpErlangTuple request = (OtpErlangTuple) tuple.elementAt(3);
        final OtpErlangObject reply = processRequest(from, request);
        final OtpErlangTuple replyMsg = OtpErlang.mkTuple(new OtpErlangAtom("io_reply"), replyAs, reply);
        mbox.send(from, replyMsg);
    } else {
        ErlLogger.warn("IOServer: unknown message " + msg);
    }
}
Also used : OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 30 with OtpErlangAtom

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

the class OtpRpc method buildRpcCastMsg.

private OtpErlangObject buildRpcCastMsg(final OtpErlangObject gleader, final String module, final String fun, final OtpErlangObject[] args) {
    final OtpErlangObject m = new OtpErlangAtom(module);
    final OtpErlangObject f = new OtpErlangAtom(fun);
    final OtpErlangObject a = new OtpErlangList(args);
    final OtpErlangAtom castTag = new OtpErlangAtom("$gen_cast");
    return OtpErlang.mkTuple(castTag, OtpErlang.mkTuple(new OtpErlangAtom("cast"), m, f, a, gleader));
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Aggregations

OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)87 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)56 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)48 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)32 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)24 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)17 ArrayList (java.util.ArrayList)15 Test (org.junit.Test)14 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)11 RpcException (org.erlide.runtime.rpc.RpcException)11 OtpBindings (org.erlide.util.erlang.OtpBindings)9 IErlElement (org.erlide.engine.model.IErlElement)6 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)4 OtpErlangPid (com.ericsson.otp.erlang.OtpErlangPid)4 IErlModule (org.erlide.engine.model.root.IErlModule)4 OtpErlangInt (com.ericsson.otp.erlang.OtpErlangInt)3 OtpErlangMap (com.ericsson.otp.erlang.OtpErlangMap)3 Subscribe (com.google.common.eventbus.Subscribe)3 Collection (java.util.Collection)3 OtpErlangException (com.ericsson.otp.erlang.OtpErlangException)2