use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ModelFindUtil method findTypespec.
@Override
public IErlTypespec findTypespec(final IErlModule module, final String name) throws CoreException {
IErlTypespec typespec = module.findTypespec(name);
if (typespec != null) {
return typespec;
}
final Collection<IErlModule> includedFiles = findAllIncludedFiles(module);
for (final IErlModule includedFile : includedFiles) {
typespec = includedFile.findTypespec(name);
if (typespec != null) {
return typespec;
}
}
return null;
}
use of org.erlide.engine.model.root.IErlModule 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;
}
use of org.erlide.engine.model.root.IErlModule 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;
}
use of org.erlide.engine.model.root.IErlModule 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;
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ModelInternalUtils method addUnitNamesWithPrefix.
private void addUnitNamesWithPrefix(final String prefix, final List<String> result, final Collection<IErlModule> modules, final boolean external, final boolean includes) {
for (final IErlModule module : modules) {
String moduleName = includes ? module.getName() : module.getModuleName();
if (external && includes) {
moduleName = getIncludeLibPath(module);
}
boolean nameMatches = moduleName.startsWith(prefix);
if (!nameMatches && prefix.startsWith("'")) {
nameMatches = moduleName.startsWith(prefix.substring(1));
}
if (nameMatches && (includes || !module.getName().endsWith(".hrl"))) {
if (!result.contains(moduleName)) {
final String name = new OtpErlangAtom(moduleName).toString();
result.add(name);
}
}
}
}
Aggregations