use of com.facebook.buck.apple.xcode.xcodeproj.PBXReference.SourceTree in project bazel by bazelbuild.
the class PbxReferencesGrouper method process.
@Override
public Iterable<PBXReference> process(Iterable<PBXReference> references) {
Map<SourceTree, Groups> groupsBySourceTree = ImmutableMap.of(SourceTree.GROUP, new Groups("workspace_root", SourceTree.GROUP), SourceTree.SDKROOT, new Groups("SDKROOT", SourceTree.SDKROOT), SourceTree.BUILT_PRODUCTS_DIR, new Groups("BUILT_PRODUCTS_DIR", SourceTree.BUILT_PRODUCTS_DIR));
ImmutableList.Builder<PBXReference> result = new ImmutableList.Builder<>();
for (PBXReference reference : references) {
if (Containing.key(groupsBySourceTree, reference.getSourceTree())) {
Path containingDir = dirOfContainingPbxGroup(reference);
Mapping.of(groupsBySourceTree, reference.getSourceTree()).get().add(containingDir, reference);
} else {
// The reference is not inside any expected source tree, so don't try anything clever. Just
// add it to the main group directly (not in a nested PBXGroup).
result.add(reference);
}
}
for (Groups groupsRoot : groupsBySourceTree.values()) {
if (!groupsRoot.rootGroup().getChildren().isEmpty()) {
result.add(groupsRoot.rootGroup());
}
}
return result.build();
}
Aggregations