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

Method parameter with many annotations gets unintuitive indentation

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

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
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
java
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu bằng cách định dạng phần tái hiện Java được hiển thị trong issue và so sánh mức thụt lề thực tế với mức thụt lề mong đợi. Truy vết entry point của formatter chịu trách nhiệm xử lý các tham số phương thức và annotation; được xem là hoàn tất khi tất cả annotation và tham số đều có cùng mức thụt lề, với một regression test bao phủ ví dụ này.

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

Mô tả

The first annotation is indented as expected, but any additional annotations and the method parameter itself get an additional indent. I'd expect all lines to have the same indentation.

To reproduce, format:

import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.RequestParam;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import java.util.Locale;

class Test {

    void foo(@NotNull @Parameter(name = "Indicates the language of the label to search", required = true) @Valid @RequestParam(value = "language", required = true) Locale language) {}
}

Actual (using the native executable built from 61eabd62d6a461c27621ebc77240345e40fb60b4):

import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import java.util.Locale;
import org.springframework.web.bind.annotation.RequestParam;

class Test {

  void foo(
      @NotNull
          @Parameter(name = "Indicates the language of the label to search", required = true)
          @Valid
          @RequestParam(value = "language", required = true)
          Locale language) {}
}

Expected:

import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import java.util.Locale;
import org.springframework.web.bind.annotation.RequestParam;

class Test {

  void foo(
      @NotNull
      @Parameter(name = "Indicates the language of the label to search", required = true)
      @Valid
      @RequestParam(value = "language", required = true)
      Locale language) {}
}
Ngôn ngữ chính
Java
Star
6.2k
Fork
936
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
3

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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 google/google-java-format

Tất cả issue của google/google-java-format

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.