Skip to content

Commit

Permalink
Prepare for 2024.1: convert kotlin's Sequence to java's Iterable
Browse files Browse the repository at this point in the history
ExtensionPointImpl is now writen in Kotlin and extends Sequence instead of Iterable
  • Loading branch information
tpasternak committed Jan 19, 2024
1 parent 6bfac3f commit ef2c786
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
import com.google.idea.common.experiments.MockExperimentService;
import com.intellij.openapi.extensions.impl.ExtensionPointImpl;
import java.util.ArrayList;

import kotlin.sequences.Sequence;
import kotlin.sequences.SequencesKt;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -123,7 +126,7 @@ public void testAddJarsForSourceTarget_attchClassJarForKotlinTarget() {
.build();
ArrayList<BlazeJarLibrary> genJars = new ArrayList<>();

for (BlazeJavaSyncAugmenter augmenter : augmenters) {
for (BlazeJavaSyncAugmenter augmenter : toIterable(augmenters)) { // #api233 - in 2024.1 ExtensionPointImpl implements Sequenec instead of Iterable
augmenter.addJarsForSourceTarget(
workspaceLanguageSettings, projectViewSet, target, new ArrayList<>(), genJars);
}
Expand Down Expand Up @@ -166,7 +169,8 @@ public void testAddJarsForSourceTarget_noExtraGenJarListForJavaTarget() {
.build();
ArrayList<BlazeJarLibrary> genJars = new ArrayList<>();

for (BlazeJavaSyncAugmenter augmenter : augmenters) {
for (BlazeJavaSyncAugmenter augmenter : toIterable(augmenters)) { // #api233 - in 2024.1 ExtensionPointImpl implements Sequence instead of Iterable

augmenter.addJarsForSourceTarget(
workspaceLanguageSettings, projectViewSet, target, new ArrayList<>(), genJars);
}
Expand All @@ -184,4 +188,12 @@ private static ArtifactLocation gen(String relativePath) {
private static ArtifactLocation source(String relativePath) {
return ArtifactLocation.builder().setRelativePath(relativePath).setIsSource(true).build();
}

private static <T> Iterable<T> toIterable(Iterable<T> iterable) {
return iterable;
}

private static <T> Iterable<T> toIterable(Sequence<T> sequence) {
return SequencesKt.asIterable(sequence);
}
}

0 comments on commit ef2c786

Please sign in to comment.