Search in sources :

Example 1 with OtpErlangAtom

use of com.ericsson.otp.erlang.OtpErlangAtom in project intellij-elixir by KronicDeth.

the class ElixirMapXValue method computeChild.

@Override
protected void computeChild(XValueChildrenList children, int childIdx) {
    OtpErlangObject key = getValue().keys()[childIdx];
    OtpErlangObject value = getValue().get(key);
    if (ElixirXValuePresentation.hasSymbolKeys(getValue()) && key instanceof OtpErlangAtom) {
        String keyStr = ((OtpErlangAtom) key).atomValue();
        if (!keyStr.equals("__struct__"))
            addNamedChild(children, value, keyStr);
    } else {
        addIndexedChild(children, new ElixirMappingXValue(key, value), childIdx);
    }
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 2 with OtpErlangAtom

use of com.ericsson.otp.erlang.OtpErlangAtom in project intellij-elixir by KronicDeth.

the class Import method keywordKeyToName.

@Nullable
private static String keywordKeyToName(@NotNull final Quotable keywordKey) {
    OtpErlangObject quotedKeywordKey = keywordKey.quote();
    String name = null;
    if (quotedKeywordKey instanceof OtpErlangAtom) {
        OtpErlangAtom keywordKeyAtom = (OtpErlangAtom) quotedKeywordKey;
        name = keywordKeyAtom.atomValue();
    }
    return name;
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with OtpErlangAtom

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

the class DialyzerUtils method processResult.

private static void processResult(final IOtpRpc backend, final OtpErlangObject o) throws DialyzerErrorException {
    if (o instanceof OtpErlangTuple) {
        final OtpErlangTuple t = (OtpErlangTuple) o;
        final OtpErlangAtom whatA = (OtpErlangAtom) t.elementAt(0);
        final String what = whatA.toString();
        final OtpErlangObject result = t.elementAt(1);
        if ("warnings".equals(what)) {
            DialyzerMarkerUtils.addDialyzerWarningMarkersFromResultList(backend, (OtpErlangList) result);
        } else if ("dialyzer_error".equals(what) || "badrpc".equals(what)) {
            final String s = Util.ioListToString(result, DialyzerUtils.MAX_MSG_LEN);
            throw new DialyzerErrorException(s);
        }
    } else {
        throw new DialyzerErrorException("Unknown Dialyzer message: " + Util.ioListToString(o, DialyzerUtils.MAX_MSG_LEN));
    }
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 4 with OtpErlangAtom

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

the class CoverRunner method runTests.

// performs tests
private void runTests(final IConfiguration config) throws RpcException {
    // clear viewer
    TestTreeModel.getInstance().clear();
    for (final IEUnitObserver obs : CoverBackend.getInstance().getEUnitListeners()) {
        obs.treeChanged();
        obs.labelChanged();
    }
    // test
    CoverBackend.getInstance().getBackend().getOtpRpc().call(TestConstants.TEST_ERL_BACKEND, TestConstants.FUN_START, "x", new OtpErlangAtom(CoverBackend.getInstance().getSettings().getFramework()));
    ErlLogger.info(config.getProject().getWorkspaceProject().getLocation().toPortableString());
    final IPath ppath = config.getProject().getWorkspaceProject().getLocation();
    ErlLogger.info(ppath.append(config.getOutputDir()).toPortableString());
    CoverBackend.getInstance().getBackend().getOtpRpc().call(TestConstants.TEST_ERL_BACKEND, TestConstants.FUN_OUTPUT_DIR, "s", ppath.append(config.getOutputDir()).toString());
    switch(CoverBackend.getInstance().getSettings().getType()) {
        case MODULE:
            ErlLogger.info(config.getModules().iterator().next().getFilePath());
            CoverBackend.getInstance().getBackend().getOtpRpc().call(TestConstants.TEST_ERL_BACKEND, TestConstants.FUN_TEST, "ss", CoverBackend.getInstance().getSettings().getType().name().toLowerCase(), config.getModules().iterator().next().getFilePath());
            break;
        case ALL:
            final List<String> testDirs = new ArrayList<>();
            for (final IPath p : config.getSourceDirs()) {
                ErlLogger.info(p.toPortableString());
                if (!p.toString().endsWith("test")) {
                    testDirs.add(ppath.append(p).append("test").toString());
                }
            }
            testDirs.add(ppath.append("test").toString());
            for (final String path : testDirs) {
                ErlLogger.info(path);
                CoverBackend.getInstance().getBackend().getOtpRpc().call(TestConstants.TEST_ERL_BACKEND, TestConstants.FUN_TEST, "ss", CoverBackend.getInstance().getSettings().getType().name().toLowerCase(), path);
            }
            break;
        default:
            break;
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 5 with OtpErlangAtom

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

the class CoveragePerformer method startCover.

/**
 * Start cover
 */
@Override
public synchronized void startCover(final Collection<String> nodes) throws CoverException {
    final StatsTreeModel model = StatsTreeModel.getInstance();
    model.clear();
    if (CoverBackend.getInstance().getAnnotationMaker() != null) {
        CoverBackend.getInstance().getAnnotationMaker().clearAllAnnotations();
    }
    for (final ICoverObserver obs : CoverBackend.getInstance().getListeners()) {
        obs.eventOccured(new CoverEvent(CoverStatus.UPDATE));
    }
    boolean different = false;
    for (final String node : nodes) {
        if (!coverNodes.contains(node)) {
            different = true;
            break;
        }
    }
    if (coverNodes.isEmpty() || different) {
        coverNodes = nodes;
        log.info(CoverBackend.getInstance().getBackend().getName());
        coverNodes.add(CoverBackend.getInstance().getBackend().getName());
        // TODO restarting
        final List<OtpErlangObject> names = new ArrayList<>(coverNodes.size());
        for (final String name : coverNodes) {
            names.add(new OtpErlangAtom(name));
        }
        final OtpErlangList nodesList = new OtpErlangList(names.toArray(new OtpErlangObject[0]));
        try {
            CoverBackend.getInstance().getBackend().getOtpRpc().call(CoverConstants.COVER_ERL_BACKEND, CoverConstants.FUN_START, "x", nodesList);
        } catch (final RpcException e) {
            ErlLogger.error(e);
            throw new CoverException(e.getMessage());
        }
    }
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) CoverException(org.erlide.cover.api.CoverException) RpcException(org.erlide.runtime.rpc.RpcException) ArrayList(java.util.ArrayList) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) StatsTreeModel(org.erlide.cover.views.model.StatsTreeModel)

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