use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.
the class ErlProject method getExternalIncludes.
@Override
public Collection<IErlModule> getExternalIncludes() throws ErlModelException {
final List<IErlModule> result = Lists.newArrayList();
accept(new IErlElementVisitor() {
@Override
public boolean visit(final IErlElement element) throws ErlModelException {
final boolean isExternalOrProject = element.getKind() == ErlElementKind.EXTERNAL_ROOT || element.getKind() == ErlElementKind.EXTERNAL_APP || element.getKind() == ErlElementKind.EXTERNAL_FOLDER || element.getKind() == ErlElementKind.PROJECT;
if (element instanceof IErlModule) {
final IErlModule module = (IErlModule) element;
if (module.getSourceKind() == SourceKind.HRL && (module.getAncestorOfKind(ErlElementKind.PROJECT) == ErlProject.this || element.getKind() == ErlElementKind.EXTERNAL_APP || element.getKind() == ErlElementKind.EXTERNAL_FOLDER)) {
result.add(module);
}
return false;
} else if (isExternalOrProject && element instanceof IOpenable) {
final IOpenable openable = (IOpenable) element;
openable.open(null);
}
return isExternalOrProject;
}
}, EnumSet.noneOf(AcceptFlags.class), ErlElementKind.MODULE);
return result;
}
use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.
the class ErlModel method findElement.
@Override
public IErlElement findElement(final IResource rsrc, final boolean openElements) {
if (rsrc == null) {
return null;
}
final IPath path = rsrc.getFullPath();
IParent p = this;
for (final String segment : path.segments()) {
IErlElement c = p.getChildWithResource(rsrc);
if (c != null) {
return c;
}
c = p.getChildNamed(segment);
if (c == null) {
return null;
}
if (openElements && c instanceof IOpenable) {
final IOpenable o = (IOpenable) c;
try {
o.open(null);
} catch (final ErlModelException e) {
return null;
}
}
final IResource resource = c.getResource();
if (resource != null && resource.equals(rsrc)) {
return c;
}
p = (IParent) c;
}
return null;
}
use of org.erlide.engine.model.ErlModelException 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));
}
}
use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.
the class ErlModel method remove.
void remove(final IResource rsrc) {
final IErlElement element = findElement(rsrc);
if (element != null) {
final IParent p = element.getParent();
p.removeChild(element);
if (element instanceof IOpenable) {
final IOpenable openable = (IOpenable) element;
try {
openable.close();
} catch (final ErlModelException e) {
ErlLogger.error(e);
}
}
}
// TODO should we make Erlidemodelevents and fire them?
}
use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.
the class ErlElement method toStringChildren.
/**
* Debugging purposes
*/
protected void toStringChildren(final int tab, final StringBuilder buffer, final Object info) {
if (!(info instanceof ErlElement)) {
return;
}
if (getChildCount() > 0) {
buffer.append("{");
int i = 0;
try {
for (final IErlElement element : getChildren()) {
((ErlElement) element).toString(tab + 1, buffer);
// $NON-NLS-1$
buffer.append(",");
if (++i > 3) {
buffer.append("...");
break;
}
}
} catch (final ErlModelException e) {
}
buffer.deleteCharAt(buffer.length() - 1);
buffer.append("}");
}
}
Aggregations