Kotlin printer: comments inside method bodies are not printed

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

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, kotlin
Ambito
compilers

Direzione di ricerca

Start in KotlinStatementPrinter, which never reads a statement's comments(), and in KotlinComments, which already turns file, type and member comments into KDoc. Read KotlinApply to see how it refuses to fold commented statements. Done means a comment inside a method body appears in the Kotlin output, with a stated rule for statements that are merged, split or hoisted. Decide those rules with the maintainers before coding.

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

Descrizione

Since d452873f5 the Java→Kotlin printer carries the comments of the file (licence header), types, fields, methods, constructors, enum entries and header properties, with Javadoc turned into KDoc (KotlinComments). Comments inside method bodies are still dropped: KotlinStatementPrinter never reads a statement's comments().

What makes this more than a one-liner: the printer does not map statements one to one. It merges and splits them (T().apply { … }, val copies for smart casts, hoisted locals, init blocks built from a constructor body), so a statement's comment needs a rule for where it goes when its statement is folded into another or disappears. KotlinApply already refuses to fold a statement that carries comments, which is one of these rules; the others need deciding.

Seen in the IDE's Java→Kotlin translation preview.

🤖 Generated with Claude Code

Lingua principale
Java
Stelle
1
Fork
1
Merge medio
1h 44m
PR unite (30g)
6

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.