use of org.erlide.engine.model.erlang.ErlangIncludeFile 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.erlang.ErlangIncludeFile in project erlide_eclipse by erlang.
the class ErlModule method getIncludeFiles.
@Override
public Collection<ErlangIncludeFile> getIncludeFiles() throws ErlModelException {
if (!isStructureKnown()) {
open(null);
}
final List<ErlangIncludeFile> r = Lists.newArrayList();
synchronized (getModelLock()) {
for (final IErlElement m : internalGetChildren()) {
if (m instanceof IErlAttribute) {
final IErlAttribute a = (IErlAttribute) m;
final OtpErlangObject v = a.getValue();
if (v instanceof OtpErlangString) {
final String s = ((OtpErlangString) v).stringValue();
if ("include".equals(a.getName())) {
r.add(new ErlangIncludeFile(false, s));
} else if ("include_lib".equals(a.getName())) {
r.add(new ErlangIncludeFile(true, s));
}
}
}
}
}
return r;
}
use of org.erlide.engine.model.erlang.ErlangIncludeFile 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.erlang.ErlangIncludeFile in project erlide_eclipse by erlang.
the class BuilderHelper method addDependents.
public void addDependents(final IResource resource, final IProject my_project, final Set<BuildResource> result) throws ErlModelException {
final IErlProject eprj = ErlangEngine.getInstance().getModel().findProject(my_project);
if (eprj != null) {
final Collection<IErlModule> ms = eprj.getModules();
for (final IErlModule m : ms) {
final Collection<ErlangIncludeFile> incs = m.getIncludeFiles();
for (final ErlangIncludeFile ifile : incs) {
if (ResourceUtil.samePath(ifile.getFilename(), resource.getName())) {
if (m.getSourceKind() == SourceKind.ERL) {
final BuildResource bres = new BuildResource(m.getResource());
result.add(bres);
}
break;
}
}
}
}
}
use of org.erlide.engine.model.erlang.ErlangIncludeFile in project erlide_eclipse by erlang.
the class BuilderHelper method shouldCompileModule.
private boolean shouldCompileModule(final IProject project, final IResource source, final IResource beam, final boolean shouldCompile0, final IErlProject eprj) throws ErlModelException {
boolean shouldCompile = shouldCompile0;
final IErlModule m = eprj.getModule(source.getName());
if (m != null) {
final Collection<ErlangIncludeFile> incs = m.getIncludeFiles();
for (final ErlangIncludeFile ifile : incs) {
final IResource rifile = ResourceUtil.findResourceByName(project, ifile.getFilename());
if (rifile != null && rifile.getLocalTimeStamp() > beam.getLocalTimeStamp()) {
shouldCompile = true;
break;
}
}
}
return shouldCompile;
}
Aggregations