use of org.erlide.engine.model.IErlElement 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.IErlElement in project erlide_eclipse by erlang.
the class FindAction method getProjects.
protected Collection<IProject> getProjects() {
final TextEditor editor = getEditor();
if (editor != null) {
final IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
final IFileEditorInput input = (IFileEditorInput) editorInput;
final IFile file = input.getFile();
final IProject project = file.getProject();
return Lists.newArrayList(project);
}
} else {
final IWorkbenchSite site = getSite();
final ISelection selection = site.getSelectionProvider().getSelection();
if (selection instanceof IStructuredSelection) {
final IStructuredSelection ss = (IStructuredSelection) selection;
final Collection<IProject> result = Sets.newHashSet();
for (final Object element : ss.toList()) {
if (element instanceof IErlElement) {
final IErlElement e = (IErlElement) element;
result.add(e.getResource().getProject());
} else if (element instanceof IResource) {
final IResource r = (IResource) element;
result.add(r.getProject());
}
}
return result;
}
}
return null;
}
use of org.erlide.engine.model.IErlElement 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;
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class ErlElementDelta method createDeltaTree.
/**
* Creates the nested delta deltas based on the affected element its delta, and the
* root of this delta tree. Returns the root of the created delta tree.
*/
protected ErlElementDelta createDeltaTree(final IErlElement element, final ErlElementDelta delta) {
ErlElementDelta childDelta = delta;
final List<IParent> ancestors = getAncestors(element);
if (ancestors == null) {
if (equalsAndSameParent(delta.getElement(), getElement())) {
// handle case of two jars that can be equals but not in the
// same project
// the element being changed is the root element
fKind = delta.fKind;
fFlags = delta.fFlags;
fMovedToElement = delta.fMovedToElement;
fMovedFromElement = delta.fMovedFromElement;
} else {
// the given delta is not the root or a child - illegal
// Assert.isTrue(false);
}
} else {
for (final IParent ancestor : ancestors) {
final IErlElement element2 = (IErlElement) ancestor;
final ErlElementDelta ancestorDelta = new ErlElementDelta(0, 0, element2);
ancestorDelta.addAffectedChild(childDelta);
childDelta = ancestorDelta;
}
}
return childDelta;
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class ErlModule method getIncludeFiles.
@Override
public Collection<ErlangIncludeFile> getIncludeFiles() throws ErlModelException {
if (!isStructureKnown()) {
open(null);
}
final List<ErlangIncludeFile> r = Lists.newArrayList();
synchronized (getModelLock()) {
for (final IErlElement m : internalGetChildren()) {
if (m instanceof IErlAttribute) {
final IErlAttribute a = (IErlAttribute) m;
final OtpErlangObject v = a.getValue();
if (v instanceof OtpErlangString) {
final String s = ((OtpErlangString) v).stringValue();
if ("include".equals(a.getName())) {
r.add(new ErlangIncludeFile(false, s));
} else if ("include_lib".equals(a.getName())) {
r.add(new ErlangIncludeFile(true, s));
}
}
}
}
}
return r;
}
Aggregations