Kotlin printer: comments inside method bodies are not printed

Đang mở
#181 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, kotlin
Lĩnh vực
compilers

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Java
Star
1
Fork
1
Merge trung bình
1 giờ 13 phút
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CodeLaser/maddi

Tất cả issue của CodeLaser/maddi

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.