Skip to content

Commit adb6ec7

Browse files
committed
Make RemoveSemicolonsStep round-trippable
1 parent f5e3dd3 commit adb6ec7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/src/main/java/com/diffplug/spotless/groovy/RemoveSemicolonsStep.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 DiffPlug
2+
* Copyright 2023-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.
@@ -21,23 +21,25 @@
2121

2222
import com.diffplug.spotless.FormatterFunc;
2323
import com.diffplug.spotless.FormatterStep;
24+
import com.diffplug.spotless.RoundedStep;
2425

2526
/**
2627
* Removes all semicolons from the end of lines.
2728
*
2829
* @author Jose Luis Badano
2930
*/
30-
public final class RemoveSemicolonsStep {
31+
public final class RemoveSemicolonsStep implements RoundedStep {
32+
private static final long serialVersionUID = 1L;
3133
private static final String NAME = "Remove unnecessary semicolons";
3234

3335
private RemoveSemicolonsStep() {
3436
// do not instantiate
3537
}
3638

3739
public static FormatterStep create() {
38-
return FormatterStep.createLazy(NAME,
39-
State::new,
40-
RemoveSemicolonsStep.State::toFormatter);
40+
return FormatterStep.create(NAME,
41+
new State(),
42+
State::toFormatter);
4143
}
4244

4345
private static final class State implements Serializable {
@@ -64,7 +66,7 @@ FormatterFunc toFormatter() {
6466
* @return the line without the last semicolon
6567
*/
6668
private String removeSemicolon(String line) {
67-
// find last semicolon in a string a remove it
69+
// Find the last semicolon in a string and remove it.
6870
int lastSemicolon = line.lastIndexOf(";");
6971
if (lastSemicolon != -1 && lastSemicolon == line.length() - 1) {
7072
return line.substring(0, lastSemicolon);

0 commit comments

Comments
 (0)