From 04d329102b43b6c779a5e7f39ebf00570abc515a Mon Sep 17 00:00:00 2001 From: Sophio Japharidze Date: Tue, 26 Nov 2024 14:23:59 +0100 Subject: [PATCH] SLVSCODE-877 do not analyze files not open in editor --- scripts/dependencies.json | 2 +- src/extension.ts | 5 ++++- src/lsp/protocol.ts | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/dependencies.json b/scripts/dependencies.json index cc2c3dfc8..c75ab9534 100644 --- a/scripts/dependencies.json +++ b/scripts/dependencies.json @@ -2,7 +2,7 @@ { "groupId": "org.sonarsource.sonarlint.ls", "artifactId": "sonarlint-language-server", - "version": "3.13.0.75685", + "version": "3.13.0.75690", "output": "server/sonarlint-ls.jar" }, { diff --git a/src/extension.ts b/src/extension.ts index 832ae8630..6dc1c4fce 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -634,7 +634,10 @@ function installCustomRequestHandlers(context: VSCode.ExtensionContext) { languageClient.onNotification(protocol.SubmitNewCodeDefinition.type, newCodeDefinitionForFolderUri => { NewCodeDefinitionService.instance.updateNewCodeDefinitionForFolderUri(newCodeDefinitionForFolderUri); }); - languageClient.onNotification(protocol.SuggestConnection.type, (params) => SharedConnectedModeSettingsService.instance.handleSuggestConnectionNotification(params.suggestionsByConfigScopeId)) + languageClient.onNotification(protocol.SuggestConnection.type, (params) => SharedConnectedModeSettingsService.instance.handleSuggestConnectionNotification(params.suggestionsByConfigScopeId)); + languageClient.onRequest(protocol.IsOpenInEditor.type, async (fileUri) => { + return VSCode.window.visibleTextEditors.some(editor => editor.document.uri.toString(true) === fileUri); + }); } function updateSonarLintViewContainerBadge() { diff --git a/src/lsp/protocol.ts b/src/lsp/protocol.ts index bc996aaef..e7f7232f6 100644 --- a/src/lsp/protocol.ts +++ b/src/lsp/protocol.ts @@ -753,8 +753,13 @@ export interface ShowFixSuggestionParams { textEdits: Change[]; fileUri: string; } + export namespace ShowFixSuggestion { export const type = new lsp.NotificationType('sonarlint/showFixSuggestion'); } +export namespace IsOpenInEditor { + export const type = new lsp.RequestType('sonarlint/isOpenInEditor'); +} + //#endregion