use of org.erlide.engine.model.ErlModelStatus 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.ErlModelStatus in project erlide_eclipse by erlang.
the class ErlFolder method buildStructure.
@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
final IErlModel model = ErlangEngine.getInstance().getModel();
final IContainer c = (IContainer) getResource();
try {
// FIXME this is general stuff -> model or model manager?
final IResource[] members = c.members();
for (final IResource resource : members) {
model.create(resource);
}
} catch (final CoreException e) {
throw new ErlModelException(new ErlModelStatus(ErlModelStatusConstants.CORE_EXCEPTION, e));
}
return true;
}
use of org.erlide.engine.model.ErlModelStatus in project erlide_eclipse by erlang.
the class ErlModel method newProject.
@Override
public final IErlProject newProject(final String name) throws ErlModelException {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final IProject project = ws.getRoot().getProject(name);
try {
if (!project.exists()) {
project.create(null);
project.open(null);
final IProjectDescription description = project.getDescription();
description.setNatureIds(new String[] { ModelPlugin.NATURE_ID });
description.setName(name);
project.setDescription(description, null);
}
if (!project.isOpen()) {
project.open(null);
}
return findProject(project);
} catch (final CoreException e) {
e.printStackTrace();
throw new ErlModelException(e, new ErlModelStatus(e));
}
}
Aggregations