Kotlin printer: streams as collection operations

Aperta
#233 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java, kotlin
Ambito
tooling

Direzione di ricerca

Start in the Kotlin printer code that translates Java stream expression chains, and run the existing printer tests to observe the current output. Implement the stage, terminal, laziness, and unsupported-operation mappings listed in the issue. Done means supported Collection.stream() chains become Kotlin collection operations, while unsupported cases such as findFirst, count, limit, and flatMap remain streams.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Split off from #231. Java translated to Kotlin keeps its streams: names.stream().filter(…).map(…).collect(Collectors.toList()) (.stream() 40 / 77 / 30 times in the langchain4j / fernflower / guava output). Kotlin's collections have these operations themselves.

First pass, a chain from Collection.stream():

  • stages filter, map, distinct, sorted() (Comparable elements), sorted(c) → sortedWith(c); filter(Objects::nonNull) → filterNotNull()
  • terminals collect(toList()) / toList() → nothing, toList() or toMutableList() as the position takes it; collect(toSet()) → toSet() / toMutableSet(); collect(joining(…)) → joinToString(…); anyMatch / allMatch / noneMatch → any / all / none; forEach
  • where Java's laziness can show (a short-circuiting terminal or forEach after a stage): asSequence()

Anything else stays a stream: findFirst (that is the Optional item of #231), count, mapToInt, limit, flatMap, custom collectors, Arrays.stream, Stream.of.

🤖 Generated with Claude Code

Lingua principale
Java
Stelle
1
Fork
1
Merge medio
48m
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CodeLaser/maddi

Tutte le issue di CodeLaser/maddi

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.