use of org.erlide.engine.model.IParent in project erlide_eclipse by erlang.
the class ErlangExternalsContentProvider method getParent.
@Override
public Object getParent(final Object element) {
if (element instanceof IErlElement) {
final IErlElement elt = (IErlElement) element;
IParent parent = elt.getParent();
final String filePath = elt.getFilePath();
if (parent == ErlangEngine.getInstance().getModel() && filePath != null) {
parent = elt.getParent();
}
if (parent instanceof IErlModule) {
final IErlModule mod = (IErlModule) parent;
final IResource resource = mod.getCorrespondingResource();
if (resource != null) {
return resource;
}
} else {
return parent;
}
}
return null;
}
use of org.erlide.engine.model.IParent in project erlide_eclipse by erlang.
the class ErlangFileContentProvider method getChildren.
/**
* Return the model elements for a *.erl IFile or NO_CHILDREN for otherwise.
*/
@Override
public Object[] getChildren(final Object parentElement0) {
Object parentElement = parentElement0;
try {
if (parentElement instanceof IFile) {
parentElement = ErlangEngine.getInstance().getModel().findModule((IFile) parentElement);
}
if (parentElement instanceof IOpenable) {
final IOpenable openable = (IOpenable) parentElement;
openable.open(null);
}
if (parentElement instanceof IParent) {
final IParent parent = (IParent) parentElement;
final Collection<IErlElement> children = parent.getChildren();
return children.toArray();
}
} catch (final ErlModelException e) {
ErlLogger.warn(e);
}
return ErlangFileContentProvider.NO_CHILDREN;
}
use of org.erlide.engine.model.IParent in project erlide_eclipse by erlang.
the class SearchUtil method getWorkingSetsScope.
public static ErlSearchScope getWorkingSetsScope(final IWorkingSet[] workingSets, final boolean addExternals, final boolean addOTP) throws CoreException {
final ErlSearchScope result = new ErlSearchScope();
final Set<String> externalModulePaths = new HashSet<>();
if (workingSets == null) {
return result;
}
for (final IWorkingSet ws : workingSets) {
final IAdaptable[] elements = ws.getElements();
for (final IAdaptable a : elements) {
final IResource r = a.getAdapter(IResource.class);
SearchCoreUtil.addResourceToScope(result, r);
IParent parent = null;
Object o = a.getAdapter(IErlElement.class);
if (o instanceof IParent) {
parent = (IParent) o;
} else {
o = a.getAdapter(IResource.class);
if (o != null) {
final IResource resource = (IResource) o;
final IErlElement element = ErlangEngine.getInstance().getModel().findElement(resource);
if (element instanceof IParent) {
parent = (IParent) element;
}
}
}
if (parent != null) {
SearchCoreUtil.addExternalModules(parent, result, externalModulePaths, addExternals, addOTP);
}
}
}
return result;
}
use of org.erlide.engine.model.IParent in project erlide_eclipse by erlang.
the class SearchUtil method getSelectionScope.
public static ErlSearchScope getSelectionScope(final ISelection selection, final boolean addExternals, final boolean addOtp) throws CoreException {
final ErlSearchScope result = new ErlSearchScope();
final Set<String> externalModulePaths = new HashSet<>();
if (selection instanceof IStructuredSelection) {
final IStructuredSelection ss = (IStructuredSelection) selection;
for (final Object i : ss.toList()) {
if (i instanceof IResource) {
final IResource r = (IResource) i;
SearchCoreUtil.addResourceToScope(result, r);
} else if (i instanceof IErlModule) {
final IErlModule module = (IErlModule) i;
result.addModule(module);
} else if (i instanceof IParent) {
final IParent parent = (IParent) i;
SearchCoreUtil.addExternalModules(parent, result, externalModulePaths, addExternals, addOtp);
}
}
}
return result;
}
use of org.erlide.engine.model.IParent in project erlide_eclipse by erlang.
the class ErlElementDelta method getAncestors.
private List<IParent> getAncestors(final IErlElement element0) {
IErlElement element = element0;
IParent parent = element.getParent();
if (parent == null) {
return null;
}
final ArrayList<IParent> parents = Lists.newArrayList();
while (!parent.equals(fElement)) {
parents.add(parent);
if (parent instanceof IErlElement) {
element = (IErlElement) parent;
parent = element.getParent();
} else {
break;
}
if (parent == null) {
break;
}
}
parents.trimToSize();
return parents;
}
Aggregations