Skip to content

Commit 931e106

Browse files
committed
Make FormatAnnotationsStep round-trippable
1 parent 0b66cca commit 931e106

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/src/main/java/com/diffplug/spotless/java/FormatAnnotationsStep.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2023 DiffPlug
2+
* Copyright 2022-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626

2727
import com.diffplug.spotless.FormatterFunc;
2828
import com.diffplug.spotless.FormatterStep;
29+
import com.diffplug.spotless.RoundedStep;
2930

3031
/**
3132
* Some formatters put every annotation on its own line
@@ -36,7 +37,8 @@
3637
* <p>
3738
* Note: A type annotation is an annotation that is meta-annotated with {@code @Target({ElementType.TYPE_USE})}.
3839
*/
39-
public final class FormatAnnotationsStep {
40+
public final class FormatAnnotationsStep implements RoundedStep {
41+
private static final long serialVersionUID = 1L;
4042

4143
/**
4244
* Simple names of type annotations.
@@ -389,7 +391,7 @@ public final class FormatAnnotationsStep {
389391

390392
);
391393

392-
static final String NAME = "No line break between type annotation and type";
394+
private static final String NAME = "No line break between type annotation and type";
393395

394396
public static FormatterStep create() {
395397
return create(Collections.emptyList(), Collections.emptyList());
@@ -432,13 +434,13 @@ private static final class State implements Serializable {
432434
}
433435

434436
FormatterFunc toFormatter() {
435-
return unixStr -> fixupTypeAnnotations(unixStr);
437+
return this::fixupTypeAnnotations;
436438
}
437439

438440
/**
439441
* Removes line break between type annotations and the following type.
440442
*
441-
* @param the text of a Java file
443+
* @param unixStr the text of a Java file
442444
* @return corrected text of the Java file
443445
*/
444446
String fixupTypeAnnotations(String unixStr) {

0 commit comments

Comments
 (0)