|
14 | 14 | */
|
15 | 15 | package org.eclipse.lsp.cobol.service;
|
16 | 16 |
|
| 17 | +import com.google.common.annotations.VisibleForTesting; |
| 18 | +import com.google.common.collect.ImmutableMap; |
| 19 | +import com.google.gson.Gson; |
| 20 | +import com.google.gson.JsonObject; |
| 21 | +import com.google.inject.Inject; |
| 22 | +import com.google.inject.Singleton; |
| 23 | +import lombok.Builder; |
| 24 | +import lombok.NonNull; |
| 25 | +import lombok.extern.slf4j.Slf4j; |
17 | 26 | import org.eclipse.lsp.cobol.core.annotation.CheckServerShutdownState;
|
18 | 27 | import org.eclipse.lsp.cobol.core.annotation.DisposableService;
|
19 | 28 | import org.eclipse.lsp.cobol.domain.databus.api.DataBusBroker;
|
20 | 29 | import org.eclipse.lsp.cobol.domain.event.api.EventObserver;
|
21 | 30 | import org.eclipse.lsp.cobol.domain.event.model.AnalysisFinishedEvent;
|
22 |
| -import org.eclipse.lsp.cobol.domain.event.model.DataEventType; |
23 | 31 | import org.eclipse.lsp.cobol.domain.event.model.AnalysisResultEvent;
|
| 32 | +import org.eclipse.lsp.cobol.domain.event.model.DataEventType; |
24 | 33 | import org.eclipse.lsp.cobol.domain.event.model.RunAnalysisEvent;
|
25 | 34 | import org.eclipse.lsp.cobol.service.delegates.actions.CodeActions;
|
26 | 35 | import org.eclipse.lsp.cobol.service.delegates.communications.Communications;
|
|
31 | 40 | import org.eclipse.lsp.cobol.service.delegates.validations.AnalysisResult;
|
32 | 41 | import org.eclipse.lsp.cobol.service.delegates.validations.LanguageEngineFacade;
|
33 | 42 | import org.eclipse.lsp.cobol.service.utils.CustomThreadPoolExecutor;
|
34 |
| -import com.google.common.annotations.VisibleForTesting; |
35 |
| -import com.google.common.collect.ImmutableMap; |
36 |
| -import com.google.gson.Gson; |
37 |
| -import com.google.gson.JsonObject; |
38 |
| -import com.google.inject.Inject; |
39 |
| -import com.google.inject.Singleton; |
40 |
| -import lombok.Builder; |
41 |
| -import lombok.NonNull; |
42 |
| -import lombok.extern.slf4j.Slf4j; |
43 | 43 | import org.eclipse.lsp4j.*;
|
44 | 44 | import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
45 | 45 | import org.eclipse.lsp4j.services.TextDocumentService;
|
|
69 | 69 | @Slf4j
|
70 | 70 | @Singleton
|
71 | 71 | public class CobolTextDocumentService
|
72 |
| - implements TextDocumentService, EventObserver<RunAnalysisEvent>, DisposableService, |
| 72 | + implements TextDocumentService, |
| 73 | + EventObserver<RunAnalysisEvent>, |
| 74 | + DisposableService, |
73 | 75 | ExtendedApiService {
|
74 | 76 | private static final List<String> COBOL_IDS = Arrays.asList("cobol", "cbl", "cob");
|
75 | 77 | private static final String GIT_FS_URI = "gitfs:/";
|
@@ -140,17 +142,6 @@ public CompletableFuture<Either<List<CompletionItem>, CompletionList>> completio
|
140 | 142 | reportExceptionIfThrown(createDescriptiveErrorMessage("completion lookup", uri)));
|
141 | 143 | }
|
142 | 144 |
|
143 |
| - @Override |
144 |
| - @CheckServerShutdownState |
145 |
| - public CompletableFuture<CompletionItem> resolveCompletionItem(CompletionItem unresolved) { |
146 |
| - return supplyAsync( |
147 |
| - () -> completions.resolveDocumentationFor(unresolved), |
148 |
| - executors.getThreadPoolExecutor()) |
149 |
| - .whenComplete( |
150 |
| - reportExceptionIfThrown( |
151 |
| - createDescriptiveErrorMessage("completion resolving", unresolved.getLabel()))); |
152 |
| - } |
153 |
| - |
154 | 145 | @Override
|
155 | 146 | @CheckServerShutdownState
|
156 | 147 | public CompletableFuture<List<? extends Location>> definition(
|
@@ -270,21 +261,24 @@ public CompletableFuture<AnalysisResult> analysis(@NonNull JsonObject json) {
|
270 | 261 | AnalysisResultEvent event = new Gson().fromJson(json.toString(), AnalysisResultEvent.class);
|
271 | 262 | String uri = Optional.ofNullable(event).map(AnalysisResultEvent::getUri).orElse("");
|
272 | 263 | return CompletableFuture.supplyAsync(
|
273 |
| - () -> Optional.ofNullable(docs.get(uri)) |
274 |
| - .map(CobolDocumentModel::getAnalysisResult) |
275 |
| - .orElse(null), |
276 |
| - executors.getThreadPoolExecutor()) |
| 264 | + () -> |
| 265 | + Optional.ofNullable(docs.get(uri)) |
| 266 | + .map(CobolDocumentModel::getAnalysisResult) |
| 267 | + .orElse(null), |
| 268 | + executors.getThreadPoolExecutor()) |
277 | 269 | .whenComplete(
|
278 | 270 | reportExceptionIfThrown(createDescriptiveErrorMessage("analysis retrieving", uri)));
|
279 | 271 | }
|
280 | 272 |
|
281 | 273 | private void registerEngineAndAnalyze(String uri, String text) {
|
282 | 274 | String fileExtension = extractExtension(uri);
|
283 | 275 | if (fileExtension != null && !isCobolFile(fileExtension)) {
|
284 |
| - outlineMap.computeIfPresent(uri, (k, v) -> { |
285 |
| - v.complete(Collections.singletonList(new DocumentSymbol())); |
286 |
| - return v; |
287 |
| - }); |
| 276 | + outlineMap.computeIfPresent( |
| 277 | + uri, |
| 278 | + (k, v) -> { |
| 279 | + v.complete(Collections.singletonList(new DocumentSymbol())); |
| 280 | + return v; |
| 281 | + }); |
288 | 282 | communications.notifyThatExtensionIsUnsupported(fileExtension);
|
289 | 283 | } else {
|
290 | 284 | communications.notifyThatLoadingInProgress(uri);
|
@@ -407,11 +401,9 @@ public CompletableFuture<List<Either<SymbolInformation, DocumentSymbol>>> docume
|
407 | 401 | public CompletableFuture<Hover> hover(TextDocumentPositionParams position) {
|
408 | 402 | String uri = position.getTextDocument().getUri();
|
409 | 403 | return CompletableFuture.<Hover>supplyAsync(
|
410 |
| - () -> hoverProvider.getHover(docs.get(uri), position), |
411 |
| - executors.getThreadPoolExecutor()) |
412 |
| - .whenComplete( |
413 |
| - reportExceptionIfThrown(createDescriptiveErrorMessage("getting hover", uri))); |
414 |
| - |
| 404 | + () -> hoverProvider.getHover(docs.get(uri), position), |
| 405 | + executors.getThreadPoolExecutor()) |
| 406 | + .whenComplete(reportExceptionIfThrown(createDescriptiveErrorMessage("getting hover", uri))); |
415 | 407 | }
|
416 | 408 |
|
417 | 409 | private void registerDocument(String uri, CobolDocumentModel document) {
|
|
0 commit comments