Search in sources :

Example 81 with IErlProject

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

the class ErlModule method getAllDependentModules.

@Override
public Set<ISourceUnit> getAllDependentModules() throws CoreException {
    final Set<ISourceUnit> result = new HashSet<>();
    final IErlProject project = modelUtilService.getProject(this);
    for (final IErlModule module : project.getModules()) {
        final Collection<IErlModule> allIncludedFiles = ErlangEngine.getInstance().getModelFindService().findAllIncludedFiles(module);
        if (allIncludedFiles.contains(this)) {
            result.add(module);
        }
    }
    return result;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ISourceUnit(org.erlide.engine.model.root.ISourceUnit) IErlModule(org.erlide.engine.model.root.IErlModule) HashSet(java.util.HashSet)

Example 82 with IErlProject

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

the class ErlOtpExternalReferenceEntryList method buildStructure.

@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
    final IErlProject erlProject = ErlangEngine.getInstance().getModelUtilService().getProject(this);
    final IOtpRpc backend = OtpRpcFactory.getOtpRpcForProject(erlProject);
    if (backend != null) {
        addExternalEntries(pm, backend);
    }
    return true;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc)

Example 83 with IErlProject

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

the class ErlModel method findModuleFromProject.

@Override
public IErlModule findModuleFromProject(final IErlProject project, final String moduleName, final String modulePath, final boolean checkExternals, final IErlElementLocator.Scope scope) throws ErlModelException {
    if (project != null) {
        final IErlModule module = ErlModel.getModuleFromCacheByNameOrPath((ErlProject) project, moduleName, modulePath, scope);
        if (module != null && module.isOnSourcePath()) {
            return module;
        }
    }
    final List<IErlModule> allModules = Lists.newArrayList();
    final Set<String> paths = Sets.newHashSet();
    try {
        for (int i = 0; i < 2; ++i) {
            final boolean externalModules = i > 0;
            if (externalModules && !checkExternals) {
                break;
            }
            if (project != null) {
                final IErlModule module = tryFindModule(Sets.newHashSet(project), moduleName, modulePath, allModules, paths, externalModules);
                if (module != null) {
                    return module;
                }
            }
            if ((scope == Scope.REFERENCED_PROJECTS || scope == Scope.ALL_PROJECTS) && project != null) {
                final Collection<IErlProject> projects = project.getReferencedProjects();
                final IErlModule module = tryFindModule(projects, moduleName, modulePath, allModules, paths, externalModules);
                if (module != null) {
                    return module;
                }
            }
            if (scope == Scope.ALL_PROJECTS) {
                final Collection<IErlProject> projects = getErlangProjects();
                final IErlModule module = tryFindModule(projects, moduleName, modulePath, allModules, paths, externalModules);
                if (module != null) {
                    return module;
                }
            }
        }
        return null;
    } finally {
        ErlModelCache.getDefault().putModules(allModules);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 84 with IErlProject

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

the class ErlModel method getAllIncludes.

private Collection<IErlModule> getAllIncludes(final IErlProject project, final boolean checkExternals, final IErlElementLocator.Scope scope) throws ErlModelException {
    final List<IErlProject> projects = Lists.newArrayList();
    final List<IErlModule> result = Lists.newArrayList();
    final Set<String> paths = Sets.newHashSet();
    if (project != null) {
        projects.add(project);
        if (scope == IErlElementLocator.Scope.REFERENCED_PROJECTS) {
            projects.addAll(project.getReferencedProjects());
        }
    }
    if (scope == IErlElementLocator.Scope.ALL_PROJECTS) {
        for (final IErlProject project2 : getErlangProjects()) {
            if (!projects.contains(project2)) {
                projects.add(project2);
            }
        }
    }
    for (final IErlProject project2 : projects) {
        ErlModel.getAllModulesAux(project2.getIncludes(), result, paths);
    }
    if (checkExternals && project != null) {
        ErlModel.getAllModulesAux(project.getExternalIncludes(), result, paths);
    }
    return result;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 85 with IErlProject

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

the class ErlModelCache method removeProject.

public void removeProject(final IErlProject project) {
    // ErlLogger.debug("removeForProject %s", project.getName());
    final List<IErlModule> includes = projectIncludeCache.getIfPresent(project);
    if (includes != null) {
        for (final IErlModule module : includes) {
            moduleIncludeCache.invalidate(module);
        }
    }
    final List<IErlModule> modules = projectModuleCache.getIfPresent(project);
    if (modules != null) {
        for (final IErlModule module : modules) {
            moduleIncludeCache.invalidate(module);
        }
    }
    projectIncludeCache.invalidate(project);
    projectModuleCache.invalidate(project);
    final Set<String> keysToRemove = Sets.newHashSet();
    final Set<Entry<String, Pair<IErlProject, List<ExternalTreeEntry>>>> entrySet = externalTreeCache.asMap().entrySet();
    for (final Entry<String, Pair<IErlProject, List<ExternalTreeEntry>>> entry : entrySet) {
        if (entry.getValue().getKey() == project) {
            keysToRemove.add(entry.getKey());
        }
    }
    for (final String keyToRemove : keysToRemove) {
        externalTreeCache.invalidate(keyToRemove);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ExternalTreeEntry(org.erlide.engine.services.search.ExternalTreeEntry) Entry(java.util.Map.Entry) IErlModule(org.erlide.engine.model.root.IErlModule) ExternalTreeEntry(org.erlide.engine.services.search.ExternalTreeEntry) List(java.util.List) Pair(org.eclipse.xtext.xbase.lib.Pair)

Aggregations

IErlProject (org.erlide.engine.model.root.IErlProject)123 IErlModule (org.erlide.engine.model.root.IErlModule)57 Test (org.junit.Test)47 IPath (org.eclipse.core.runtime.IPath)30 IProject (org.eclipse.core.resources.IProject)29 ErlProject (org.erlide.engine.internal.model.root.ErlProject)25 File (java.io.File)19 Path (org.eclipse.core.runtime.Path)16 CoreException (org.eclipse.core.runtime.CoreException)13 ErlModelException (org.erlide.engine.model.ErlModelException)13 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)13 IErlModel (org.erlide.engine.model.root.IErlModel)13 ArrayList (java.util.ArrayList)11 IErlElement (org.erlide.engine.model.IErlElement)10 IFile (org.eclipse.core.resources.IFile)9 IResource (org.eclipse.core.resources.IResource)9 HashSet (java.util.HashSet)7 IProjectDescription (org.eclipse.core.resources.IProjectDescription)7 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)6 IErlPreprocessorDef (org.erlide.engine.model.erlang.IErlPreprocessorDef)6