Search in sources :

Example 76 with IErlProject

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

the class SearchCoreUtil method getProjectsScope.

public static ErlSearchScope getProjectsScope(final Collection<IProject> projects, final boolean addExternals, final boolean addOtp) throws CoreException {
    final ErlSearchScope result = new ErlSearchScope();
    final Set<String> externalModulePaths = new HashSet<>();
    final IErlModel model = ErlangEngine.getInstance().getModel();
    for (final IProject project : projects) {
        SearchCoreUtil.addProjectToScope(project, result);
        if (NatureUtil.hasErlangNature(project)) {
            final IErlProject erlProject = model.getErlangProject(project);
            SearchCoreUtil.addExternalModules(erlProject, result, externalModulePaths, addExternals, addOtp);
        }
    }
    return result;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModel(org.erlide.engine.model.root.IErlModel) ErlSearchScope(org.erlide.engine.services.search.ErlSearchScope) IProject(org.eclipse.core.resources.IProject) HashSet(java.util.HashSet)

Example 77 with IErlProject

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

the class DialyzerUtils method collectFilesAndIncludeDirs.

public static void collectFilesAndIncludeDirs(final Set<IErlModule> modules, final Set<IErlProject> projects, final Collection<String> files, final Collection<String> names, final Collection<IPath> includeDirs, final boolean fromSource) {
    for (final IErlModule m : modules) {
        final String name = m.getName();
        final IErlProject erlProject = ErlangEngine.getInstance().getModelUtilService().getProject(m);
        final IProject project = erlProject.getWorkspaceProject();
        final IFolder ebin = project.getFolder(erlProject.getProperties().getOutputDir());
        if (SourceKind.hasErlExtension(name)) {
            if (fromSource) {
                final IResource resource = m.getResource();
                files.add(resource.getLocation().toPortableString());
            } else {
                final String moduleName = SystemConfiguration.withoutExtension(name);
                final String beamName = moduleName + ".beam";
                final IResource beam = ebin.findMember(beamName);
                if (beam != null) {
                    files.add(beam.getLocation().toPortableString());
                    names.add(moduleName);
                }
            }
        }
    }
    DialyzerUtils.helper = new BuilderHelper();
    for (final IErlProject p : projects) {
        includeDirs.addAll(DialyzerUtils.helper.getIncludeDirs(p.getWorkspaceProject()));
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) BuilderHelper(org.erlide.core.builder.BuilderHelper) IErlModule(org.erlide.engine.model.root.IErlModule) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Example 78 with IErlProject

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

the class ErlExternalReferenceEntry method buildStructure.

@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
    if (prebuilt) {
        // already done
        return true;
    }
    final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(this);
    final IOtpRpc backend = OtpRpcFactory.getOtpRpcForProject(project);
    if (backend != null) {
        final List<String> files = ErlangEngine.getInstance().getOpenService().getLibFiles(path.toPortableString());
        final List<IErlModule> children = Lists.newArrayListWithCapacity(files.size());
        for (final String file : files) {
            if (CommonUtils.isErlangFileContentFileName(getName(file))) {
                children.add(new ErlModule(this, getName(file), file, null, null));
            }
        }
        setChildren(children);
        return true;
    }
    return false;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule) IErlModule(org.erlide.engine.model.root.IErlModule) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc)

Example 79 with IErlProject

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

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

the class ErlModule method getDirectDependentModules.

@Override
public Set<ISourceUnit> getDirectDependentModules() throws ErlModelException {
    final Set<ISourceUnit> result = new HashSet<>();
    final IErlProject project = modelUtilService.getProject(this);
    for (final IErlModule module : project.getModules()) {
        final boolean wasOpen = module.isOpen();
        if (!wasOpen) {
            module.open(null);
        }
        final Collection<ErlangIncludeFile> incs = module.getIncludeFiles();
        for (final ErlangIncludeFile inc : incs) {
            if (inc.getFilename().equals(getName())) {
                result.add(module);
                break;
            }
        }
        if (!wasOpen) {
            module.close();
        }
    }
    return result;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlangIncludeFile(org.erlide.engine.model.erlang.ErlangIncludeFile) ISourceUnit(org.erlide.engine.model.root.ISourceUnit) IErlModule(org.erlide.engine.model.root.IErlModule) HashSet(java.util.HashSet)

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