public List<ExternalTreeEntry> getExternalModuleTree(final IOtpRpc backend,
final String externalModules, final OtpErlangList pathVars) {
if (ModelConfig.verbose) {
ErlLogger.debug("open:external_module_tree -> " + externalModules);
}
final Stopwatch stopwatch = Stopwatch.createStarted();
try {
final OtpErlangObject res = backend.call(ERLIDE_OPEN,
"get_external_module_tree", "x",
mkContext(externalModules, null, pathVars, null, null));
if (Util.isOk(res)) {
OtpErlangTuple t = (OtpErlangTuple) res;
final OtpErlangList l = (OtpErlangList) t.elementAt(1);
final List<ExternalTreeEntry> result = Lists.newArrayListWithCapacity(l
.arity());
for (final OtpErlangObject i : l) {
t = (OtpErlangTuple) i;
final String parentPath = Util.stringValue(t.elementAt(0));
final String path = Util.stringValue(t.elementAt(1));
final OtpErlangAtom isModuleA = (OtpErlangAtom) t.elementAt(2);
result.add(new ExternalTreeEntry(parentPath, path, isModuleA
.atomValue().equals("module")));
}
final String msg = "open:external_module_tree <- " + stopwatch;
if (stopwatch.elapsed(TimeUnit.SECONDS) > 5) {
ErlLogger.warn("WARNING " + msg);
} else {
if (ModelConfig.verbose) {
ErlLogger.debug(msg);
}