use of com.ericsson.otp.erlang.OtpErlangRangeException 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 com.ericsson.otp.erlang.OtpErlangRangeException in project erlide_eclipse by erlang.
the class DialyzerMarkerUtils method addDialyzerWarningMarkersFromResultList.
public static void addDialyzerWarningMarkersFromResultList(final IOtpRpc backend, final OtpErlangList result) {
if (result == null || result.arity() == 0) {
return;
}
final List<String> warnings = ErlideDialyze.formatWarnings(backend, result);
for (int i = 0; i < warnings.size(); i++) {
final OtpErlangTuple t = (OtpErlangTuple) result.elementAt(i);
final OtpErlangTuple fileLine = (OtpErlangTuple) t.elementAt(1);
final String filename = Util.stringValue(fileLine.elementAt(0));
final OtpErlangLong lineL = (OtpErlangLong) fileLine.elementAt(1);
if (!filename.isEmpty()) {
int line = 1;
try {
line = lineL.intValue();
} catch (final OtpErlangRangeException e) {
ErlLogger.error(e);
}
if (line <= 0) {
line = 1;
}
String msg = warnings.get(i);
final int j = msg.indexOf(": ");
if (j != -1) {
msg = msg.substring(j + 1);
}
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
DialyzerMarkerUtils.addDialyzerWarningMarker(model, filename, line, msg);
}
}
}
use of com.ericsson.otp.erlang.OtpErlangRangeException in project erlide_eclipse by erlang.
the class ErlSearchQuery method run.
@Override
public IStatus run(final IProgressMonitor monitor) throws OperationCanceledException {
final Object locker = new Object();
final IRpcResultCallback callback = new IRpcResultCallback() {
@Override
public void start(final OtpErlangObject msg) {
if (fSearchResult != null) {
fSearchResult.removeAll();
}
final OtpErlangLong progressMaxL = (OtpErlangLong) msg;
int progressMax;
try {
progressMax = progressMaxL.intValue();
} catch (final OtpErlangRangeException e) {
progressMax = 10;
}
monitor.beginTask("Searching", progressMax);
}
@Override
public void stop(final OtpErlangObject msg) {
monitor.done();
stopped = true;
synchronized (locker) {
locker.notifyAll();
}
}
@Override
public void progress(final OtpErlangObject msg) {
final OtpErlangTuple t = (OtpErlangTuple) msg;
final OtpErlangPid backgroundSearchPid = (OtpErlangPid) t.elementAt(0);
final OtpErlangLong progressL = (OtpErlangLong) t.elementAt(1);
final OtpErlangObject resultO = t.elementAt(2);
int progress = 1;
try {
progress = progressL.intValue();
final List<ModuleLineFunctionArityRef> result = Lists.newArrayList();
SearchUtil.addSearchResult(result, resultO);
addMatches(result);
} catch (final OtpErlangRangeException e) {
}
monitor.worked(progress);
if (monitor.isCanceled()) {
try {
ErlangEngine.getInstance().getSearchServerService().cancelSearch(backgroundSearchPid);
} catch (final RpcException e) {
}
}
}
};
try {
final ErlSearchScope reducedScope = pattern.reduceScope(scope);
ErlangEngine.getInstance().getSearchServerService().startFindRefs(pattern, reducedScope, ErlangEngine.getInstance().getStateDir(), callback, false);
} catch (final RpcException e) {
return new Status(IStatus.ERROR, ErlideUIPlugin.PLUGIN_ID, "Search error", e);
}
while (!stopped) {
synchronized (locker) {
try {
if (!stopped) {
locker.wait();
}
} catch (final InterruptedException e) {
}
}
}
return Status.OK_STATUS;
}
use of com.ericsson.otp.erlang.OtpErlangRangeException in project erlide_eclipse by erlang.
the class ErlParser method createComment.
/**
* create an IErlComment from a token record
*
* @param IErlModule
* module containing comment
* @param OtpErlangTuple
* token record from noparse
* @return IErlComment
*/
private IErlComment createComment(final IErlModule module, final OtpErlangTuple c) {
final OtpErlangLong lineL = (OtpErlangLong) c.elementAt(ErlParser.LINE);
final OtpErlangObject s = c.elementAt(ErlParser.TEXT);
int line;
int lastLine;
try {
line = lineL.intValue();
} catch (final OtpErlangRangeException x) {
line = 0;
}
lastLine = line;
try {
if (c.elementAt(ErlParser.LAST_LINE) instanceof OtpErlangLong) {
final OtpErlangLong lastLineL = (OtpErlangLong) c.elementAt(ErlParser.LAST_LINE);
lastLine = lastLineL.intValue();
}
} catch (final OtpErlangRangeException e1) {
lastLine = line;
}
final ErlComment comment = new ErlComment(module, Util.stringValue(s), line <= ErlParser.MODULE_HEADER_COMMENT_THRESHOLD);
try {
final int ofs = ((OtpErlangLong) c.elementAt(ErlParser.OFFSET)).intValue();
final int len = ((OtpErlangLong) c.elementAt(ErlParser.LENGTH)).intValue();
setPos(comment, line, lastLine, ofs + 1, len);
} catch (final OtpErlangRangeException e) {
return null;
}
return comment;
}
use of com.ericsson.otp.erlang.OtpErlangRangeException in project erlide_eclipse by erlang.
the class ErlParser method makeErlFunctionClause.
/**
* @param f
* function
* @param i
* clause number
* @param clause
* -record(clause, {pos, name, args, head, code, name_pos}).
* @return ErlFunctionClause
*/
private ErlFunctionClause makeErlFunctionClause(final ErlFunction f, final int i, final OtpErlangTuple clause) {
final OtpErlangTuple cpos = (OtpErlangTuple) clause.elementAt(1);
final OtpErlangList parameters = (OtpErlangList) clause.elementAt(3);
final OtpErlangObject head = clause.elementAt(4);
final OtpErlangTuple cnamePos = (OtpErlangTuple) clause.elementAt(5);
final ErlFunctionClause cl = new ErlFunctionClause(f, "#" + i, Util.stringValue(head), parameters);
try {
setNamePos(cl, cnamePos);
} catch (final OtpErlangRangeException e) {
ErlLogger.warn(e);
}
setPos(cl, cpos);
return cl;
}
Aggregations