Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
Fix depset expansion when common nodes are traversed
Browse files Browse the repository at this point in the history
  • Loading branch information
SocksDevil committed Mar 5, 2021
1 parent 48e6fd0 commit ddc8f7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ private List<AnalysisProtos.Action> getActions(String targetLabel) {
private List<AnalysisProtos.Artifact> expandDepsetToArtifacts(String idToExpand) {
Queue<String> idsToExpand = new ArrayDeque<>(Lists.newArrayList(idToExpand));

HashSet<String> expandedIds = new HashSet<>();
Set<String> expandedIds = new HashSet<>();

HashSet<String> artifactIds = new HashSet<>();
Set<String> artifactIds = new HashSet<>();
while (!idsToExpand.isEmpty()) {
String depsetId = idsToExpand.remove();
if (expandedIds.contains(depsetId)) {
Expand All @@ -64,9 +64,9 @@ private List<AnalysisProtos.Artifact> expandDepsetToArtifacts(String idToExpand)
expandedIds.add(depsetId);

actionGraph.getDepSetOfFilesList().stream()
.filter((depset) -> depsetId.equals(depset.getId()))
.filter(depset -> depsetId.equals(depset.getId()))
.forEach(
(depset) -> {
depset -> {
idsToExpand.addAll(depset.getTransitiveDepSetIdsList());
artifactIds.addAll(depset.getDirectArtifactIdsList());
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jetbrains.bsp.bazel.server.bsp.resolvers.actiongraph;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.devtools.build.lib.analysis.AnalysisProtosV2;
import java.util.*;
Expand Down Expand Up @@ -71,20 +72,20 @@ private List<AnalysisProtosV2.Action> getActions(String targetLabel) {
private List<AnalysisProtosV2.Artifact> expandDepsetToArtifacts(Integer idToExpand) {
Queue<Integer> idsToExpand = new ArrayDeque<>(Lists.newArrayList(idToExpand));

HashSet<Integer> expandedIds = new HashSet<>();
Set<Integer> expandedIds = new HashSet<>();

HashSet<Integer> artifactIds = new HashSet<>();
Set<Integer> artifactIds = new HashSet<>();
while (!idsToExpand.isEmpty()) {
Integer depsetId = idsToExpand.remove();
if (expandedIds.contains(depsetId)) {
return Collections.emptyList();
continue;
}
expandedIds.add(depsetId);

actionGraph.getDepSetOfFilesList().stream()
.filter((depset) -> depsetId.equals(depset.getId()))
.filter(depset -> depsetId.equals(depset.getId()))
.forEach(
(depset) -> {
depset -> {
idsToExpand.addAll(depset.getTransitiveDepSetIdsList());
artifactIds.addAll(depset.getDirectArtifactIdsList());
});
Expand Down

0 comments on commit ddc8f7c

Please sign in to comment.