Search in sources :

Example 1 with ISourceUnit

use of org.erlide.engine.model.root.ISourceUnit 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)

Example 2 with ISourceUnit

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

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

the class IErlModuleTest method getXDependentModules.

// void finalReconcile();
// Empty method
// Set<IErlModule> getDirectDependentModules() throws ErlModelException;
// Set<IErlModule> getAllDependentModules() throws CoreException;
@Test
public void getXDependentModules() throws Exception {
    final String yyHrl = "yy.hrl";
    final IErlModule include = ErlideTestUtils.createInclude(project, yyHrl, "-include(\"zz.hrl\").\n-define(A, hej).\n");
    final IErlModule include2 = ErlideTestUtils.createInclude(project, "zz.hrl", "-define(B(X), lists:reverse(X)).\n");
    module.open(null);
    final Set<ISourceUnit> directDependents = module.getDirectDependentModules();
    final Set<ISourceUnit> allDependents = module.getAllDependentModules();
    final Set<ISourceUnit> directDependents2 = include.getDirectDependentModules();
    final Set<ISourceUnit> allDependents2 = include.getAllDependentModules();
    final Set<ISourceUnit> directDependents3 = include2.getDirectDependentModules();
    final Set<ISourceUnit> allDependents3 = include2.getAllDependentModules();
    final Set<ISourceUnit> dependentModules = module.getDirectDependentModules();
    assertEquals(0, directDependents.size());
    assertEquals(0, allDependents.size());
    assertEquals(1, directDependents2.size());
    assertEquals(module, directDependents2.iterator().next());
    assertEquals(1, allDependents2.size());
    assertEquals(module, allDependents2.iterator().next());
    assertEquals(0, directDependents3.size());
    assertEquals(1, allDependents3.size());
    assertEquals(module, allDependents3.iterator().next());
    assertEquals(0, dependentModules.size());
}
Also used : ISourceUnit(org.erlide.engine.model.root.ISourceUnit) IErlModule(org.erlide.engine.model.root.IErlModule) Test(org.junit.Test)

Aggregations

IErlModule (org.erlide.engine.model.root.IErlModule)3 ISourceUnit (org.erlide.engine.model.root.ISourceUnit)3 HashSet (java.util.HashSet)2 IErlProject (org.erlide.engine.model.root.IErlProject)2 ErlangIncludeFile (org.erlide.engine.model.erlang.ErlangIncludeFile)1 Test (org.junit.Test)1