Search in sources :

Example 6 with IErlImport

use of org.erlide.engine.model.erlang.IErlImport in project erlide_eclipse by erlang.

the class ModelInternalUtils method getImportsAsList.

@Override
public List<OtpErlangObject> getImportsAsList(final IErlModule mod) {
    if (mod == null) {
        return ModelInternalUtils.NO_IMPORTS;
    }
    final Collection<IErlImport> imports = mod.getImports();
    if (imports.isEmpty()) {
        return ModelInternalUtils.NO_IMPORTS;
    }
    final List<OtpErlangObject> result = new ArrayList<>(imports.size());
    for (final IErlImport i : imports) {
        final Collection<ErlangFunction> functions = i.getFunctions();
        final OtpErlangObject[] funsT = new OtpErlangObject[functions.size()];
        int j = 0;
        for (final ErlangFunction f : functions) {
            funsT[j] = f.getNameArityTuple();
            j++;
        }
        final OtpErlangTuple modFunsT = new OtpErlangTuple(new OtpErlangObject[] { new OtpErlangAtom(i.getImportModule()), new OtpErlangList(funsT) });
        result.add(modFunsT);
    }
    return result;
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ArrayList(java.util.ArrayList) ErlangFunction(org.erlide.engine.model.erlang.ErlangFunction) IErlImport(org.erlide.engine.model.erlang.IErlImport) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 7 with IErlImport

use of org.erlide.engine.model.erlang.IErlImport in project erlide_eclipse by erlang.

the class ErlParser method addImportAttribute.

private IErlImport addImportAttribute(final IErlModule module, final OtpErlangObject pos, final OtpErlangObject val) {
    final OtpErlangTuple t = (OtpErlangTuple) val;
    if (t.elementAt(0) instanceof OtpErlangAtom && t.elementAt(1) instanceof OtpErlangList) {
        final OtpErlangAtom importModule = (OtpErlangAtom) t.elementAt(0);
        final OtpErlangList functionList = (OtpErlangList) t.elementAt(1);
        final ErlImport imp = new ErlImport(module, importModule.atomValue(), functionList);
        setPos(imp, pos);
        return imp;
    }
    return null;
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) ErlImport(org.erlide.engine.internal.model.erlang.ErlImport) IErlImport(org.erlide.engine.model.erlang.IErlImport)

Aggregations

IErlImport (org.erlide.engine.model.erlang.IErlImport)7 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)4 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)3 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)3 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)3 ArrayList (java.util.ArrayList)3 IErlElement (org.erlide.engine.model.IErlElement)3 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)2 IErlModule (org.erlide.engine.model.root.IErlModule)2 CompletionData (org.erlide.engine.services.codeassist.CompletionData)2 FunctionCompletionData (org.erlide.engine.services.codeassist.FunctionCompletionData)2 ErlImport (org.erlide.engine.internal.model.erlang.ErlImport)1 ErlangFunction (org.erlide.engine.model.erlang.ErlangFunction)1 IErlFunction (org.erlide.engine.model.erlang.IErlFunction)1 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)1 IErlModel (org.erlide.engine.model.root.IErlModel)1 IErlProject (org.erlide.engine.model.root.IErlProject)1 Test (org.junit.Test)1