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

Number-only array arguments print one element per line

Đang mở
#1,114 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

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

Đá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
56/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java

Hướng nghiên cứu

Start by locating the Java printer logic and tests for array formatting; the issue does not name specific files or test entry points. Reproduce the examples with print width 80, then check how number-only arrays are laid out both as a final argument and when they fit on one line. Done means short arrays stay on one line and longer arrays wrap elements across lines without dropping commas.

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

# Options (if any):
--print-width 80

Input:

class A {
  void f() {
    assertEquals(Bytes.fromInt(0x01020304), new byte[] { 0x01, 0x02, 0x03, 0x04 });
    community = fromExtended(0x02, new byte[] { 0x00, 0x00, 0x00, 0x64, 0x19, 0x00, 0x00, 0x00, 0x00, 0x64, 0x19, 0x00, 0x00, 0x00, 0x00, 0x64 });
  }
}

Output:

class A {

  void f() {
    assertEquals(Bytes.fromInt(0x01020304), new byte[] {
      0x01,
      0x02,
      0x03,
      0x04,
    });
    community = fromExtended(0x02, new byte[] {
      0x00,
      0x00,
      0x00,
      0x64,
      0x19,
      0x00,
      0x00,
      0x00,
      0x00,
      0x64,
      0x19,
      0x00,
      0x00,
      0x00,
      0x00
      0x64,
    });
  }
}

Expected behavior:

class A {

  void f() {
    assertEquals(
      Bytes.fromInt(0x01020304),
      new byte[] { 0x01, 0x02, 0x03, 0x04 }
    );
    community = fromExtended(
      0x02,
      new byte[] {
        0x00, 0x00, 0x00, 0x64, 0x19, 0x00, 0x00, 0x00, 0x00, 0x64, 0x19, 0x00,
        0x00, 0x00, 0x00, 0x64,
      }
    );
  }
}

This matches Prettier JS, which doesn't hug a number-only array as the last argument and fills its elements across lines:

community = fromExtended(
  0x02,
  [
    0x00, 0x00, 0x00, 0x64, 0x19, 0x00, 0x00, 0x00, 0x00, 0x64, 0x19, 0x00,
    0x00, 0x00, 0x00, 0x64,
  ],
);

2.8.1 also kept short arrays like the first one on a single line:

assertEquals(Bytes.fromInt(0x01020304), new byte[] { 0x01, 0x02, 0x03, 0x04 });
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.