Skip to content

Commit 504a4d2

Browse files
committed
Add support for ktlint FilenameRule
1 parent 2e61129 commit 504a4d2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/src/main/java/com/diffplug/spotless/kotlin/KtLintStep.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ FormatterFunc createFormat() throws Exception {
154154
/* editorConfigPath, nullable */ String.class,
155155
/* debug */ boolean.class);
156156
Method formatterMethod = ktlintClass.getMethod("format", paramsClass);
157-
formatterFunc = input -> {
157+
FormatterFunc.NeedsFile needsFile = (input, file) -> {
158158
try {
159159
Object params = constructor.newInstance(
160-
/* fileName, nullable */ null,
160+
/* fileName, nullable */ file.getName(),
161161
/* text */ input,
162162
/* ruleSets */ ruleSets,
163163
/* userData */ userData,
@@ -170,6 +170,7 @@ FormatterFunc createFormat() throws Exception {
170170
throw ThrowingEx.unwrapCause(e);
171171
}
172172
};
173+
formatterFunc = FormatterFunc.needsFile(needsFile);
173174
} else {
174175
// and its format method
175176
String formatterMethodName = isScript ? "formatScript" : "format";

0 commit comments

Comments
 (0)