use of org.erlide.engine.model.root.IErlFolder in project erlide_eclipse by erlang.
the class DialyzerUtils method collectModulesFromResource.
public static Set<IErlModule> collectModulesFromResource(final IErlElementLocator model, final IResource resource) throws ErlModelException {
final Set<IErlModule> result = Sets.newHashSet();
final IErlElement element = model.findElement(resource, true);
if (element == null) {
return result;
}
if (element instanceof IErlFolder) {
final IErlFolder folder = (IErlFolder) element;
folder.open(null);
result.addAll(folder.getModules());
} else if (element instanceof IErlModule) {
final IErlModule module = (IErlModule) element;
result.add(module);
} else if (element instanceof IErlProject) {
final IErlProject project = (IErlProject) element;
project.open(null);
result.addAll(project.getModules());
}
return result;
}
use of org.erlide.engine.model.root.IErlFolder in project erlide_eclipse by erlang.
the class ErlangElementImageProvider method computeDescriptor.
private ImageDescriptor computeDescriptor(final Object element, final int flags) {
if (element instanceof IErlElement) {
return ErlangElementImageProvider.getErlImageDescriptor((IErlElement) element, flags);
} else if (element instanceof IFile) {
final IFile file = (IFile) element;
if ("erl".equals(file.getFileExtension())) {
// $NON-NLS-1$
return getErlResourceImageDescriptor(file, flags);
// image for a CU not on the build path
}
return getWorkbenchImageDescriptor(file, flags);
} else if (element instanceof IFolder) {
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlFolder ef = (IErlFolder) model.findElement((IResource) element);
if (ef != null && (ef.isOnSourcePath() || ef.isOnIncludePath())) {
return ErlangElementImageProvider.getErlImageDescriptor(ef, flags);
}
} else if (element instanceof IAdaptable) {
return getWorkbenchImageDescriptor((IAdaptable) element, flags);
}
return null;
}
use of org.erlide.engine.model.root.IErlFolder in project erlide_eclipse by erlang.
the class ErlProject method buildStructure.
@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
final IResource r = getCorrespondingResource();
// check whether the Erlang project can be opened
if (!(r instanceof IContainer) || !r.isAccessible()) {
ErlLogger.warn("Project %s has no resources: res:%s acc:%s cont:%s", getName(), r, r == null ? "?" : r.isAccessible(), r instanceof IContainer);
throw new ErlModelException(new ErlModelStatus(ErlModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this));
}
addConfigurationChangeListeners();
try {
final IContainer c = (IContainer) r;
final IResource[] elems = c.members();
final List<IErlElement> children = new ArrayList<>(elems.length + 1);
// ErlLogger.debug(">>adding externals");
addExternals(children);
// ErlLogger.debug("childcount %d", children.size());
// ErlLogger.debug(">>adding otp");
addOtpExternals(children);
// ErlLogger.debug("childcount %d", children.size());
final IErlModel model = ErlangEngine.getInstance().getModel();
for (final IResource element : elems) {
if (element instanceof IFolder) {
final IFolder folder = (IFolder) element;
final IErlFolder erlFolder = (IErlFolder) model.create(folder);
children.add(erlFolder);
} else if (element instanceof IFile) {
final IFile file = (IFile) element;
if (CommonUtils.isErlangFileContentFileName(file.getName())) {
final IErlModule m = (IErlModule) model.create(file);
children.add(m);
}
}
}
setChildren(children);
} catch (final CoreException e) {
ErlLogger.error(e);
setChildren(new ArrayList<IErlModule>());
return false;
}
return true;
}
use of org.erlide.engine.model.root.IErlFolder in project erlide_eclipse by erlang.
the class ErlModel method createFolder.
public IErlFolder createFolder(final IFolder folder, final IParent parent) {
if (folder == null) {
return null;
}
final IErlFolder f = new ErlFolder(folder, parent);
final IParent p = parent;
if (p != null) {
p.addChild(f);
} else {
// ErlLogger.warn("creating folder %s in null parent?!", folder
// .getName());
}
return f;
}
use of org.erlide.engine.model.root.IErlFolder 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);
}
Aggregations