@@ -164,7 +164,8 @@ public LineClause in(final JavaFileObject file) {
164
164
diagnosticsWithMessage .filter (new Predicate <Diagnostic <? extends FileObject >>() {
165
165
@ Override
166
166
public boolean apply (Diagnostic <? extends FileObject > input ) {
167
- return file .toUri ().getPath ().equals (input .getSource ().toUri ().getPath ());
167
+ return ((input .getSource () != null )
168
+ && file .toUri ().getPath ().equals (input .getSource ().toUri ().getPath ()));
168
169
}
169
170
});
170
171
if (diagnosticsInFile .isEmpty ()) {
@@ -173,9 +174,11 @@ public boolean apply(Diagnostic<? extends FileObject> input) {
173
174
diagnosticsWithMessage .transform (
174
175
new Function <Diagnostic <? extends FileObject >, String >() {
175
176
@ Override public String apply (Diagnostic <? extends FileObject > input ) {
176
- return input .getSource ().getName ();
177
+ return (input .getSource () != null ) ? input .getSource ().getName ()
178
+ : "(no associated file)" ;
177
179
}
178
- })));
180
+ })
181
+ .toSet ()));
179
182
}
180
183
return new LineClause () {
181
184
@ Override public UnsuccessfulCompilationClause and () {
@@ -194,11 +197,14 @@ public boolean apply(Diagnostic<?> input) {
194
197
failureStrategy .fail (String .format (
195
198
"Expected an error on line %d of %s, but only found errors on line(s) %s" ,
196
199
lineNumber , file .getName (), diagnosticsInFile .transform (
197
- new Function <Diagnostic <?>, Long >() {
198
- @ Override public Long apply (Diagnostic <?> input ) {
199
- return input .getLineNumber ();
200
+ new Function <Diagnostic <?>, String >() {
201
+ @ Override public String apply (Diagnostic <?> input ) {
202
+ long errLine = input .getLineNumber ();
203
+ return (errLine != Diagnostic .NOPOS ) ? errLine + ""
204
+ : "(no associated position)" ;
200
205
}
201
- })));
206
+ })
207
+ .toSet ()));
202
208
}
203
209
return new ColumnClause () {
204
210
@ Override
@@ -220,11 +226,14 @@ public boolean apply(Diagnostic<?> input) {
220
226
failureStrategy .fail (String .format (
221
227
"Expected an error at %d:%d of %s, but only found errors at column(s) %s" ,
222
228
lineNumber , columnNumber , file .getName (), diagnosticsOnLine .transform (
223
- new Function <Diagnostic <?>, Long >() {
224
- @ Override public Long apply (Diagnostic <?> input ) {
225
- return input .getColumnNumber ();
229
+ new Function <Diagnostic <?>, String >() {
230
+ @ Override public String apply (Diagnostic <?> input ) {
231
+ long errCol = input .getColumnNumber ();
232
+ return (errCol != Diagnostic .NOPOS ) ? errCol + ""
233
+ : "(no associated position)" ;
226
234
}
227
- })));
235
+ })
236
+ .toSet ()));
228
237
}
229
238
return new ChainingClause <UnsuccessfulCompilationClause >() {
230
239
@ Override public UnsuccessfulCompilationClause and () {
0 commit comments