Search in sources :

Example 1 with ErlangFunction

use of org.erlide.engine.model.erlang.ErlangFunction in project erlide_eclipse by erlang.

the class ErlangProcess method addStackTrace.

private void addStackTrace(final OtpErlangTuple savedStackTrace) {
    try {
        final OtpBindings bind = OtpErlang.match("{saved_stacktrace, _,STrace}", savedStackTrace);
        if (bind != null) {
            final Collection<OtpErlangObject> trace = bind.getList("STrace");
            for (final OtpErlangObject oframe : trace) {
                final OtpErlangTuple frame = (OtpErlangTuple) oframe;
                final OtpErlangAtom m = (OtpErlangAtom) frame.elementAt(0);
                final OtpErlangAtom f = (OtpErlangAtom) frame.elementAt(1);
                final OtpErlangLong a = (OtpErlangLong) frame.elementAt(2);
                try {
                    stackFrames.add(new ErlangUninterpretedStackFrame(m.atomValue(), new ErlangFunction(f.atomValue(), a.intValue()), this, getDebugTarget()));
                } catch (final OtpErlangRangeException e) {
                    ErlLogger.error(e);
                }
            }
        }
    } catch (final OtpParserException e1) {
        // ignore
        ErlLogger.error(e1);
    } catch (final OtpErlangException e1) {
        ErlLogger.error(e1);
    }
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpParserException(org.erlide.util.erlang.OtpParserException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangException(com.ericsson.otp.erlang.OtpErlangException) OtpBindings(org.erlide.util.erlang.OtpBindings) ErlangFunction(org.erlide.engine.model.erlang.ErlangFunction) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 2 with ErlangFunction

use of org.erlide.engine.model.erlang.ErlangFunction in project erlide_eclipse by erlang.

the class ErlModel method findFunction.

@Override
public IErlFunction findFunction(final FunctionRef r) throws ErlModelException {
    final IErlModule module = findModule(r.module);
    if (module == null) {
        return null;
    }
    module.open(null);
    return module.findFunction(new ErlangFunction(r.function, r.arity));
}
Also used : IErlModule(org.erlide.engine.model.root.IErlModule) ErlangFunction(org.erlide.engine.model.erlang.ErlangFunction)

Example 3 with ErlangFunction

use of org.erlide.engine.model.erlang.ErlangFunction in project erlide_eclipse by erlang.

the class ModelUtilsTest method findExternalFunctionModuleTest.

@Test
public void findExternalFunctionModuleTest() throws Exception {
    // given
    // a module with functions and functions
    final IErlModule moduleD = ErlideTestUtils.createModule(ModelUtilsTest.projects[0], "d.erl", "-module(d).\n-export([f/0]).\nf() ->\n    ok.\ng() ->\n    ?MODULE:f().\n");
    moduleD.open(null);
    // when
    // looking for it with ?MODULE
    final IErlElementLocator model = ErlangEngine.getInstance().getModel();
    final IErlElement element1 = modelFindService.findFunction(model, ModelUtilsTest.projects[0], moduleD, "?MODULE", null, new ErlangFunction("f", 0), IErlElementLocator.Scope.PROJECT_ONLY);
    // then
    // it should be found
    assertTrue(element1 instanceof IErlFunction);
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlFunction(org.erlide.engine.model.erlang.IErlFunction) IErlModule(org.erlide.engine.model.root.IErlModule) ErlangFunction(org.erlide.engine.model.erlang.ErlangFunction) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) Test(org.junit.Test)

Example 4 with ErlangFunction

use of org.erlide.engine.model.erlang.ErlangFunction in project erlide_eclipse by erlang.

the class ErlangSearchTreeContentProvider method addElement.

private void addElement(final ErlangSearchElement ese) {
    final String moduleName = ese.getModuleName();
    if (!moduleNames.contains(moduleName)) {
        moduleNames.add(moduleName);
    }
    if (ese.isSubClause()) {
        final ErlangFunction function = new ErlangFunction(ese.getName(), ese.getArity());
        addChild(moduleName, function);
        addChild(function, ese);
    } else {
        addChild(moduleName, ese);
    }
}
Also used : ErlangFunction(org.erlide.engine.model.erlang.ErlangFunction)

Example 5 with ErlangFunction

use of org.erlide.engine.model.erlang.ErlangFunction in project erlide_eclipse by erlang.

the class ErlangSearchTreeContentProvider method removeElement.

private void removeElement(final ErlangSearchElement ese) {
    final String moduleName = ese.getModuleName();
    if (ese.isSubClause()) {
        final ErlangFunction function = new ErlangFunction(ese.getName(), ese.getArity());
        removeChild(moduleName, function);
        removeChild(function, ese);
    } else {
        removeChild(moduleName, ese);
    }
    final List<Object> moduleChildren = childMap.get(moduleName);
    if (moduleChildren == null && moduleNames.contains(moduleName)) {
        moduleNames.remove(moduleName);
    }
}
Also used : ErlangFunction(org.erlide.engine.model.erlang.ErlangFunction)

Aggregations

ErlangFunction (org.erlide.engine.model.erlang.ErlangFunction)9 IErlFunction (org.erlide.engine.model.erlang.IErlFunction)4 IErlModule (org.erlide.engine.model.root.IErlModule)4 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)2 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)2 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)2 ErlModelException (org.erlide.engine.model.ErlModelException)2 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)2 OtpErlangException (com.ericsson.otp.erlang.OtpErlangException)1 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 ArrayList (java.util.ArrayList)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)1 IEditorPart (org.eclipse.ui.IEditorPart)1 FunctionStats (org.erlide.cover.views.model.FunctionStats)1 StatsTreeObject (org.erlide.cover.views.model.StatsTreeObject)1