use of com.android.tools.idea.gradle.structure.model.android.PsAndroidArtifact in project android by JetBrains.
the class DependencyNodes method createNodesFor.
@NotNull
static List<AbstractPsModelNode<?>> createNodesFor(@NotNull AndroidArtifactNode parent, @NotNull Collection<PsDependency> dependencies) {
List<AbstractPsModelNode<?>> children = Lists.newArrayList();
List<PsDependency> declared = new SortedList<>(PsDependencyComparator.INSTANCE);
Multimap<PsDependency, PsDependency> allTransitive = HashMultimap.create();
List<PsDependency> mayBeTransitive = Lists.newArrayList();
for (PsDependency dependency : dependencies) {
Collection<DependencyModel> parsedModels = dependency.getParsedModels();
if (parsedModels.isEmpty()) {
mayBeTransitive.add(dependency);
} else {
for (DependencyModel parsedModel : parsedModels) {
// "main" artifact.
for (PsAndroidArtifact artifact : parent.getModels()) {
if (artifact.contains(parsedModel)) {
declared.add(dependency);
break;
}
}
}
addTransitive(dependency, allTransitive);
}
}
Collection<PsDependency> uniqueTransitives = allTransitive.values();
declared.addAll(mayBeTransitive.stream().filter(dependency -> !uniqueTransitives.contains(dependency)).collect(Collectors.toList()));
for (PsDependency dependency : declared) {
AbstractDependencyNode<?> child = AbstractDependencyNode.createNode(parent, dependency);
if (child != null) {
children.add(child);
}
}
return children;
}
Aggregations