Search in sources :

Example 46 with OtpErlangString

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

the class ErlideOpen method mkContext.

@Override
public OtpErlangTuple mkContext(final String externalModules, final String externalIncludes, final OtpErlangList pathVars, final Collection<IPath> extraSourcePaths, final Collection<OtpErlangObject> imports) {
    final OtpErlangAtom tag = new OtpErlangAtom("open_context");
    final OtpErlangAtom UNDEFINED = new OtpErlangAtom("undefined");
    final List<OtpErlangObject> result = Lists.newArrayList();
    // order must match definition of #open_context !
    // TODO use a proplist instead?
    result.add(tag);
    result.add(externalModules != null ? new OtpErlangString(externalModules) : UNDEFINED);
    result.add(externalIncludes != null ? new OtpErlangString(externalIncludes) : UNDEFINED);
    result.add(pathVars != null ? pathVars : UNDEFINED);
    result.add(extraSourcePaths != null ? OtpErlang.mkStringList(extraSourcePaths) : UNDEFINED);
    result.add(imports != null ? OtpErlang.mkList(imports) : UNDEFINED);
    return new OtpErlangTuple(result.toArray(new OtpErlangObject[] {}));
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 47 with OtpErlangString

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

the class TraceDataHandler method processFileInfo.

private ITreeNode processFileInfo(final OtpErlangTuple tuple) {
    TracingResultsNode node = null;
    if (tuple.elementAt(TraceDataHandler.INDEX_INFO_START_DATE) instanceof OtpErlangAtom) {
        // file contains no trace events
        return null;
    }
    try {
        final Date from = readDateTuple((OtpErlangTuple) tuple.elementAt(TraceDataHandler.INDEX_INFO_START_DATE));
        final Date to = readDateTuple((OtpErlangTuple) tuple.elementAt(TraceDataHandler.INDEX_INFO_END_DATE));
        final String path = ((OtpErlangString) tuple.elementAt(TraceDataHandler.INDEX_INFO_PATH)).stringValue();
        final long size = ((OtpErlangLong) tuple.elementAt(TraceDataHandler.INDEX_INFO_COUNT)).longValue();
        node = new TracingResultsNode();
        node.setStartDate(from);
        node.setEndDate(to);
        node.setFileName(path);
        node.setSize(size);
        // node label
        String builder = infoDateFormatter.format(from) + " - " + infoDateFormatter.format(to) + " (" + size + " traces): " + path;
        node.setLabel(builder);
    } catch (final OtpErlangRangeException e) {
        ErlLogger.error(e);
    }
    return node;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) TracingResultsNode(org.erlide.tracing.core.mvc.model.treenodes.TracingResultsNode) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Date(java.util.Date) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 48 with OtpErlangString

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

the class TraceBackend method loadFile.

/**
 * Loads information about given file.
 *
 * @param path
 *            path
 */
public void loadFile(final String path) {
    if (!tracing && !loading) {
        synchronized (this) {
            if (!tracing && !loading) {
                try {
                    loading = true;
                    loadingFileInfo = true;
                    handler = new TraceEventHandler();
                    getBackend(true);
                    tracerBackend.getRuntime().registerEventListener(handler);
                    tracerBackend.getOtpRpc().call(Constants.ERLANG_HELPER_MODULE, TraceBackend.FUN_FILE_INFO, "s", new OtpErlangString(path));
                } catch (final RpcException e) {
                    ErlLogger.error(e);
                    errorObject = e;
                    finishLoading(TracingStatus.EXCEPTION_THROWN);
                }
            }
        }
    }
}
Also used : RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 49 with OtpErlangString

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

the class TermParserTest method string_1.

@Test
public void string_1() throws OtpParserException {
    final OtpErlangString r = (OtpErlangString) termParser.parse("\"Hello\"");
    Assert.assertEquals(r.stringValue(), "Hello");
}
Also used : OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Test(org.junit.Test)

Example 50 with OtpErlangString

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

the class UtilTest method testIoListToString_large2.

@Test
public void testIoListToString_large2() {
    final OtpErlangObject input = OtpErlang.mkList(new OtpErlangString("hej"), new OtpErlangString("hoj"));
    final String result = Util.ioListToString(input, 6);
    final String expected = "hejhoj";
    Assert.assertEquals(expected, result);
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Test(org.junit.Test)

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