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;
}
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;
}
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());
}
Aggregations