@Test void observerCallback() { Communications communications = mock(Communications.class); LanguageEngineFacade engine = mock(LanguageEngineFacade.class); DataBusBroker broker = mock(DataBusBroker.class); Map<String, List<Diagnostic>> diagnosticsNoErrors = emptyMap(); Map<String, List<Diagnostic>> diagnosticsWithErrors = createDefaultDiagnostics(); AnalysisResult resultNoErrors = AnalysisResult.builder().diagnostics(diagnosticsNoErrors).build(); AnalysisResult resultWithErrors = AnalysisResult.builder().diagnostics(diagnosticsWithErrors).build(); when(engine.analyze(DOCUMENT_URI, TEXT_EXAMPLE, ENABLED)) .thenReturn(resultNoErrors); when(engine.analyze( DOCUMENT_WITH_ERRORS_URI, INCORRECT_TEXT_EXAMPLE, ENABLED)) .thenReturn(resultWithErrors); when(engine.analyze(DOCUMENT_URI, TEXT_EXAMPLE, SKIP)).thenReturn(resultNoErrors); when(engine.analyze(DOCUMENT_WITH_ERRORS_URI, INCORRECT_TEXT_EXAMPLE, SKIP)) .thenReturn(resultWithErrors); MyTextDocumentService service = verifyServiceStart(communications, engine, broker); verifyDidOpen( communications, engine, broker, diagnosticsNoErrors, service, TEXT_EXAMPLE, DOCUMENT_URI); verifyDidOpen( communications, engine, broker, diagnosticsWithErrors, service, INCORRECT_TEXT_EXAMPLE, DOCUMENT_WITH_ERRORS_URI); service.observerCallback(new RunAnalysisEvent()); verifyCallback(communications, engine, diagnosticsNoErrors, TEXT_EXAMPLE, DOCUMENT_URI); verifyCallback( communications, engine, diagnosticsWithErrors, INCORRECT_TEXT_EXAMPLE, DOCUMENT_WITH_ERRORS_URI); }
@Override public void observerCallback(@Nonnull RunAnalysisEvent event) { docs.forEach((key, value) -> analyzeDocumentFirstTime(key, value.getText(), event.verbose)); }
MyTextDocumentService implements TextDocumentService, EventObserver<RunAnalysisEvent> { @Override public void observerCallback(@Nonnull RunAnalysisEvent event) { docs.forEach((key, value) -> analyzeDocumentFirstTime(key, value.getText(), event.verbose)); } }
MyTextDocumentService implements TextDocumentService, EventObserver<RunAnalysisEvent> { @Override public void observerCallback(@Nonnull RunAnalysisEvent event) { docs.forEach((key, value) -> analyzeDocumentFirstTime(key, value.getText(), event.verbose)); } @Inject @Builder  MyTextDocumentService(
      Communications communications,
      LanguageEngineFacade engine,
      Formations formations,
      Completions completions,
      Occurrences occurrences,
      DataBusBroker dataBus,
      CodeActions actions); }
MyTextDocumentService implements TextDocumentService, EventObserver<RunAnalysisEvent> { @Override public void observerCallback(@Nonnull RunAnalysisEvent event) { docs.forEach((key, value) -> analyzeDocumentFirstTime(key, value.getText(), event.verbose)); } @Inject @Builder  MyTextDocumentService(
      Communications communications,
      LanguageEngineFacade engine,
      Formations formations,
      Completions completions,
      Occurrences occurrences,
      DataBusBroker dataBus,
      CodeActions actions); @Override CompletableFuture<Either<List<CompletionItem>, CompletionList>> completion(
      CompletionParams params); @Override CompletableFuture<CompletionItem> resolveCompletionItem(CompletionItem unresolved); @Override CompletableFuture<List<? extends Location>> definition(
      TextDocumentPositionParams position); @Override CompletableFuture<List<? extends Location>> references(ReferenceParams params); @Override CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(
      TextDocumentPositionParams position); @Override CompletableFuture<List<? extends TextEdit>> formatting(DocumentFormattingParams params); @Override CompletableFuture<List<Either<Command, CodeAction>>> codeAction(CodeActionParams params); @Override void didOpen(DidOpenTextDocumentParams params); @Override void didChange(DidChangeTextDocumentParams params); @Override void didClose(DidCloseTextDocumentParams params); @Override void didSave(DidSaveTextDocumentParams params); @Override void observerCallback(@Nonnull RunAnalysisEvent event); @Override CompletableFuture<List<Either<SymbolInformation, DocumentSymbol>>> documentSymbol(DocumentSymbolParams params); }
MyTextDocumentService implements TextDocumentService, EventObserver<RunAnalysisEvent> { @Override public void observerCallback(@Nonnull RunAnalysisEvent event) { docs.forEach((key, value) -> analyzeDocumentFirstTime(key, value.getText(), event.verbose)); } @Inject @Builder  MyTextDocumentService(
      Communications communications,
      LanguageEngineFacade engine,
      Formations formations,
      Completions completions,
      Occurrences occurrences,
      DataBusBroker dataBus,
      CodeActions actions); @Override CompletableFuture<Either<List<CompletionItem>, CompletionList>> completion(
      CompletionParams params); @Override CompletableFuture<CompletionItem> resolveCompletionItem(CompletionItem unresolved); @Override CompletableFuture<List<? extends Location>> definition(
      TextDocumentPositionParams position); @Override CompletableFuture<List<? extends Location>> references(ReferenceParams params); @Override CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(
      TextDocumentPositionParams position); @Override CompletableFuture<List<? extends TextEdit>> formatting(DocumentFormattingParams params); @Override CompletableFuture<List<Either<Command, CodeAction>>> codeAction(CodeActionParams params); @Override void didOpen(DidOpenTextDocumentParams params); @Override void didChange(DidChangeTextDocumentParams params); @Override void didClose(DidCloseTextDocumentParams params); @Override void didSave(DidSaveTextDocumentParams params); @Override void observerCallback(@Nonnull RunAnalysisEvent event); @Override CompletableFuture<List<Either<SymbolInformation, DocumentSymbol>>> documentSymbol(DocumentSymbolParams params);  }