Search in sources :

Example 81 with OtpErlangAtom

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

the class WranglerRefactoringBackend method callSimpleInspection.

/**
 * Call inspection function which returns with boolean values
 *
 * @param functionName
 *            function to call
 * @param signature
 *            signature
 * @param parameters
 *            parameters
 * @return true if the call was successful, else false
 */
public boolean callSimpleInspection(final String functionName, final String signature, final Object... parameters) {
    ErlLogger.info("Wrangler inspection call: " + makeLogStr(functionName, parameters));
    RpcResult res;
    res = backend.call_noexception(WranglerRefactoringBackend.UNLIMITED_TIMEOUT, WranglerRefactoringBackend.INSPECTION_MODULE, functionName, signature, parameters);
    try {
        if (res.isOk()) {
            final OtpErlangAtom b = (OtpErlangAtom) res.getValue();
            return "true".equals(b.atomValue()) || "ok".equals(b.atomValue());
        }
    } catch (final Exception e) {
        ErlLogger.error(e);
    }
    return false;
}
Also used : RpcResult(org.erlide.runtime.rpc.RpcResult) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 82 with OtpErlangAtom

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

the class WranglerSyntaxBackend method parseVarInfo.

private SyntaxInfo parseVarInfo(final OtpErlangObject value) {
    try {
        final OtpErlangTuple result = (OtpErlangTuple) value;
        if (!"ok".equals(((OtpErlangAtom) result.elementAt(0)).atomValue())) {
            return new SyntaxInfo(Type.NONE, -1, -1);
        }
        SyntaxInfo ret;
        final OtpErlangTuple res = (OtpErlangTuple) result.elementAt(1);
        final OtpErlangTuple position = (OtpErlangTuple) ((OtpErlangList) res.elementAt(1)).elementAt(0);
        OtpErlangLong line;
        OtpErlangLong col;
        line = (OtpErlangLong) position.elementAt(0);
        col = (OtpErlangLong) position.elementAt(0);
        ret = new SyntaxInfo(Type.VARIABLE, line.intValue(), col.intValue());
        return ret;
    } catch (final Exception e) {
        ErlLogger.debug(e);
        return null;
    }
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 83 with OtpErlangAtom

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

the class ModelInternalUtils method getImportsAsList.

@Override
public List<OtpErlangObject> getImportsAsList(final IErlModule mod) {
    if (mod == null) {
        return ModelInternalUtils.NO_IMPORTS;
    }
    final Collection<IErlImport> imports = mod.getImports();
    if (imports.isEmpty()) {
        return ModelInternalUtils.NO_IMPORTS;
    }
    final List<OtpErlangObject> result = new ArrayList<>(imports.size());
    for (final IErlImport i : imports) {
        final Collection<ErlangFunction> functions = i.getFunctions();
        final OtpErlangObject[] funsT = new OtpErlangObject[functions.size()];
        int j = 0;
        for (final ErlangFunction f : functions) {
            funsT[j] = f.getNameArityTuple();
            j++;
        }
        final OtpErlangTuple modFunsT = new OtpErlangTuple(new OtpErlangObject[] { new OtpErlangAtom(i.getImportModule()), new OtpErlangList(funsT) });
        result.add(modFunsT);
    }
    return result;
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ArrayList(java.util.ArrayList) ErlangFunction(org.erlide.engine.model.erlang.ErlangFunction) IErlImport(org.erlide.engine.model.erlang.IErlImport) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 84 with OtpErlangAtom

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

the class PatternMatchTest method testMatch_0.

@Test
public void testMatch_0() throws Exception {
    final OtpBindings b = new OtpBindings();
    b.put("W", new OtpErlangAtom("a"));
    final OtpBindings r = OtpErlang.match("[W, V]", "[a, b]", b);
    Assert.assertNotNull(r);
    Assert.assertEquals(r.get("V"), new OtpErlangAtom("b"));
}
Also used : OtpBindings(org.erlide.util.erlang.OtpBindings) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) Test(org.junit.Test)

Example 85 with OtpErlangAtom

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

the class TermParserTest method atom_2.

@Test
public void atom_2() throws OtpParserException {
    final OtpErlangAtom r = (OtpErlangAtom) termParser.parse("hello   ");
    Assert.assertEquals(r.atomValue(), "hello");
}
Also used : OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) Test(org.junit.Test)

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)16 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