use of com.ericsson.otp.erlang.OtpErlangRangeException in project erlide_eclipse by erlang.
the class DebuggerTraceView method createViewer.
@Override
protected Viewer createViewer(final Composite parent) {
viewer = new TreeViewer(new Tree(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION));
// setViewer(viewer);
// super.createPartControl(parent);
// parent.setLayout(new FillLayout());
viewer.getTree().setLinesVisible(true);
viewer.setUseHashlookup(true);
createColumns();
viewer.setContentProvider(getContentProvider());
viewer.setLabelProvider(new ColumnLabelProvider());
getSite().setSelectionProvider(viewer);
viewer.setInput(this);
DebugPlugin.getDefault().addDebugEventListener(this);
// viewer.getTree().addTreeListener(new TreeAdapter() {
// @Override
// public void treeCollapsed(final TreeEvent e) {
// removeExpandedCategory((MarkerCategory) e.item.getData());
// }
//
// @Override
// public void treeExpanded(final TreeEvent e) {
// addExpandedCategory((MarkerCategory) e.item.getData());
// }
// });
// // Set help on the view itself
// viewer.getControl().addHelpListener(new HelpListener() {
// public void helpRequested(HelpEvent e) {
// Object provider = getAdapter(IContextProvider.class);
// if (provider == null) {
// return;
// }
//
// IContext context = ((IContextProvider) provider)
// .getContext(viewer.getControl());
// PlatformUI.getWorkbench().getHelpSystem().displayHelp(context);
// }
//
// });
viewer.getTree().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final Object o = getSelectedInTree();
// $NON-NLS-1$
final String msg = o == null ? "" : o.toString();
getViewSite().getActionBars().getStatusLineManager().setMessage(msg);
}
});
viewer.getTree().addMouseListener(new MouseListener() {
@Override
public void mouseDoubleClick(final MouseEvent e) {
final Object o = getSelectedInTree();
if (o instanceof OtpErlangTuple) {
final OtpErlangTuple t = (OtpErlangTuple) o;
final OtpErlangTuple t2 = (OtpErlangTuple) t.elementAt(1);
final OtpErlangTuple ieval = (OtpErlangTuple) t2.elementAt(0);
final OtpErlangAtom mod = (OtpErlangAtom) ieval.elementAt(3);
final String module = mod.atomValue();
final OtpErlangLong lin = (OtpErlangLong) ieval.elementAt(2);
try {
final int line = lin.intValue();
gotoModuleLine(module, line);
} catch (final OtpErlangRangeException e1) {
}
}
}
@Override
public void mouseDown(final MouseEvent e) {
}
@Override
public void mouseUp(final MouseEvent e) {
}
});
// .addPropertyChangeListener(getWorkingSetListener());
return viewer;
// registerContextMenu();
// initDragAndDrop();
}
use of com.ericsson.otp.erlang.OtpErlangRangeException in project intellij-elixir by KronicDeth.
the class Import method keywordValueToArity.
@Nullable
private static Integer keywordValueToArity(@NotNull final Quotable keywordValue) {
OtpErlangObject quotedKeywordValue = keywordValue.quote();
Integer arity = null;
if (quotedKeywordValue instanceof OtpErlangLong) {
OtpErlangLong quotedKeywordValueLong = (OtpErlangLong) quotedKeywordValue;
try {
arity = quotedKeywordValueLong.intValue();
} catch (OtpErlangRangeException e) {
Logger.error(Import.class, "Arity in OtpErlangLong could not be downcast to an int", keywordValue);
}
}
return arity;
}
use of com.ericsson.otp.erlang.OtpErlangRangeException in project erlide_eclipse by erlang.
the class MarkerUtils method addAnnotationForMessage.
private static void addAnnotationForMessage(final IResource resource, final String fileName, final IResource res, final OtpErlangTuple data) {
int line = 0;
if (data.elementAt(0) instanceof OtpErlangLong) {
try {
line = ((OtpErlangLong) data.elementAt(0)).intValue();
} catch (final OtpErlangRangeException e) {
}
}
int sev = IMarker.SEVERITY_INFO;
try {
switch(((OtpErlangLong) data.elementAt(3)).intValue()) {
case 0:
sev = IMarker.SEVERITY_ERROR;
break;
case 1:
sev = IMarker.SEVERITY_WARNING;
break;
default:
sev = IMarker.SEVERITY_INFO;
break;
}
} catch (final OtpErlangRangeException e) {
}
String msg = OtpErlang.asString(data.elementAt(2)).replaceAll("[\n\r]", " ");
if (msg.startsWith("-warning(")) {
msg = msg.substring("-warning(".length(), msg.length() - 2);
}
if (msg.startsWith("-error(")) {
msg = msg.substring("-error(".length(), msg.length() - 2);
}
if (msg.startsWith("\"")) {
msg = msg.substring(1, msg.length() - 1);
}
final IMarker marker = MarkerUtils.createMarker(res, fileName, msg, line, sev, MarkerUtils.PROBLEM_MARKER);
if (marker != null) {
try {
marker.setAttribute(IMarker.SOURCE_ID, resource.getLocation().toString());
} catch (final CoreException e) {
}
}
}
use of com.ericsson.otp.erlang.OtpErlangRangeException in project erlide_eclipse by erlang.
the class TraceDataHandler method processFileInfo.
private ITreeNode processFileInfo(final OtpErlangTuple tuple) {
TracingResultsNode node = null;
if (tuple.elementAt(TraceDataHandler.INDEX_INFO_START_DATE) instanceof OtpErlangAtom) {
// file contains no trace events
return null;
}
try {
final Date from = readDateTuple((OtpErlangTuple) tuple.elementAt(TraceDataHandler.INDEX_INFO_START_DATE));
final Date to = readDateTuple((OtpErlangTuple) tuple.elementAt(TraceDataHandler.INDEX_INFO_END_DATE));
final String path = ((OtpErlangString) tuple.elementAt(TraceDataHandler.INDEX_INFO_PATH)).stringValue();
final long size = ((OtpErlangLong) tuple.elementAt(TraceDataHandler.INDEX_INFO_COUNT)).longValue();
node = new TracingResultsNode();
node.setStartDate(from);
node.setEndDate(to);
node.setFileName(path);
node.setSize(size);
// node label
final String builder = infoDateFormatter.format(from) + " - " + infoDateFormatter.format(to) + " (" + size + " traces): " + path;
node.setLabel(builder);
} catch (final OtpErlangRangeException e) {
ErlLogger.error(e);
}
return node;
}
use of com.ericsson.otp.erlang.OtpErlangRangeException in project erlide_eclipse by erlang.
the class TraceDataHandler method createFunctionNode.
private ITreeNode createFunctionNode(final String label, final OtpErlangObject erlangObject) {
final ITreeNode node = new TreeNode();
if (erlangObject instanceof OtpErlangTuple) {
final OtpErlangTuple functionTuple = (OtpErlangTuple) erlangObject;
final OtpErlangAtom moduleName = (OtpErlangAtom) functionTuple.elementAt(TraceDataHandler.INDEX_FUNCTION_MODULE);
final OtpErlangAtom functionName = (OtpErlangAtom) functionTuple.elementAt(TraceDataHandler.INDEX_FUNCTION_NAME);
// args or arity node
final TreeNode argsNode = new TreeNode();
argsNode.setImage(Activator.getImage(Images.INFO_NODE));
final OtpErlangObject arityOrArgs = functionTuple.elementAt(TraceDataHandler.INDEX_FUNCTION_ARGS);
int arityValue = -1;
if (arityOrArgs instanceof OtpErlangList) {
// last element is a list of arguments
final OtpErlangList arguments = (OtpErlangList) arityOrArgs;
final StringBuilder builder = new StringBuilder("arguments: ");
for (int i = 1; i < arguments.arity(); i++) {
builder.append(arguments.elementAt(i)).append(", ");
}
arityValue = arguments.arity() - 1;
argsNode.setLabel(builder.substring(0, builder.length() - 2));
} else {
// last element is arity
try {
if (functionTuple.elementAt(TraceDataHandler.INDEX_FUNCTION_ARGS) instanceof OtpErlangInt) {
arityValue = ((OtpErlangInt) functionTuple.elementAt(TraceDataHandler.INDEX_FUNCTION_ARGS)).intValue();
} else {
arityValue = (int) ((OtpErlangLong) functionTuple.elementAt(TraceDataHandler.INDEX_FUNCTION_ARGS)).longValue();
}
argsNode.setLabel("arity: " + arityValue);
} catch (final OtpErlangRangeException e) {
ErlLogger.error(e);
}
}
// module name node
final TreeNode moduleNameNode = new ModuleNode(moduleName.atomValue());
moduleNameNode.setLabel("module: " + moduleName);
// function name node
final TreeNode functionNameNode = new FunctionNode(moduleName.atomValue(), functionName.atomValue(), arityValue);
functionNameNode.setLabel("function: " + functionName);
node.addChildren(moduleNameNode, functionNameNode, argsNode);
lastFunctionDescription = label + moduleName + ":" + functionName + "/" + arityValue;
} else {
lastFunctionDescription = "unknown";
}
node.setLabel(lastFunctionDescription);
return node;
}
Aggregations