File tree 2 files changed +7
-2
lines changed
lib/src/main/java/com/diffplug/spotless/kotlin
testlib/src/test/java/com/diffplug/spotless/kotlin
2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -101,13 +101,17 @@ FormatterFunc createFormat() throws Exception {
101
101
Class <?> function2Interface = classLoader .loadClass ("kotlin.jvm.functions.Function2" );
102
102
Class <?> lintErrorClass = classLoader .loadClass ("com.github.shyiko.ktlint.core.LintError" );
103
103
Method detailGetter = lintErrorClass .getMethod ("getDetail" );
104
+ Method lineGetter = lintErrorClass .getMethod ("getLine" );
105
+ Method colGetter = lintErrorClass .getMethod ("getCol" );
104
106
Object formatterCallback = Proxy .newProxyInstance (classLoader , new Class []{function2Interface },
105
107
(proxy , method , args ) -> {
106
108
Object lintError = args [0 ]; // com.github.shyiko.ktlint.core.LintError
107
109
boolean corrected = (Boolean ) args [1 ];
108
110
if (!corrected ) {
109
111
String detail = (String ) detailGetter .invoke (lintError );
110
- throw new AssertionError (detail );
112
+ int line = (Integer ) lineGetter .invoke (lintError );
113
+ int col = (Integer ) colGetter .invoke (lintError );
114
+ throw new AssertionError ("Error on line: " + line + ", column: " + col + "\n " + detail );
111
115
}
112
116
return null ;
113
117
});
Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ public void behavior() throws Exception {
33
33
.testResource ("kotlin/ktlint/basic.dirty" , "kotlin/ktlint/basic.clean" )
34
34
.testException ("kotlin/ktlint/unsolvable.dirty" , assertion -> {
35
35
assertion .isInstanceOf (AssertionError .class );
36
- assertion .hasMessage ("Wildcard import" );
36
+ assertion .hasMessage ("Error on line: 1, column: 1\n " +
37
+ "Wildcard import" );
37
38
});
38
39
}
39
40
You can’t perform that action at this time.
0 commit comments