final List<ExternalTreeEntry> externalTree, final IErlModel model,
final String rootName, final List<String> otherItems, final boolean includeDir)
throws ErlModelException {
final Map<String, IErlExternal> pathToEntryMap = Maps.newHashMap();
pathToEntryMap.put("root", this);
IErlExternal parent = null;
if (externalTree != null && !externalTree.isEmpty()) {
for (final ExternalTreeEntry entry : externalTree) {
final String path = entry.getPath();
if (path.isEmpty()) {
continue;
}
// final String name = entry.getName();
parent = pathToEntryMap.get(entry.getParentPath());
if (entry.isModule()) {
final IErlModule module = model.getModuleFromFile(parent,
getNameFromPath(path), path, null, path);
parent.addChild(module);
} else {
final String name = 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, "." + rootName
+ ".", true, includeDir);
addChild(parent);
}
for (final String path : otherItems) {
final IErlModule module = model.getModuleFromFile(parent,
getNameFromPath(path), path, null, path);
parent.addChild(module);
}
}
}