File tree Expand file tree Collapse file tree 4 files changed +40
-0
lines changed
spring-javaformat-formatter-tests/src/test/resources
spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter Expand file tree Collapse file tree 4 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 11package example;
22
3+ import org.jspecify.annotations.NonNull;
34import org.jspecify.annotations.Nullable;
45import org.jspecify.annotations.NullMarked;
56import org.jspecify.annotations.NullUnmarked;
@@ -34,4 +35,16 @@ public interface ExampleNullables {
3435 @NullUnmarked
3536 void withNullUnmarked(String str);
3637
38+ static class Fields {
39+
40+ @Nullable Object one;
41+
42+ @NonNull Object two;
43+
44+ private @Nullable Object three;
45+
46+ private @NonNull Object four;
47+
48+ }
49+
3750}
Original file line number Diff line number Diff line change 11package example;
22
3+ import org.jspecify.annotations.NonNull;
34import org.jspecify.annotations.Nullable;
45import org.jspecify.annotations.NullMarked;
56import org.jspecify.annotations.NullUnmarked;
@@ -32,4 +33,16 @@ public interface ExampleNullables {
3233 @NullUnmarked
3334 void withNullUnmarked(String str);
3435
36+ static class Fields {
37+
38+ @Nullable Object one;
39+
40+ @NonNull Object two;
41+
42+ private @Nullable Object three;
43+
44+ private @NonNull Object four;
45+
46+ }
47+
3548}
Original file line number Diff line number Diff line change 2929import io .spring .javaformat .eclipse .jdt .jdk17 .core .dom .ASTVisitor ;
3030import io .spring .javaformat .eclipse .jdt .jdk17 .core .dom .Annotation ;
3131import io .spring .javaformat .eclipse .jdt .jdk17 .core .dom .CompilationUnit ;
32+ import io .spring .javaformat .eclipse .jdt .jdk17 .core .dom .FieldDeclaration ;
3233import io .spring .javaformat .eclipse .jdt .jdk17 .core .dom .IExtendedModifier ;
3334import io .spring .javaformat .eclipse .jdt .jdk17 .core .dom .ImportDeclaration ;
3435import io .spring .javaformat .eclipse .jdt .jdk17 .core .dom .MethodDeclaration ;
@@ -85,6 +86,12 @@ public boolean visit(ImportDeclaration node) {
8586 return super .visit (node );
8687 }
8788
89+ @ Override
90+ public boolean visit (FieldDeclaration node ) {
91+ clearLineBreaksIfHasJSpecifyAnnotation (node .modifiers ());
92+ return super .visit (node );
93+ }
94+
8895 @ Override
8996 public boolean visit (MethodDeclaration node ) {
9097 clearLineBreaksIfHasJSpecifyAnnotation (node .modifiers ());
Original file line number Diff line number Diff line change 2929import io .spring .javaformat .eclipse .jdt .jdk8 .core .dom .ASTVisitor ;
3030import io .spring .javaformat .eclipse .jdt .jdk8 .core .dom .Annotation ;
3131import io .spring .javaformat .eclipse .jdt .jdk8 .core .dom .CompilationUnit ;
32+ import io .spring .javaformat .eclipse .jdt .jdk8 .core .dom .FieldDeclaration ;
3233import io .spring .javaformat .eclipse .jdt .jdk8 .core .dom .IExtendedModifier ;
3334import io .spring .javaformat .eclipse .jdt .jdk8 .core .dom .ImportDeclaration ;
3435import io .spring .javaformat .eclipse .jdt .jdk8 .core .dom .MethodDeclaration ;
@@ -85,6 +86,12 @@ public boolean visit(ImportDeclaration node) {
8586 return super .visit (node );
8687 }
8788
89+ @ Override
90+ public boolean visit (FieldDeclaration node ) {
91+ clearLineBreaksIfHasJSpecifyAnnotation (node .modifiers ());
92+ return super .visit (node );
93+ }
94+
8895 @ Override
8996 public boolean visit (MethodDeclaration node ) {
9097 clearLineBreaksIfHasJSpecifyAnnotation (node .modifiers ());
You can’t perform that action at this time.
0 commit comments