Search in sources :

Example 11 with OtpErlangString

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

the class ErlParser method addRecordDef.

private IErlRecordDef addRecordDef(final IErlModule module, final OtpErlangObject pos, final OtpErlangObject val, final OtpErlangObject extra) {
    if (val instanceof OtpErlangTuple) {
        final OtpErlangTuple recordTuple = (OtpErlangTuple) val;
        if (recordTuple.elementAt(0) instanceof OtpErlangAtom) {
            final String s = extra instanceof OtpErlangString ? ((OtpErlangString) extra).stringValue() : null;
            final OtpErlangList fields = (OtpErlangList) recordTuple.elementAt(1);
            final ErlRecordDef r = new ErlRecordDef(module, null, s);
            setPos(r, pos);
            if (fields != null) {
                final List<ErlRecordField> children = Lists.newArrayListWithCapacity(fields.arity());
                for (final OtpErlangObject o : fields) {
                    if (o instanceof OtpErlangTuple) {
                        final OtpErlangTuple fieldTuple = (OtpErlangTuple) o;
                        final OtpErlangAtom fieldNameAtom = (OtpErlangAtom) fieldTuple.elementAt(0);
                        final String fieldName = fieldNameAtom.atomValue();
                        final ErlRecordField field = new ErlRecordField(r, fieldName);
                        final OtpErlangTuple posTuple = (OtpErlangTuple) fieldTuple.elementAt(1);
                        if (fieldTuple.arity() > 2) {
                            final OtpErlangObject fieldExtra = fieldTuple.elementAt(2);
                            field.setExtra(Util.stringValue(fieldExtra));
                        }
                        setPos(field, posTuple);
                        children.add(field);
                    } else {
                        ErlLogger.error("bad record def: %s", o);
                    }
                }
                r.setChildren(children);
            } else {
                r.setChildren(new ArrayList<>());
            }
            return r;
        }
    }
    if (val instanceof OtpErlangAtom) {
        final String s = extra instanceof OtpErlangString ? ((OtpErlangString) extra).stringValue() : null;
        final ErlRecordDef r = new ErlRecordDef(module, null, s);
        setPos(r, pos);
        return r;
    }
    return null;
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) ErlRecordField(org.erlide.engine.internal.model.erlang.ErlRecordField) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) ErlRecordDef(org.erlide.engine.internal.model.erlang.ErlRecordDef) IErlRecordDef(org.erlide.engine.model.erlang.IErlRecordDef) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 12 with OtpErlangString

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

the class ErlideDoc method getOtpDoc.

@Override
public OtpErlangObject getOtpDoc(final IOtpRpc b, final ErlangFunctionCall functionCall) {
    OtpErlangObject res = null;
    final OtpErlangTuple input = new OtpErlangTuple(new OtpErlangObject[] { new OtpErlangAtom("external"), new OtpErlangAtom(functionCall.getModule()), new OtpErlangAtom(functionCall.getName()), new OtpErlangInt(functionCall.getArity()), new OtpErlangString("") });
    try {
        res = b.call(ErlideDoc.ERLIDE_OTP_DOC, "get_doc", "sxs", functionCall.getModule(), input, stateDir);
    } catch (final RpcException e) {
        ErlLogger.warn(e);
    }
    return res;
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangInt(com.ericsson.otp.erlang.OtpErlangInt) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 13 with OtpErlangString

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

the class ErlModel method getPathVars.

@Override
public OtpErlangList getPathVars() {
    // if (fCachedPathVars == null) {
    final IPathVariableManager pvm = ResourcesPlugin.getWorkspace().getPathVariableManager();
    final String[] names = pvm.getPathVariableNames();
    final OtpErlangObject[] objects = new OtpErlangObject[names.length];
    for (int i = 0; i < names.length; i++) {
        final String name = names[i];
        final String value = URIUtil.toPath(pvm.getURIValue(name)).toPortableString();
        objects[i] = new OtpErlangTuple(new OtpErlangObject[] { new OtpErlangString(name), new OtpErlangString(value) });
    }
    fCachedPathVars = new OtpErlangList(objects);
    // }
    return fCachedPathVars;
}
Also used : IPathVariableManager(org.eclipse.core.resources.IPathVariableManager) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 14 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString 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 15 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString 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)

Aggregations

OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)56 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)36 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)31 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)22 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)15 ArrayList (java.util.ArrayList)9 RpcResult (org.erlide.runtime.rpc.RpcResult)8 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)7 RpcException (org.erlide.runtime.rpc.RpcException)7 Test (org.junit.Test)7 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)6 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)5 IPath (org.eclipse.core.runtime.IPath)5 ErlModelException (org.erlide.engine.model.ErlModelException)5 IErlElement (org.erlide.engine.model.IErlElement)5 WranglerRpcParsingException (org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)5 IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)5 CoreException (org.eclipse.core.runtime.CoreException)4 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)4 Map (java.util.Map)3