diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/HighlightsCodeLensProvider.java b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/HighlightsCodeLensProvider.java index be6ba9088..2d84b9dbe 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/HighlightsCodeLensProvider.java +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/HighlightsCodeLensProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Pivotal, Inc. + * Copyright (c) 2018, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -72,22 +72,29 @@ public class HighlightsCodeLensProvider extends AbstractCodeMiningProvider { IPreferenceStore store = LanguageServerCommonsActivator.getInstance().getPreferenceStore(); if (store.getBoolean(PreferenceConstants.HIGHLIGHT_CODELENS_PREFS)) { IDocument document = viewer.getDocument(); - List docInfos = LanguageServiceAccessor.getLSPDocumentInfosFor(document, (x) -> true); - if (!docInfos.isEmpty()) { - LSPDocumentInfo info = docInfos.get(0); - HighlightParams highlights = STS4LanguageClientImpl.currentHighlights.get(info.getFileUri().toString()); - if (highlights != null) { - return CompletableFuture.completedFuture(highlights.getCodeLenses().stream() - .filter(codeLens -> codeLens.getCommand() != null).map(codeLens -> { - try { - return new HighlightCodeMining(codeLens, document, this, action(codeLens.getCommand())); - } catch (BadLocationException e) { - LanguageServerCommonsActivator.logError(e, "Failed to create Eclipse client CodeLens"); - return null; - } - }).filter(Objects::nonNull).collect(Collectors.toList())); + + return CompletableFuture.supplyAsync(() -> { + List docInfos = LanguageServiceAccessor.getLSPDocumentInfosFor(document, null); + if (!docInfos.isEmpty()) { + LSPDocumentInfo info = docInfos.get(0); + HighlightParams highlights = STS4LanguageClientImpl.currentHighlights.get(info.getFileUri().toString()); + if (highlights != null) { + return highlights.getCodeLenses().stream() + .filter(codeLens -> codeLens.getCommand() != null) + .map(codeLens -> { + try { + return new HighlightCodeMining(codeLens, document, this, action(codeLens.getCommand())); + } catch (BadLocationException e) { + LanguageServerCommonsActivator.logError(e, "Failed to create Eclipse client CodeLens"); + return null; + } + }) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + } } - } + return null; + }); } return null; }