Search in sources :

Example 31 with OtpErlangAtom

use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.

the class OtpRpc method buildRpcCall.

private OtpErlangObject buildRpcCall(final OtpErlangPid pid, final OtpErlangObject gleader, final String module, final String fun, final OtpErlangObject[] args) {
    final OtpErlangObject m = new OtpErlangAtom(module);
    final OtpErlangObject f = new OtpErlangAtom(fun);
    final OtpErlangObject a = new OtpErlangList(args);
    return OtpErlang.mkTuple(pid, OtpErlang.mkTuple(new OtpErlangAtom("call"), m, f, a, gleader));
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 32 with OtpErlangAtom

use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.

the class BeamLoader method reloadAllCode.

public static void reloadAllCode(final IOtpRpc backend) {
    try {
        final OtpErlangList loaded = (OtpErlangList) backend.call("code", "all_loaded", "");
        final List<OtpErlangAtom> mine = new ArrayList<>();
        for (final OtpErlangObject elem : loaded) {
            final OtpErlangTuple t = (OtpErlangTuple) elem;
            final OtpErlangAtom mod = (OtpErlangAtom) t.elementAt(0);
            if (mod.atomValue().startsWith("erlide_")) {
                // ErlLogger.debug(">>> HAD " + mod + " " +
                // t.elementAt(1));
                mine.add(mod);
            }
        }
        for (final OtpErlangAtom mod : mine) {
            // ErlLogger.debug(">>> reload " + mod);
            backend.call("c", "l", "x", mod);
        }
    } catch (final Exception e) {
        ErlLogger.error(e);
    }
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ArrayList(java.util.ArrayList) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 33 with OtpErlangAtom

use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.

the class SimpleCodeInspectionHandler method processFunctionResult.

private ArrayList<IErlElement> processFunctionResult(final Shell shell, final RpcResult result) throws OtpErlangRangeException {
    final ArrayList<IErlElement> elements = new ArrayList<>();
    final OtpErlangObject obj = result.getValue();
    final OtpErlangTuple restuple = (OtpErlangTuple) obj;
    final OtpErlangAtom resindicator = (OtpErlangAtom) restuple.elementAt(0);
    if ("ok".equals(resindicator.atomValue())) {
        final OtpErlangList erlangFunctionList = (OtpErlangList) restuple.elementAt(1);
        for (int i = 0; i < erlangFunctionList.arity(); ++i) {
            final OtpErlangTuple fTuple = (OtpErlangTuple) erlangFunctionList.elementAt(i);
            IErlFunctionClause f;
            try {
                f = extractFunction(fTuple);
                elements.add(f);
            } catch (final ErlModelException e) {
            }
        }
    } else {
        final OtpErlangString s = (OtpErlangString) restuple.elementAt(1);
        MessageDialog.openError(shell, "Error", s.stringValue());
        return null;
    }
    return elements;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) ErlModelException(org.erlide.engine.model.ErlModelException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ArrayList(java.util.ArrayList) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) IErlFunctionClause(org.erlide.engine.model.erlang.IErlFunctionClause) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 34 with OtpErlangAtom

use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.

the class SimpleCodeInspectionHandler method handleDepenenciesCall.

private void handleDepenenciesCall(final IErlSelection wranglerSelection, final Shell shell) {
    // hiding the views
    CodeInspectionViewsManager.hideView(CodeInspectionViewsManager.CODE_INSPECTION_VIEW, SimpleCodeInspectionHandler.DEPENECIES_1_VIEW_ID);
    CodeInspectionViewsManager.hideView(CodeInspectionViewsManager.CODE_INSPECTION_VIEW, SimpleCodeInspectionHandler.DEPENECIES_2_VIEW_ID);
    // run the rpc
    try {
        final RpcResult res = WranglerBackendManager.getRefactoringBackend().callInspection("dependencies_of_a_module_eclipse", "sx", wranglerSelection.getFilePath(), wranglerSelection.getSearchPath());
        ArrayList<IErlElement> modules1 = new ArrayList<>();
        ArrayList<IErlElement> modules2 = new ArrayList<>();
        final OtpErlangObject obj = res.getValue();
        final OtpErlangTuple restuple = (OtpErlangTuple) obj;
        final OtpErlangAtom resindicator = (OtpErlangAtom) restuple.elementAt(0);
        if ("ok".equals(resindicator.atomValue())) {
            final OtpErlangTuple listtuple = (OtpErlangTuple) restuple.elementAt(1);
            final OtpErlangList modList1 = (OtpErlangList) listtuple.elementAt(0);
            final OtpErlangList modList2 = (OtpErlangList) listtuple.elementAt(1);
            modules1 = createErlModuleList(modList1);
            modules2 = createErlModuleList(modList2);
        } else {
            final OtpErlangString s = (OtpErlangString) restuple.elementAt(1);
            MessageDialog.openError(shell, "Error", s.stringValue());
            return;
        }
        if (!modules1.isEmpty()) {
            CodeInspectionViewsManager.showErlElements("Modules which depends on " + wranglerSelection.getErlElement().getAncestorOfKind(ErlElementKind.MODULE).getName(), modules1, SimpleCodeInspectionHandler.DEPENECIES_1_VIEW_ID);
        }
        if (!modules2.isEmpty()) {
            CodeInspectionViewsManager.showErlElements("Modules, on which " + wranglerSelection.getErlElement().getAncestorOfKind(ErlElementKind.MODULE).getName() + " depends", modules2, SimpleCodeInspectionHandler.DEPENECIES_2_VIEW_ID);
        } else {
            MessageDialog.openInformation(shell, "No result", "There is no large module with the specified parameter!");
        }
    } catch (final Exception e) {
        ErlLogger.error(e);
    }
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcResult(org.erlide.runtime.rpc.RpcResult) ArrayList(java.util.ArrayList) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) ErlModelException(org.erlide.engine.model.ErlModelException) ExecutionException(org.eclipse.core.commands.ExecutionException) WranglerException(org.erlide.wrangler.refactoring.exception.WranglerException) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 35 with OtpErlangAtom

use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.

the class WranglerSyntaxBackend method parseParserResult.

protected OtpErlangTuple parseParserResult(final OtpErlangObject value) {
    final OtpErlangTuple backendResult = (OtpErlangTuple) value;
    if (!"ok".equals(((OtpErlangAtom) backendResult.elementAt(0)).atomValue())) {
        return null;
    }
    final OtpErlangTuple wranglerResult = (OtpErlangTuple) backendResult.elementAt(1);
    return (OtpErlangTuple) wranglerResult.elementAt(0);
}
Also used : OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Aggregations

OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)87 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)56 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)48 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)32 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)24 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)17 ArrayList (java.util.ArrayList)15 Test (org.junit.Test)14 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)11 RpcException (org.erlide.runtime.rpc.RpcException)11 OtpBindings (org.erlide.util.erlang.OtpBindings)9 IErlElement (org.erlide.engine.model.IErlElement)6 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)4 OtpErlangPid (com.ericsson.otp.erlang.OtpErlangPid)4 IErlModule (org.erlide.engine.model.root.IErlModule)4 OtpErlangInt (com.ericsson.otp.erlang.OtpErlangInt)3 OtpErlangMap (com.ericsson.otp.erlang.OtpErlangMap)3 Subscribe (com.google.common.eventbus.Subscribe)3 Collection (java.util.Collection)3 OtpErlangException (com.ericsson.otp.erlang.OtpErlangException)2