Search in sources :

Example 6 with OtpParserException

use of org.erlide.util.erlang.OtpParserException in project erlide_eclipse by erlang.

the class TestCaseData method parseReason.

private FailReason parseReason(final OtpErlangObject reason) {
    OtpBindings b;
    try {
        b = OtpErlang.match("{Cause, Stack}", reason);
        if (b == null) {
            return new FailReason("internal error: " + reason.toString(), TestCaseData.NO_STACK);
        }
        final Collection<OtpErlangObject> stack = b.getList("Stack");
        return new FailReason(b.get("Cause").toString(), stack);
    } catch (final OtpParserException e) {
        ErlLogger.warn(e);
    } catch (final OtpErlangException e) {
        ErlLogger.warn(e);
    }
    return null;
}
Also used : OtpParserException(org.erlide.util.erlang.OtpParserException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangException(com.ericsson.otp.erlang.OtpErlangException) OtpBindings(org.erlide.util.erlang.OtpBindings)

Example 7 with OtpParserException

use of org.erlide.util.erlang.OtpParserException in project erlide_eclipse by erlang.

the class CompilerOptions method export.

@SuppressWarnings("unchecked")
public OtpErlangList export() {
    final List<OtpErlangObject> result = new ArrayList<>();
    for (final CompilerOption option : ALL_OPTIONS) {
        final Object optionValue = options.get(option);
        if (optionValue != null) {
            if (option instanceof BooleanOption) {
                final OtpErlangObject val = ((BooleanOption) option).toTerm((Boolean) optionValue);
                if (val != null) {
                    result.add(val);
                }
            } else if (option instanceof PathsOption) {
                final Iterable<String> value = (Iterable<String>) optionValue;
                final OtpErlangList val = (OtpErlangList) ((PathsOption) option).toTerm(value);
                for (final OtpErlangObject inc : val.elements()) {
                    result.add(inc);
                }
            } else if (option instanceof ModuleOption) {
                final String value = (String) optionValue;
                final OtpErlangObject val = ((ModuleOption) option).toTerm(value);
                result.add(val);
            } else if (option instanceof RawOption) {
                final String value = (String) optionValue;
                final OtpErlangList val = (OtpErlangList) ((RawOption) option).toTerm(value);
                for (final OtpErlangObject item : val.elements()) {
                    result.add(item);
                }
            } else {
                try {
                    final OtpErlangList val = ((DefineOption) option).toTerm((List<Pair<String, String>>) optionValue);
                    if (val != null) {
                        result.addAll(Lists.newArrayList(val.elements()));
                    }
                } catch (final OtpParserException e) {
                    ErlLogger.warn(e);
                }
            }
        }
    }
    final OtpErlangList list = OtpErlang.mkList(result);
    return list;
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpParserException(org.erlide.util.erlang.OtpParserException) PathsOption(org.erlide.core.builder.CompilerOption.PathsOption) ArrayList(java.util.ArrayList) RawOption(org.erlide.core.builder.CompilerOption.RawOption) ModuleOption(org.erlide.core.builder.CompilerOption.ModuleOption) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ArrayList(java.util.ArrayList) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) List(java.util.List) BooleanOption(org.erlide.core.builder.CompilerOption.BooleanOption)

Example 8 with OtpParserException

use of org.erlide.util.erlang.OtpParserException in project erlide_eclipse by erlang.

the class ErlideDebug method setVariableValue.

@SuppressWarnings("boxing")
public static String setVariableValue(final IOtpRpc backend, final String name, final String value, final int stackFrameNo, final OtpErlangPid meta) {
    try {
        final OtpErlangObject res = backend.call(ErlideDebug.ERLIDE_DEBUG, "set_variable_value", "ssix", name, value, stackFrameNo + 1, meta);
        try {
            final OtpBindings bind = OtpErlang.match("{eval_rsp, {'EXIT', Val}}", res);
            if (bind == null) {
                return null;
            }
            final String err = bind.getAsString("Val");
            return err;
        } catch (final OtpParserException e1) {
        }
        return null;
    } catch (final RpcException e) {
        ErlLogger.warn(e);
    }
    return "error";
}
Also used : OtpParserException(org.erlide.util.erlang.OtpParserException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpBindings(org.erlide.util.erlang.OtpBindings) RpcException(org.erlide.runtime.rpc.RpcException)

Aggregations

OtpParserException (org.erlide.util.erlang.OtpParserException)8 OtpBindings (org.erlide.util.erlang.OtpBindings)6 OtpErlangException (com.ericsson.otp.erlang.OtpErlangException)5 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)5 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)2 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)2 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)2 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 IPath (org.eclipse.core.runtime.IPath)1 BooleanOption (org.erlide.core.builder.CompilerOption.BooleanOption)1 ModuleOption (org.erlide.core.builder.CompilerOption.ModuleOption)1 PathsOption (org.erlide.core.builder.CompilerOption.PathsOption)1 RawOption (org.erlide.core.builder.CompilerOption.RawOption)1 ErlangFunction (org.erlide.engine.model.erlang.ErlangFunction)1 ErlangProjectProperties (org.erlide.engine.model.root.ErlangProjectProperties)1