Skip to content

Commit

Permalink
adds immutability to target handling
Browse files Browse the repository at this point in the history
A prior pr #7198 introduced some stream handling. It
was later pointed out that the collection of the
stream should be immutable; this PR will fix that.
  • Loading branch information
andponlin-canva committed Feb 12, 2025
1 parent c7ddb60 commit 360f9b1
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
*/
package com.google.idea.blaze.base.run.testmap;

import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static java.util.function.Predicate.not;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.Futures;
import com.google.idea.blaze.base.dependencies.TargetInfo;
import com.google.idea.blaze.base.ideinfo.TargetIdeInfo;
Expand All @@ -37,6 +35,7 @@
import com.intellij.openapi.project.Project;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -80,7 +79,8 @@ public Future<Collection<TargetInfo>> targetsForSourceFiles(
.map(TargetInfo::fromBuildTarget)
.distinct()
.sorted(new TargetInfoComparator())
.collect(Collectors.toList());
.collect(Collectors.collectingAndThen(
Collectors.toList(), Collections::unmodifiableList));
return Futures.immediateFuture(targets);
}
FilteredTargetMap targetMap =
Expand All @@ -95,7 +95,8 @@ public Future<Collection<TargetInfo>> targetsForSourceFiles(
.filter(target -> !ruleType.isPresent() || target.getRuleType().equals(ruleType.get()))
.distinct()
.sorted(new TargetInfoComparator())
.collect(Collectors.toList());
.collect(Collectors.collectingAndThen(
Collectors.toList(), Collections::unmodifiableList));
return Futures.immediateFuture(targets);
}

Expand Down

0 comments on commit 360f9b1

Please sign in to comment.