Skip to content

When formatting an annotated array type, the space before the annotation gets removed #880

@Bronkoknorb

Description

@Bronkoknorb

Prettier-Java 2.9.1

Input:

import org.jspecify.annotations.Nullable;
 
class Example {
  int @Nullable [] array;
}

Output:

import org.jspecify.annotations.Nullable;

class Example {
  int@Nullable [] array;
}

Expected behavior:

The output is valid Java, but int@Nullable looks like a single token and is hard to read. Would be nice to keep the space:

  int @Nullable [] array;

Note: annotating the array type rather than the element type (i.e. int @Nullable [] vs @Nullable int []) is the style jspecify needs (https://jspecify.dev/docs/user-guide/#type-use-annotation-syntax) for nullable arrays.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions