use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class WranglerRefactoringBackend method callSimpleInspection.
/**
* Call inspection function which returns with boolean values
*
* @param functionName
* function to call
* @param signature
* signature
* @param parameters
* parameters
* @return true if the call was successful, else false
*/
public boolean callSimpleInspection(final String functionName, final String signature, final Object... parameters) {
ErlLogger.info("Wrangler inspection call: " + makeLogStr(functionName, parameters));
RpcResult res;
res = backend.call_noexception(WranglerRefactoringBackend.UNLIMITED_TIMEOUT, WranglerRefactoringBackend.INSPECTION_MODULE, functionName, signature, parameters);
try {
if (res.isOk()) {
final OtpErlangAtom b = (OtpErlangAtom) res.getValue();
return "true".equals(b.atomValue()) || "ok".equals(b.atomValue());
}
} catch (final Exception e) {
ErlLogger.error(e);
}
return false;
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class WranglerSyntaxBackend method parseVarInfo.
private SyntaxInfo parseVarInfo(final OtpErlangObject value) {
try {
final OtpErlangTuple result = (OtpErlangTuple) value;
if (!"ok".equals(((OtpErlangAtom) result.elementAt(0)).atomValue())) {
return new SyntaxInfo(Type.NONE, -1, -1);
}
SyntaxInfo ret;
final OtpErlangTuple res = (OtpErlangTuple) result.elementAt(1);
final OtpErlangTuple position = (OtpErlangTuple) ((OtpErlangList) res.elementAt(1)).elementAt(0);
OtpErlangLong line;
OtpErlangLong col;
line = (OtpErlangLong) position.elementAt(0);
col = (OtpErlangLong) position.elementAt(0);
ret = new SyntaxInfo(Type.VARIABLE, line.intValue(), col.intValue());
return ret;
} catch (final Exception e) {
ErlLogger.debug(e);
return null;
}
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class ModelInternalUtils method getImportsAsList.
@Override
public List<OtpErlangObject> getImportsAsList(final IErlModule mod) {
if (mod == null) {
return ModelInternalUtils.NO_IMPORTS;
}
final Collection<IErlImport> imports = mod.getImports();
if (imports.isEmpty()) {
return ModelInternalUtils.NO_IMPORTS;
}
final List<OtpErlangObject> result = new ArrayList<>(imports.size());
for (final IErlImport i : imports) {
final Collection<ErlangFunction> functions = i.getFunctions();
final OtpErlangObject[] funsT = new OtpErlangObject[functions.size()];
int j = 0;
for (final ErlangFunction f : functions) {
funsT[j] = f.getNameArityTuple();
j++;
}
final OtpErlangTuple modFunsT = new OtpErlangTuple(new OtpErlangObject[] { new OtpErlangAtom(i.getImportModule()), new OtpErlangList(funsT) });
result.add(modFunsT);
}
return result;
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class PatternMatchTest method testMatch_0.
@Test
public void testMatch_0() throws Exception {
final OtpBindings b = new OtpBindings();
b.put("W", new OtpErlangAtom("a"));
final OtpBindings r = OtpErlang.match("[W, V]", "[a, b]", b);
Assert.assertNotNull(r);
Assert.assertEquals(r.get("V"), new OtpErlangAtom("b"));
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class TermParserTest method atom_2.
@Test
public void atom_2() throws OtpParserException {
final OtpErlangAtom r = (OtpErlangAtom) termParser.parse("hello ");
Assert.assertEquals(r.atomValue(), "hello");
}
Aggregations