Search in sources :

Example 26 with IErlProject

use of org.erlide.engine.model.root.IErlProject 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 27 with IErlProject

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

the class ErlModel method getErlangProjects.

/**
 * @see IErlModel
 */
@Override
public Collection<IErlProject> getErlangProjects() throws ErlModelException {
    final Collection<IErlElement> list = getChildrenOfKind(ErlElementKind.PROJECT);
    final Collection<IErlProject> result = Lists.newArrayList();
    for (final IErlElement e : list) {
        result.add((IErlProject) e);
    }
    return result;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlProject(org.erlide.engine.model.root.IErlProject)

Example 28 with IErlProject

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

the class ModelFindUtil method findAllIncludedFiles.

public Collection<IErlModule> findAllIncludedFiles(final IErlModule module, final List<IErlModule> checked) throws CoreException {
    final Collection<IErlModule> result = Sets.newHashSet();
    if (checked.contains(module)) {
        return result;
    }
    checked.add(module);
    final List<IErlModule> includedFilesForModule = ErlModelCache.getDefault().getIncludedFilesForModule(module);
    if (includedFilesForModule != null && !includedFilesForModule.isEmpty()) {
        return includedFilesForModule;
    }
    final Collection<ErlangIncludeFile> includedFiles = module.getIncludeFiles();
    final IErlProject project = modelUtilService.getProject(module);
    if (project == null) {
        return result;
    }
    final Collection<IErlModule> includes = project.getIncludes();
    includes.addAll(getLocalIncludes(module));
    Collection<IErlModule> externalIncludes = null;
    Collection<IErlModule> referencedIncludes = null;
    Collection<IErlModule> modules = null;
    for (final ErlangIncludeFile includeFile : includedFiles) {
        final String includeFileName = includeFile.getFilenameLastPart();
        if (findAllIncludedFilesAux(checked, result, includes, includeFileName)) {
            continue;
        }
        if (referencedIncludes == null) {
            referencedIncludes = Lists.newArrayList();
            final Collection<IErlProject> referencedProjects = project.getReferencedProjects();
            for (final IErlProject referencedProject : referencedProjects) {
                referencedIncludes.addAll(referencedProject.getIncludes());
            }
        }
        if (findAllIncludedFilesAux(checked, result, referencedIncludes, includeFileName)) {
            continue;
        }
        if (externalIncludes == null) {
            externalIncludes = project.getExternalIncludes();
        }
        if (findAllIncludedFilesAux(checked, result, externalIncludes, includeFileName)) {
            continue;
        }
        if (modules == null) {
            modules = project.getModules();
        }
        findAllIncludedFilesAux(checked, result, modules, includeFileName);
    }
    ErlModelCache.getDefault().putIncludedFilesForModule(module, result);
    return result;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlangIncludeFile(org.erlide.engine.model.erlang.ErlangIncludeFile) IErlModule(org.erlide.engine.model.root.IErlModule)

Example 29 with IErlProject

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

the class ModelFindUtil method findExternalIncludeInOpenProjects.

public static IErlModule findExternalIncludeInOpenProjects(final IErlModule externalInclude) throws CoreException {
    final String filePath = externalInclude.getFilePath();
    final Collection<IErlProject> projects = ErlangEngine.getInstance().getModel().getErlangProjects();
    for (final IErlProject project : projects) {
        final Collection<IErlModule> includes = project.getIncludes();
        for (final IErlModule include : includes) {
            if (include.getFilePath().equals(filePath)) {
                return include;
            }
        }
    }
    return externalInclude;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule)

Example 30 with IErlProject

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

the class ModelInternalUtils method findUnitsWithPrefix.

@Override
public List<String> findUnitsWithPrefix(final String prefix, final IErlProject project, final boolean checkExternals, final boolean includes) throws ErlModelException {
    final List<String> result = Lists.newArrayList();
    final Collection<IErlModule> units = getUnits(project, checkExternals, includes);
    addUnitNamesWithPrefix(prefix, result, units, false, includes);
    if (project != null) {
        for (final IErlProject p : project.getReferencedProjects()) {
            if (p != null) {
                p.open(null);
                addUnitNamesWithPrefix(prefix, result, getUnits(p, checkExternals, includes), false, includes);
            }
        }
        if (checkExternals) {
            final Collection<IErlModule> externalUnits = includes ? project.getExternalIncludes() : project.getExternalModules();
            addUnitNamesWithPrefix(prefix, result, externalUnits, true, includes);
        }
    }
    return result;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule)

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