@Test void testAnalysisFinishedNotification() { DataBusBroker broker = mock(DataBusBroker.class); LanguageEngineFacade engine = mock(LanguageEngineFacade.class); Communications communications = mock(Communications.class); Map<String, List<Location>> copybookUsages = new HashMap<>(); Location parentLocation = new Location(DOCUMENT_URI, null); Location nestedLocation = new Location(PARENT_CPY_URI, null); Location nested2Location = new Location(NESTED_CPY_URI, null); copybookUsages.put("PARENT", asList(parentLocation, parentLocation)); copybookUsages.put("NESTED", singletonList(nestedLocation)); copybookUsages.put("NESTED2", singletonList(nested2Location)); when(engine.analyze(DOCUMENT_URI, TEXT_EXAMPLE, CopybookProcessingMode.ENABLED)) .thenReturn(AnalysisResult.empty().toBuilder().copybookUsages(copybookUsages).build()); MyTextDocumentService service = MyTextDocumentService.builder().communications(communications).engine(engine).dataBus(broker).build(); service.didOpen( new DidOpenTextDocumentParams( new TextDocumentItem(DOCUMENT_URI, LANGUAGE, 0, TEXT_EXAMPLE))); verify(broker, timeout(10000)) .postData( AnalysisFinishedEvent.builder() .documentUri(DOCUMENT_URI) .copybookUris(asList(NESTED_CPY_URI, DOCUMENT_URI, PARENT_CPY_URI)) .copybookProcessingMode(ENABLED) .build()); }
@Override public void didOpen(DidOpenTextDocumentParams params) { String uri = params.getTextDocument().getUri(); outlineMap.put(uri, new CompletableFuture<>()); if (uri.startsWith(GIT_FS_URI)) { LOG.warn(String.join(" ", GITFS_URI_NOT_SUPPORTED, uri)); } String text = params.getTextDocument().getText(); String langId = params.getTextDocument().getLanguageId(); registerEngineAndAnalyze(uri, langId, text); }
MyTextDocumentService implements TextDocumentService, EventObserver<RunAnalysisEvent> { @Override public void didOpen(DidOpenTextDocumentParams params) { String uri = params.getTextDocument().getUri(); outlineMap.put(uri, new CompletableFuture<>()); if (uri.startsWith(GIT_FS_URI)) { LOG.warn(String.join(" ", GITFS_URI_NOT_SUPPORTED, uri)); } String text = params.getTextDocument().getText(); String langId = params.getTextDocument().getLanguageId(); registerEngineAndAnalyze(uri, langId, text); } }
MyTextDocumentService implements TextDocumentService, EventObserver<RunAnalysisEvent> { @Override public void didOpen(DidOpenTextDocumentParams params) { String uri = params.getTextDocument().getUri(); outlineMap.put(uri, new CompletableFuture<>()); if (uri.startsWith(GIT_FS_URI)) { LOG.warn(String.join(" ", GITFS_URI_NOT_SUPPORTED, uri)); } String text = params.getTextDocument().getText(); String langId = params.getTextDocument().getLanguageId(); registerEngineAndAnalyze(uri, langId, text); } @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 didOpen(DidOpenTextDocumentParams params) { String uri = params.getTextDocument().getUri(); outlineMap.put(uri, new CompletableFuture<>()); if (uri.startsWith(GIT_FS_URI)) { LOG.warn(String.join(" ", GITFS_URI_NOT_SUPPORTED, uri)); } String text = params.getTextDocument().getText(); String langId = params.getTextDocument().getLanguageId(); registerEngineAndAnalyze(uri, langId, text); } @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 didOpen(DidOpenTextDocumentParams params) { String uri = params.getTextDocument().getUri(); outlineMap.put(uri, new CompletableFuture<>()); if (uri.startsWith(GIT_FS_URI)) { LOG.warn(String.join(" ", GITFS_URI_NOT_SUPPORTED, uri)); } String text = params.getTextDocument().getText(); String langId = params.getTextDocument().getLanguageId(); registerEngineAndAnalyze(uri, langId, text); } @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);  }