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);
}
}
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));
}
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);
}
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);
}
}
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);
}
}
Aggregations