if (names.size() == 1) {
return resolveAsName(names.get(0), context);
} else if (names.size() == 2) {
String name = names.get(1);
Path.ID mid = resolveAsModule(names.get(0), context);
NameID nid = new NameID(mid, name);
if (builder.isName(nid)) {
if (isNameVisible(nid, context)) {
return nid;
} else {
throw new ResolveError(nid + " is not visible");
}
}
} else {
String name = names.get(names.size() - 1);
String module = names.get(names.size() - 2);
Path.ID pkg = Trie.ROOT;
for (int i = 0; i != names.size() - 2; ++i) {
pkg = pkg.append(names.get(i));
}
Path.ID mid = pkg.append(module);
NameID nid = new NameID(mid, name);
if (builder.isName(nid)) {
if (isNameVisible(nid, context)) {
return nid;
} else {
throw new ResolveError(nid + " is not visible");