@@ -74,7 +74,14 @@ public static DirtyState of(Formatter formatter, File file) throws IOException {
74
74
}
75
75
76
76
public static DirtyState of (Formatter formatter , File file , byte [] rawBytes ) {
77
- String raw = new String (rawBytes , formatter .getEncoding ());
77
+ return of (formatter , file , rawBytes , new String (rawBytes , formatter .getEncoding ()));
78
+ }
79
+
80
+ public static DirtyState of (Formatter formatter , File file , byte [] rawBytes , String raw ) {
81
+ return of (formatter , file , rawBytes , raw , new ValuePerStep <>(formatter ));
82
+ }
83
+
84
+ public static DirtyState of (Formatter formatter , File file , byte [] rawBytes , String raw , ValuePerStep <Throwable > exceptionPerStep ) {
78
85
// check that all characters were encodable
79
86
String encodingError = EncodingErrorMsg .msg (raw , rawBytes , formatter .getEncoding ());
80
87
if (encodingError != null ) {
@@ -84,7 +91,7 @@ public static DirtyState of(Formatter formatter, File file, byte[] rawBytes) {
84
91
String rawUnix = LineEnding .toUnix (raw );
85
92
86
93
// enforce the format
87
- String formattedUnix = formatter .compute (rawUnix , file );
94
+ String formattedUnix = formatter .computeWithLint (rawUnix , file , exceptionPerStep );
88
95
// convert the line endings if necessary
89
96
String formatted = formatter .computeLineEndings (formattedUnix , file );
90
97
@@ -95,13 +102,13 @@ public static DirtyState of(Formatter formatter, File file, byte[] rawBytes) {
95
102
}
96
103
97
104
// F(input) != input, so we'll do a padded check
98
- String doubleFormattedUnix = formatter .compute (formattedUnix , file );
105
+ String doubleFormattedUnix = formatter .computeWithLint (formattedUnix , file , exceptionPerStep );
99
106
if (doubleFormattedUnix .equals (formattedUnix )) {
100
107
// most dirty files are idempotent-dirty, so this is a quick-short circuit for that common case
101
108
return new DirtyState (formattedBytes );
102
109
}
103
110
104
- PaddedCell cell = PaddedCell .check (formatter , file , rawUnix );
111
+ PaddedCell cell = PaddedCell .check (formatter , file , rawUnix , exceptionPerStep );
105
112
if (!cell .isResolvable ()) {
106
113
return didNotConverge ;
107
114
}
0 commit comments