Search in sources :

Example 6 with OtpErlangRangeException

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);
    }
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpParserException(org.erlide.util.erlang.OtpParserException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangException(com.ericsson.otp.erlang.OtpErlangException) OtpBindings(org.erlide.util.erlang.OtpBindings) ErlangFunction(org.erlide.engine.model.erlang.ErlangFunction) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 7 with OtpErlangRangeException

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);
        }
    }
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 8 with OtpErlangRangeException

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;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) ModuleLineFunctionArityRef(org.erlide.engine.services.search.ModuleLineFunctionArityRef) ErlSearchScope(org.erlide.engine.services.search.ErlSearchScope) IRpcResultCallback(org.erlide.runtime.rpc.IRpcResultCallback) OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 9 with OtpErlangRangeException

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;
}
Also used : IErlComment(org.erlide.engine.model.erlang.IErlComment) ErlComment(org.erlide.engine.internal.model.erlang.ErlComment) OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException)

Example 10 with OtpErlangRangeException

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;
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) ErlFunctionClause(org.erlide.engine.internal.model.erlang.ErlFunctionClause)

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