Search in sources :

Example 11 with OtpErlangRangeException

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();
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) MouseListener(org.eclipse.swt.events.MouseListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 12 with OtpErlangRangeException

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;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with OtpErlangRangeException

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) {
        }
    }
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) CoreException(org.eclipse.core.runtime.CoreException) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) IMarker(org.eclipse.core.resources.IMarker)

Example 14 with OtpErlangRangeException

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;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) TracingResultsNode(org.erlide.tracing.core.mvc.model.treenodes.TracingResultsNode) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Date(java.util.Date) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 15 with OtpErlangRangeException

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;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) FunctionNode(org.erlide.tracing.core.mvc.model.treenodes.FunctionNode) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) ITreeNode(org.erlide.tracing.core.mvc.model.treenodes.ITreeNode) TreeNode(org.erlide.tracing.core.mvc.model.treenodes.TreeNode) ITreeNode(org.erlide.tracing.core.mvc.model.treenodes.ITreeNode) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangInt(com.ericsson.otp.erlang.OtpErlangInt) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) ModuleNode(org.erlide.tracing.core.mvc.model.treenodes.ModuleNode)

Aggregations

OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)23 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)18 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)18 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)16 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)8 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)7 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)4 ArrayList (java.util.ArrayList)3 RpcException (org.erlide.runtime.rpc.RpcException)3 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)3 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)1 OtpErlangException (com.ericsson.otp.erlang.OtpErlangException)1 OtpErlangInt (com.ericsson.otp.erlang.OtpErlangInt)1 OtpErlangPid (com.ericsson.otp.erlang.OtpErlangPid)1 TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)1 Date (java.util.Date)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IMarker (org.eclipse.core.resources.IMarker)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1