@@ -358,8 +358,17 @@ void cancelDiagnostics(AtomicBoolean cancel) {
358
358
}
359
359
360
360
class LspClient implements LanguageClient {
361
+ private final String uri2CatchDiags ;
361
362
List <MessageParams > loggedMessages = new ArrayList <>();
362
363
364
+ public LspClient () {
365
+ this (null );
366
+ }
367
+
368
+ public LspClient (String uri2CatchDiags ) {
369
+ this .uri2CatchDiags = uri2CatchDiags ;
370
+ }
371
+
363
372
@ Override
364
373
public CompletableFuture <Void > createProgress (WorkDoneProgressCreateParams params ) {
365
374
return CompletableFuture .completedFuture (null );
@@ -378,8 +387,11 @@ public void telemetryEvent(Object arg0) {
378
387
public void publishDiagnostics (PublishDiagnosticsParams params ) {
379
388
synchronized (diags ) {
380
389
diagnosticURIs .add (params .getUri ());
381
- diags .add (params .getDiagnostics ());
382
- diags .notifyAll ();
390
+
391
+ if (uri2CatchDiags == null || uri2CatchDiags .equals (params .getUri ())) {
392
+ diags .add (params .getDiagnostics ());
393
+ diags .notifyAll ();
394
+ }
383
395
}
384
396
}
385
397
@@ -490,7 +502,7 @@ public void testDiagnosticsRemovedForDeletedFile() throws Exception {
490
502
try (Writer w = new FileWriter (src )) {
491
503
w .write (code );
492
504
}
493
- Launcher <LanguageServer > serverLauncher = createClientLauncherWithLogging (new LspClient (), client .getInputStream (), client .getOutputStream ());
505
+ Launcher <LanguageServer > serverLauncher = createClientLauncherWithLogging (new LspClient (src . toURI (). toString () ), client .getInputStream (), client .getOutputStream ());
494
506
serverLauncher .startListening ();
495
507
LanguageServer server = serverLauncher .getRemoteProxy ();
496
508
InitializeResult result = server .initialize (new InitializeParams ()).get ();
0 commit comments