Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Comment before // prettier-ignore on an expression fails with "Comment was not printed"

Đã đóng
#1,115 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 2 ngày

Một pull request liên quan đã được merge.

  • #1109 của @jtkiesel — đã merge

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
tooling

Hướng nghiên cứu

The issue provides two Java inputs that trigger the error, one in an array initializer and one in a conditional expression, but names no source files or tests. Start by locating the comment printing and prettier-ignore handling paths and run the relevant tests with these examples. Done means both comments are retained and the ignored expression stays unchanged without a “Comment was not printed” error.

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

Mô tả

Prettier-Java 2.11.0

Input:

class A {
  Object[] a = {
    // explain
    // prettier-ignore
    foo(1,
        2),
  };
}
class A {
  Object f(boolean c) {
    return c
      ? a()
      : // prettier-ignore
        // explain
        b(1,   2);
  }
}

Output:

[error] A.java: Error: Comment "// explain" was not printed. Please report this error!

(Same error for both inputs.)

Expected behavior: Both comments are kept, and the ignored expression is printed as-is. For the first input:

class A {

  Object[] a = {
    // explain
    // prettier-ignore
    foo(1,
        2),
  };
}

Note: This issue is similar to #1098, but that one is about @formatter:on and @formatter:off comments.

Ngôn ngữ chính
Java
Star
1.2k
Fork
123
Merge trung bình
2 ngày 10 giờ
Pull request đã merge (30 ngày)
35

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 jhipster/prettier-java

Tất cả issue của jhipster/prettier-java

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.