use of org.erlide.engine.model.root.IErlExternal in project erlide_eclipse by erlang.
the class ModelInternalUtils method isOtpModule.
@Override
public boolean isOtpModule(final IErlModule module) {
IParent parent = module.getParent();
while (parent instanceof IErlExternal) {
final IErlExternal external = (IErlExternal) parent;
if (external.isOTP()) {
return true;
}
parent = external.getParent();
}
return false;
}
use of org.erlide.engine.model.root.IErlExternal in project erlide_eclipse by erlang.
the class ModelInternalUtils method getExternalModulePath.
@Override
public String getExternalModulePath(final IErlElementLocator model, final IErlModule module) {
final List<String> result = Lists.newArrayList();
IErlElement element = module;
while (element != model) {
if (element instanceof IErlExternal) {
final IErlExternal external = (IErlExternal) element;
result.add(external.getName());
} else {
result.add(element.getName());
}
element = (IErlElement) element.getParent();
}
return Joiner.on(ModelInternalUtils.DELIMITER).join(Lists.reverse(result));
}
use of org.erlide.engine.model.root.IErlExternal in project erlide_eclipse by erlang.
the class OpenErlangAction method run.
@Override
public void run() {
if (isEnabled()) {
try {
if (selectedElement != null) {
if (selectedElement instanceof IErlExternal) {
final StructuredViewer structuredViewer = site.getStructuredViewer();
if (structuredViewer instanceof AbstractTreeViewer) {
final AbstractTreeViewer treeViewer = (AbstractTreeViewer) structuredViewer;
final boolean expanded = treeViewer.getExpandedState(selectedElement);
treeViewer.setExpandedState(selectedElement, !expanded);
}
} else {
final IEditorPart part = EditorUtility.openInEditor(selectedElement, true);
EditorUtility.revealInEditor(part, selectedElement);
}
} else if (!selectedClosedProjects.isEmpty()) {
openResourceAction.selectionChanged((IStructuredSelection) provider.getSelection());
openResourceAction.run();
}
} catch (final PartInitException e) {
ErlLogger.warn(e);
}
}
}
use of org.erlide.engine.model.root.IErlExternal in project erlide_eclipse by erlang.
the class EditorUtility method getEditorInput.
private static IEditorInput getEditorInput(final IErlElement element0) {
IErlElement element = element0;
final IResource resource = element.getResource();
if (resource instanceof IFile) {
IFile file = (IFile) resource;
file = EditorUtility.resolveFile(file);
return new FileEditorInput(file);
}
String filePath = element.getFilePath();
while (filePath == null) {
final IParent parent = element.getParent();
if (parent instanceof IErlElement) {
element = (IErlElement) parent;
filePath = element.getFilePath();
} else {
break;
}
}
if (filePath != null) {
final IPath path = new Path(filePath);
IFileStore fileStore = EFS.getLocalFileSystem().getStore(path.removeLastSegments(1));
fileStore = fileStore.getChild(path.lastSegment());
final IFileInfo fetchInfo = fileStore.fetchInfo();
if (!fetchInfo.isDirectory() && fetchInfo.exists()) {
if (element instanceof IErlModule && element.getParent() instanceof IErlExternal) {
return new ErlangExternalEditorInput(fileStore, (IErlModule) element);
}
return new FileStoreEditorInput(fileStore);
}
}
return null;
}
use of org.erlide.engine.model.root.IErlExternal in project erlide_eclipse by erlang.
the class ErlExternalReferenceEntryList method addExternalEntries.
private void addExternalEntries(final IProgressMonitor pm, final List<ExternalTreeEntry> externalTree, final IErlModel model, final String rootName, final List<String> otherItems, final boolean includeDir) throws ErlModelException {
final Map<IPath, IErlExternal> pathToEntryMap = Maps.newHashMap();
pathToEntryMap.put(new Path("root"), this);
IErlExternal parent = null;
if (externalTree != null && !externalTree.isEmpty()) {
for (final ExternalTreeEntry entry : externalTree) {
final IPath path = entry.getPath();
parent = pathToEntryMap.get(entry.getParentPath());
if (entry.isModule()) {
final IErlModule module = model.getModuleFromFile(parent, getNameFromPath(path), path, null);
parent.addChild(module);
} else {
final String name = ErlExternalReferenceEntryList.getNameFromExternalPath(path);
final ErlExternalReferenceEntry externalReferenceEntry = new ErlExternalReferenceEntry(parent, name, path, true, includeDir);
pathToEntryMap.put(path, externalReferenceEntry);
externalReferenceEntry.open(pm);
parent.addChild(externalReferenceEntry);
}
}
}
if (otherItems != null) {
if (parent == null) {
parent = new ErlExternalReferenceEntry(this, rootName, new Path("." + rootName + "."), true, includeDir);
addChild(parent);
}
for (final String path : otherItems) {
IPath apath = new Path(path);
final IErlModule module = model.getModuleFromFile(parent, getNameFromPath(apath), apath, null);
parent.addChild(module);
}
}
}
Aggregations