Search in sources :

Example 1 with ErlModelCache

use of org.erlide.engine.internal.model.cache.ErlModelCache in project erlide_eclipse by erlang.

the class ErlProject method getModulesAndIncludes.

@Override
public Collection<IErlModule> getModulesAndIncludes() throws ErlModelException {
    final List<IErlModule> result = new ArrayList<>();
    final ErlModelCache erlModelCache = ErlModelCache.getDefault();
    final List<IErlModule> modulesForProject = erlModelCache.getModulesForProject(this);
    final List<IErlModule> includesForProject = erlModelCache.getIncludesForProject(this);
    if (modulesForProject != null && includesForProject != null) {
        result.addAll(modulesForProject);
        result.addAll(includesForProject);
    } else {
        final List<IErlModule> cached = erlModelCache.getModulesForProject(this);
        final IErlElementLocator model = ErlangEngine.getInstance().getModel();
        if (cached == null) {
            final List<IErlModule> modules = ErlProject.getModulesOrIncludes(fProject, model, getProperties().getSourceDirs(), true);
            result.addAll(modules);
        } else {
            result.addAll(cached);
        }
        final Collection<IErlModule> includes = getIncludes();
        result.addAll(includes);
    }
    return result;
}
Also used : ErlModelCache(org.erlide.engine.internal.model.cache.ErlModelCache) IErlModule(org.erlide.engine.model.root.IErlModule) ArrayList(java.util.ArrayList) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator)

Example 2 with ErlModelCache

use of org.erlide.engine.internal.model.cache.ErlModelCache in project erlide_eclipse by erlang.

the class ErlModel method createErlangProject.

private IErlProject createErlangProject(final IProject project) {
    final IErlProject ep = new ErlProject(project, this);
    addChild(ep);
    final ErlModelCache cache = getModelCache();
    cache.newProjectCreated();
    return ep;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlProject(org.erlide.engine.internal.model.root.ErlProject) IErlProject(org.erlide.engine.model.root.IErlProject) ErlModelCache(org.erlide.engine.internal.model.cache.ErlModelCache)

Example 3 with ErlModelCache

use of org.erlide.engine.internal.model.cache.ErlModelCache in project erlide_eclipse by erlang.

the class ErlExternalReferenceEntryList method buildStructure.

@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
    // TODO some code duplication within this function
    // ErlLogger.debug("ErlExternalReferenceEntryList.buildStructure %s",
    // getName());
    final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(this);
    final ErlModelCache cache = ErlModelCache.getDefault();
    List<ExternalTreeEntry> externalModuleTree = cache.getExternalTree(externalModules);
    List<ExternalTreeEntry> externalIncludeTree = cache.getExternalTree(externalIncludes);
    if (externalModuleTree == null || externalIncludeTree == null) {
        final OtpErlangList pathVars = ErlangEngine.getInstance().getModel().getPathVars();
        final IOtpRpc backend = OtpRpcFactory.getOtpRpcForProject(project);
        if (externalModuleTree == null && !externalModules.isEmpty()) {
            if (pm != null) {
                pm.worked(1);
            }
            externalModuleTree = ErlangEngine.getInstance().getOpenService().getExternalModuleTree(backend, externalModules, pathVars);
        }
        if (externalIncludeTree == null && !externalIncludes.isEmpty()) {
            if (pm != null) {
                pm.worked(1);
            }
            externalIncludeTree = ErlangEngine.getInstance().getOpenService().getExternalModuleTree(backend, externalIncludes, pathVars);
        }
    }
    setChildren(null);
    final IErlModel model = ErlangEngine.getInstance().getModel();
    if (externalModuleTree != null && !externalModuleTree.isEmpty()) {
        addExternalEntries(pm, externalModuleTree, model, "modules", null, false);
        cache.putExternalTree(externalModules, project, externalModuleTree);
    }
    if (externalIncludeTree != null && !externalIncludeTree.isEmpty() || !projectIncludes.isEmpty()) {
        addExternalEntries(pm, externalIncludeTree, model, "includes", projectIncludes, true);
        if (externalIncludeTree != null) {
            cache.putExternalTree(externalIncludes, project, externalIncludeTree);
        }
    }
    return true;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModel(org.erlide.engine.model.root.IErlModel) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) ErlModelCache(org.erlide.engine.internal.model.cache.ErlModelCache) ExternalTreeEntry(org.erlide.engine.services.search.ExternalTreeEntry) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc)

Example 4 with ErlModelCache

use of org.erlide.engine.internal.model.cache.ErlModelCache in project erlide_eclipse by erlang.

the class ErlProject method getIncludes.

@Override
public Collection<IErlModule> getIncludes() throws ErlModelException {
    final ErlModelCache erlModelCache = ErlModelCache.getDefault();
    final List<IErlModule> cached = erlModelCache.getIncludesForProject(this);
    if (cached != null) {
        return cached;
    }
    final List<IErlModule> includes = ErlProject.getModulesOrIncludes(fProject, ErlangEngine.getInstance().getModel(), getProperties().getIncludeDirs(), false);
    erlModelCache.putIncludesForProject(this, includes);
    return includes;
}
Also used : ErlModelCache(org.erlide.engine.internal.model.cache.ErlModelCache) IErlModule(org.erlide.engine.model.root.IErlModule)

Aggregations

ErlModelCache (org.erlide.engine.internal.model.cache.ErlModelCache)4 IErlModule (org.erlide.engine.model.root.IErlModule)2 IErlProject (org.erlide.engine.model.root.IErlProject)2 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 ArrayList (java.util.ArrayList)1 ErlProject (org.erlide.engine.internal.model.root.ErlProject)1 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)1 IErlModel (org.erlide.engine.model.root.IErlModel)1 ExternalTreeEntry (org.erlide.engine.services.search.ExternalTreeEntry)1 IOtpRpc (org.erlide.runtime.rpc.IOtpRpc)1