use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.
the class IndexedErlangValue method getVariable.
@Override
public IVariable getVariable(final int offset) throws DebugException {
String name;
if (record != null) {
try {
final IErlRecordField recordField = (IErlRecordField) record.getChildren().get(offset);
name = recordField.getFieldName();
} catch (final ErlModelException e) {
name = varName + ":" + offset;
}
} else {
name = varName + ":" + offset;
}
return new ErlangVariable(getDebugTarget(), name, true, getElementAt(offset), process, moduleName, -1);
}
use of org.erlide.engine.model.ErlModelException 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.ErlModelException in project erlide_eclipse by erlang.
the class ErlProject method dispose.
@Override
public void dispose() {
removeConfigurationChangeListeners();
clearCaches();
try {
accept(new IErlElementVisitor() {
@Override
public boolean visit(final IErlElement element) throws ErlModelException {
element.dispose();
return false;
}
}, EnumSet.of(AcceptFlags.CHILDREN_FIRST, AcceptFlags.LEAFS_ONLY), ErlElementKind.MODULE);
} catch (final ErlModelException e) {
}
super.dispose();
}
use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.
the class ErlProject method getExternalModules.
@Override
public Collection<IErlModule> getExternalModules() 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.getAncestorOfKind(ErlElementKind.PROJECT) == ErlProject.this) {
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 SimpleCodeInspectionHandler method processFunctionResult.
private ArrayList<IErlElement> processFunctionResult(final Shell shell, final RpcResult result) throws OtpErlangRangeException {
final ArrayList<IErlElement> elements = new ArrayList<>();
final OtpErlangObject obj = result.getValue();
final OtpErlangTuple restuple = (OtpErlangTuple) obj;
final OtpErlangAtom resindicator = (OtpErlangAtom) restuple.elementAt(0);
if ("ok".equals(resindicator.atomValue())) {
final OtpErlangList erlangFunctionList = (OtpErlangList) restuple.elementAt(1);
for (int i = 0; i < erlangFunctionList.arity(); ++i) {
final OtpErlangTuple fTuple = (OtpErlangTuple) erlangFunctionList.elementAt(i);
IErlFunctionClause f;
try {
f = extractFunction(fTuple);
elements.add(f);
} catch (final ErlModelException e) {
}
}
} else {
final OtpErlangString s = (OtpErlangString) restuple.elementAt(1);
MessageDialog.openError(shell, "Error", s.stringValue());
return null;
}
return elements;
}
Aggregations