// :Package -> fully qualified class name [from] -> set of fully qualified class names [to] private Map<String, Map<String, Set<String>>> getDependencies( Context context, Collection<JavaFileObject> explicitJFOs, boolean cp) { Map<String, Map<String, Set<String>>> result = new HashMap<>(); for (CompletionNode cnode : getDependencyNodes(context, explicitJFOs, true)) { String fqDep = cnode.getClassSymbol().outermostClass().flatname.toString(); String depPkg = Util.pkgNameOfClassName(fqDep); Map<String, Set<String>> depsForThisClass = result.get(depPkg); if (depsForThisClass == null) { result.put(depPkg, depsForThisClass = new HashMap<>()); } Set<String> fqDeps = depsForThisClass.get(fqDep); if (fqDeps == null) { depsForThisClass.put(fqDep, fqDeps = new HashSet<>()); } for (Node<?, ?> depNode : getAllDependencies(cnode)) { CompletionNode cDepNode = (CompletionNode) depNode; // Symbol is not regarded to depend on itself. if (cDepNode == cnode) { continue; } // Skip anonymous classes if (cDepNode.getClassSymbol().fullname == null) { continue; } if (isSymbolRelevant(cp, cDepNode.getClassSymbol())) { fqDeps.add(cDepNode.getClassSymbol().outermostClass().flatname.toString()); } } // The completion dependency graph is not transitively closed for inheritance relations. // For sjavac's purposes however, a class depends on it's super super type, so below we // make sure that we include super types. for (ClassSymbol cs : allSupertypes(cnode.getClassSymbol())) { if (isSymbolRelevant(cp, cs)) { fqDeps.add(cs.outermostClass().flatname.toString()); } } } return result; }
private void collectPubApisOfDependencies( Context context, Collection<JavaFileObject> explicitJFOs) { PubAPIs pubApis = PubAPIs.instance(context); for (CompletionNode cDepNode : getDependencyNodes(context, explicitJFOs, false)) { ClassSymbol cs = cDepNode.getClassSymbol().outermostClass(); Location loc = getLocationOf(cs); // We're completely ignorant of PLATFORM_CLASS_PATH classes if (loc == StandardLocation.CLASS_PATH || loc == StandardLocation.SOURCE_PATH) pubApis.visitPubapi(cs); } }