Skip to content

Commit e3843cd

Browse files
committed
StepHarnessBase is now embarked on a methodical journey to make every step support roundtrip serialization.
1 parent eb0df83 commit e3843cd

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

testlib/src/main/java/com/diffplug/spotless/StepHarnessBase.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,23 @@ class StepHarnessBase<T extends StepHarnessBase<?>> implements AutoCloseable {
2626

2727
protected StepHarnessBase(Formatter formatter) {
2828
this.formatter = Objects.requireNonNull(formatter);
29-
}
30-
31-
public T supportsRoundTrip(boolean supportsRoundTrip) {
32-
this.supportsRoundTrip = supportsRoundTrip;
33-
return (T) this;
29+
if (formatter.getSteps().size() == 1) {
30+
// our goal is for everything to be roundtrip serializable
31+
// the steps to get there are
32+
// - make every individual step round-trippable
33+
// - make the other machinery (Formatter, LineEnding, etc) round-trippable
34+
// - done!
35+
//
36+
// Right now, we're still trying to get each and every single step to be round-trippable.
37+
// You can help by add a test below, make sure that the test for that step fails, and then
38+
// make the test pass. `FormatterStepEqualityOnStateSerialization` is a good base class for
39+
// easily converting a step to round-trip serialization while maintaining easy and concise
40+
// equality code.
41+
String onlyStepName = formatter.getSteps().get(0).getName();
42+
if (onlyStepName.startsWith("indentWith")) {
43+
supportsRoundTrip = true;
44+
}
45+
}
3446
}
3547

3648
protected Formatter formatter() {

0 commit comments

Comments
 (0)