16
16
package com .diffplug .spotless ;
17
17
18
18
import java .io .File ;
19
+ import java .util .List ;
19
20
import java .util .Objects ;
20
21
21
22
/**
@@ -32,6 +33,14 @@ default String apply(String unix, File file) throws Exception {
32
33
return apply (unix );
33
34
}
34
35
36
+ /**
37
+ * Calculates a list of lints against the given content.
38
+ * By default, that's just an throwables thrown by the lint.
39
+ */
40
+ default List <Lint > lint (String content , File file ) throws Exception {
41
+ return List .of ();
42
+ }
43
+
35
44
/**
36
45
* {@code Function<String, String>} and {@code BiFunction<String, File, String>} whose implementation
37
46
* requires a resource which should be released when the function is no longer needed.
@@ -74,6 +83,14 @@ public String apply(String unix) throws Exception {
74
83
@ FunctionalInterface
75
84
interface ResourceFunc <T extends AutoCloseable > {
76
85
String apply (T resource , String unix ) throws Exception ;
86
+
87
+ /**
88
+ * Calculates a list of lints against the given content.
89
+ * By default, that's just an throwables thrown by the lint.
90
+ */
91
+ default List <Lint > lint (T resource , String unix ) throws Exception {
92
+ return List .of ();
93
+ }
77
94
}
78
95
79
96
/** Creates a {@link FormatterFunc.Closeable} which uses the given resource to execute the format function. */
@@ -101,6 +118,10 @@ public String apply(String unix) throws Exception {
101
118
@ FunctionalInterface
102
119
interface ResourceFuncNeedsFile <T extends AutoCloseable > {
103
120
String apply (T resource , String unix , File file ) throws Exception ;
121
+
122
+ default List <Lint > lint (T resource , String content , File file ) throws Exception {
123
+ return List .of ();
124
+ }
104
125
}
105
126
106
127
/** Creates a {@link FormatterFunc.Closeable} which uses the given resource to execute the file-dependent format function. */
@@ -123,6 +144,11 @@ public String apply(String unix, File file) throws Exception {
123
144
public String apply (String unix ) throws Exception {
124
145
return apply (unix , Formatter .NO_FILE_SENTINEL );
125
146
}
147
+
148
+ @ Override
149
+ public List <Lint > lint (String content , File file ) throws Exception {
150
+ return function .lint (resource , content , file );
151
+ }
126
152
};
127
153
}
128
154
}
0 commit comments