Package com.ericsson.otp.erlang

Examples of com.ericsson.otp.erlang.OtpErlangTuple


            final boolean interpret) {
        try {
            final OtpErlangObject res = backend.call(ERLIDE_DEBUG, "interpret", "alxoo",
                    moduleName, options, distributed, interpret);
            if (res instanceof OtpErlangTuple) {
                final OtpErlangTuple t = (OtpErlangTuple) res;
                final OtpErlangObject o = t.elementAt(0);
                if (o instanceof OtpErlangAtom) {
                    final OtpErlangAtom moduleAtom = (OtpErlangAtom) o;
                    return moduleAtom.atomValue().equals("module");
                }
            }
View Full Code Here


            final OtpErlangPid meta) {
        try {
            final OtpErlangObject res = backend.call(ERLIDE_DEBUG, "eval", "sx",
                    expression, meta);
            if (res instanceof OtpErlangTuple) {
                final OtpErlangTuple t = (OtpErlangTuple) res;
                if (Util.isOk(t)) {
                    return t.elementAt(1);
                }
            }
        } catch (final RpcException e) {
            ErlLogger.warn(e);
        }
View Full Code Here

                r1 = b.call("erlide_backend", "eval", "s", string);
            } else {
                r1 = b.call("erlide_backend", "eval", "sx", string, bindings);
            }
            // value may be something else if exception is thrown...
            final OtpErlangTuple t = (OtpErlangTuple) r1;
            final boolean ok = !"error".equals(((OtpErlangAtom) t.elementAt(0))
                    .atomValue());
            if (ok) {
                result.setValue(t.elementAt(1), t.elementAt(2));
            } else {
                result.setError(t.elementAt(1));
            }
        } catch (final Exception e) {
            result.setError("rpc failed");
        }
        return result;
View Full Code Here

     * (com.ericsson.otp.erlang.OtpErlangObject)
     */
    @Override
    public void parse(final OtpErlangObject object) {
        try {
            final OtpErlangTuple res = (OtpErlangTuple) object;
            if (!res.elementAt(0).toString().equals("ok")) {
                setUnSuccessful(((OtpErlangString) res.elementAt(1)).stringValue());
                return;
            }

            final OtpErlangTuple result = (OtpErlangTuple) res.elementAt(1);

            if (result.elementAt(0).equals(new OtpErlangList())) {
                setUnSuccessful("No more instances found!");
                return;
            }

            final DuplicatedCodeElement dup = parseDuplicates(result);
View Full Code Here

    // { [{ {filename(), integer(), integer()} , {filename(), integer(),
    // integer()} }], integer(), integer(), string()}
    protected DuplicatedCodeElement parseDuplicates(final OtpErlangObject object)
            throws OtpErlangRangeException {
        final OtpErlangTuple listElementTuple = (OtpErlangTuple) object;
        final OtpErlangList duplicateCodeList = (OtpErlangList) listElementTuple
                .elementAt(0);
        final LinkedHashMap<IFile, List<DuplicatedCodeInstanceElement>> values = new LinkedHashMap<IFile, List<DuplicatedCodeInstanceElement>>();

        final OtpErlangString suggestion = (OtpErlangString) listElementTuple
                .elementAt(1);
        final String suggStr = suggestion.stringValue();

        final OtpErlangObject[] elements = duplicateCodeList.elements();

        for (int i = 0; i < elements.length; ++i) {
            final OtpErlangTuple elementPair = (OtpErlangTuple) elements[i];
            final OtpErlangTuple firstElement = (OtpErlangTuple) elementPair.elementAt(0);
            final OtpErlangTuple secondElement = (OtpErlangTuple) elementPair
                    .elementAt(1);
            final OtpErlangString fileName = (OtpErlangString) firstElement.elementAt(0);
            final OtpErlangLong startLine = (OtpErlangLong) firstElement.elementAt(1);
            final OtpErlangLong startCol = (OtpErlangLong) firstElement.elementAt(2);
            final OtpErlangLong endLine = (OtpErlangLong) secondElement.elementAt(1);
            final OtpErlangLong endCol = (OtpErlangLong) secondElement.elementAt(2);

            final String fileNameStr = fileName.stringValue();
            final IFile file = WranglerUtils.getFileFromPath(fileNameStr);
            final DuplicatedCodeInstanceElement instance = new DuplicatedCodeInstanceElement(
                    file, startLine.intValue(), startCol.intValue(), endLine.intValue(),
View Full Code Here

    @Override
    public void parse(final OtpErlangObject object) {
        try {
            // TODO testing all cases
            if (object instanceof OtpErlangTuple) {
                final OtpErlangTuple objectTuple = (OtpErlangTuple) object;
                setUnSuccessful(((OtpErlangString) objectTuple.elementAt(1))
                        .stringValue());

            } else {
                final OtpErlangList resultList = (OtpErlangList) object;
                if (resultList.arity() == 0) {
View Full Code Here

    // { [{ {filename(), integer(), integer()} , {filename(), integer(),
    // integer()} }], integer(), integer(), string()}
    protected DuplicatedCodeElement parseDuplicates(final OtpErlangObject object)
            throws OtpErlangRangeException {
        final OtpErlangTuple listElementTuple = (OtpErlangTuple) object;
        final OtpErlangList duplicateCodeList = (OtpErlangList) listElementTuple
                .elementAt(0);
        final LinkedHashMap<IFile, List<DuplicatedCodeInstanceElement>> values = new LinkedHashMap<IFile, List<DuplicatedCodeInstanceElement>>();

        final OtpErlangString suggestion = (OtpErlangString) listElementTuple
                .elementAt(3);
        final String suggStr = suggestion.stringValue();

        final OtpErlangObject[] elements = duplicateCodeList.elements();

        for (int i = 0; i < elements.length; ++i) {
            OtpErlangTuple elementPair = (OtpErlangTuple) elements[i];

            String replicationFunction = "";
            final OtpErlangTuple checkable = (OtpErlangTuple) elementPair.elementAt(0);
            if (checkable.elementAt(0) instanceof OtpErlangTuple) {
                final OtpErlangString repFunStr = (OtpErlangString) elementPair
                        .elementAt(1);
                replicationFunction = repFunStr.stringValue();
                elementPair = checkable;

            }
            final OtpErlangTuple firstElement = (OtpErlangTuple) elementPair.elementAt(0);
            final OtpErlangTuple secondElement = (OtpErlangTuple) elementPair
                    .elementAt(1);
            final OtpErlangString fileName = (OtpErlangString) firstElement.elementAt(0);
            final OtpErlangLong startLine = (OtpErlangLong) firstElement.elementAt(1);
            final OtpErlangLong startCol = (OtpErlangLong) firstElement.elementAt(2);
            final OtpErlangLong endLine = (OtpErlangLong) secondElement.elementAt(1);
            final OtpErlangLong endCol = (OtpErlangLong) secondElement.elementAt(2);

            final String fileNameStr = fileName.stringValue();
            final IFile file = WranglerUtils.getFileFromPath(fileNameStr);
            final DuplicatedCodeInstanceElement instance = new DuplicatedCodeInstanceElement(
                    file, startLine.intValue(), startCol.intValue(), endLine.intValue(),
View Full Code Here

    }

    @Override
    public void parse(final OtpErlangObject object) {
        try {
            final OtpErlangTuple res = (OtpErlangTuple) object;

            if (!res.elementAt(0).toString().equals("ok")) {
                setUnSuccessful(((OtpErlangString) res.elementAt(1)).stringValue());
                return;
            }
            if (res.elementAt(1).equals(new OtpErlangList())) {
                setUnSuccessful("No more instances found!");
                return;
            }

            final OtpErlangList posList = (OtpErlangList) res.elementAt(1);
            OtpErlangTuple actPos;
            OtpErlangLong startLine, startColumn, endLine, endColumn;

            final ArrayList<DuplicatedCodeInstanceElement> instances = new ArrayList<DuplicatedCodeInstanceElement>();

            final Iterator<OtpErlangObject> it = posList.iterator();
            while (it.hasNext()) {
                actPos = (OtpErlangTuple) it.next();
                startLine = (OtpErlangLong) ((OtpErlangTuple) actPos.elementAt(0))
                        .elementAt(0);
                startColumn = (OtpErlangLong) ((OtpErlangTuple) actPos.elementAt(0))
                        .elementAt(1);
                endLine = (OtpErlangLong) ((OtpErlangTuple) actPos.elementAt(1))
                        .elementAt(0);
                endColumn = (OtpErlangLong) ((OtpErlangTuple) actPos.elementAt(1))
                        .elementAt(1);

                final IErlSelection sel = GlobalParameters.getWranglerSelection();
                instances.add(new DuplicatedCodeInstanceElement((IFile) sel
                        .getErlElement().getResource(), startLine.intValue(), startColumn
View Full Code Here

    public static OtpErlangObject ok(final OtpErlangObject v0) {
        if (!(v0 instanceof OtpErlangTuple)) {
            return v0;
        }
        final OtpErlangTuple v = (OtpErlangTuple) v0;
        if (Util.isOk(v)) {
            return v.elementAt(1);
        }
        return v;
    }
View Full Code Here

    public static boolean isAccessibleDir(final IOtpRpc otpRpc, final String localDir) {
        try {
            final OtpErlangObject r = otpRpc
                    .call("file", "read_file_info", "s", localDir);
            if (Util.isOk(r)) {
                final OtpErlangTuple result = (OtpErlangTuple) r;
                final OtpErlangTuple info = (OtpErlangTuple) result.elementAt(1);
                final String access = info.elementAt(3).toString();
                final int mode = ((OtpErlangLong) info.elementAt(7)).intValue();
                return ("read".equals(access) || "read_write".equals(access))
                        && (mode & 4) == 4;
            }
        } catch (final OtpErlangRangeException e) {
            ErlLogger.error(e);
View Full Code Here

TOP

Related Classes of com.ericsson.otp.erlang.OtpErlangTuple

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.