use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlModel method tryFindModule.
private IErlModule tryFindModule(final Collection<IErlProject> projects, final String moduleName, final String modulePath, final List<IErlModule> allModules, final Set<String> paths, final boolean externalModules) throws ErlModelException {
IErlModule module;
for (final IErlProject project : projects) {
final Collection<IErlModule> modules = Lists.newArrayList();
final Collection<IErlModule> modulesOrExternals = externalModules ? project.getExternalModules() : project.getModules();
ErlModel.getAllModulesAux(modulesOrExternals, modules, paths);
allModules.addAll(modules);
module = findModule(modules, moduleName, modulePath);
if (module != null) {
return module;
}
}
return null;
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlModel method findIncludeFromModule.
@Override
public IErlModule findIncludeFromModule(final IErlModule module, final String includeName, final String includePath, final IErlElementLocator.Scope scope) throws ErlModelException {
final IParent parent = module.getParent();
if (parent instanceof IErlFolder) {
final IErlFolder folder = (IErlFolder) parent;
folder.open(null);
final IErlModule include = folder.findInclude(includeName, includePath);
if (include != null) {
return include;
}
}
return findIncludeFromProject(ErlangEngine.getInstance().getModelUtilService().getProject(module), includeName, includePath, true, scope);
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlModel method findFunction.
@Override
public IErlFunction findFunction(final FunctionRef r) throws ErlModelException {
final IErlModule module = findModule(r.module);
if (module == null) {
return null;
}
module.open(null);
return module.findFunction(new ErlangFunction(r.function, r.arity));
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlModel method findIncludeFromProject.
private IErlModule findIncludeFromProject(final IErlProject project, final String includeName, final String includePath, final boolean checkExternals, final IErlElementLocator.Scope scope) throws ErlModelException {
if (project != null) {
final IErlModule module = ErlModel.getModuleFromCacheByNameOrPath((ErlProject) project, includeName, includePath, scope);
if (module != null && module.isOnIncludePath()) {
return module;
}
}
final Collection<IErlModule> includes = getAllIncludes(project, checkExternals, scope);
ErlModelCache.getDefault().putModules(includes);
if (includePath != null) {
for (final IErlModule module2 : includes) {
final String path2 = module2.getFilePath();
if (path2 != null && includePath.equals(path2)) {
return module2;
}
}
}
if (includeName != null) {
final boolean hasExtension = SystemConfiguration.hasExtension(includeName);
for (final IErlModule module2 : includes) {
final String name = hasExtension ? module2.getName() : module2.getModuleName();
if (ResourceUtil.samePath(includeName, name)) {
return module2;
}
}
}
return null;
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ModelFindUtil method findPreprocessorDef.
@Override
public IErlPreprocessorDef findPreprocessorDef(final IErlModule module, final String definedName, final ErlElementKind kind) throws CoreException {
String unquoted = StringUtils.unquote(definedName);
final String quoted = StringUtils.quote(definedName);
final Set<String> names = new HashSet<>(3);
if (kind == ErlElementKind.RECORD_DEF) {
while (names.add(unquoted)) {
unquoted = resolveMacroValue(unquoted, module);
}
} else {
names.add(unquoted);
}
names.add(quoted);
names.add(definedName);
final List<IErlModule> allIncludedFiles = Lists.newArrayList(findAllIncludedFiles(module));
allIncludedFiles.add(0, module);
for (final IErlModule includedFile : allIncludedFiles) {
for (final String name : names) {
includedFile.open(null);
final IErlPreprocessorDef preprocessorDef = includedFile.findPreprocessorDef(name, kind);
if (preprocessorDef != null) {
return preprocessorDef;
}
}
}
return null;
}
Aggregations