From ebfc308d2561c314fbd121506705ea3c8a892b27 Mon Sep 17 00:00:00 2001 From: Dirk Baeumer Date: Tue, 22 Aug 2023 12:00:20 +0200 Subject: [PATCH] Testbed for 181166 --- lsp-sample/.vscode/launch.json | 3 ++- lsp-sample/server/src/server.ts | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lsp-sample/.vscode/launch.json b/lsp-sample/.vscode/launch.json index 7d4032fe..3d8697d2 100644 --- a/lsp-sample/.vscode/launch.json +++ b/lsp-sample/.vscode/launch.json @@ -9,10 +9,11 @@ "runtimeExecutable": "${execPath}", "args": ["--extensionDevelopmentPath=${workspaceRoot}"], "outFiles": ["${workspaceRoot}/client/out/**/*.js"], + "autoAttachChildProcesses": true, "preLaunchTask": { "type": "npm", "script": "watch" - } + }, }, { "name": "Language Server E2E Test", diff --git a/lsp-sample/server/src/server.ts b/lsp-sample/server/src/server.ts index afd81c39..0c3be280 100644 --- a/lsp-sample/server/src/server.ts +++ b/lsp-sample/server/src/server.ts @@ -5,6 +5,7 @@ import { createConnection, TextDocuments, + Range, Diagnostic, DiagnosticSeverity, ProposedFeatures, @@ -55,7 +56,8 @@ connection.onInitialize((params: InitializeParams) => { // Tell the client that this server supports code completion. completionProvider: { resolveProvider: true - } + }, + codeActionProvider: true, } }; if (hasWorkspaceFolderCapability) { @@ -147,14 +149,16 @@ async function validateTextDocument(textDocument: TextDocument): Promise { const diagnostics: Diagnostic[] = []; while ((m = pattern.exec(text)) && problems < settings.maxNumberOfProblems) { problems++; + const range: Range = { + start: textDocument.positionAt(m.index), + end: textDocument.positionAt(m.index + m[0].length) + }; const diagnostic: Diagnostic = { severity: DiagnosticSeverity.Warning, - range: { - start: textDocument.positionAt(m.index), - end: textDocument.positionAt(m.index + m[0].length) - }, + range: range, message: `${m[0]} is all uppercase.`, - source: 'ex' + source: 'ex', + data: JSON.stringify(range, undefined, 0) }; if (hasDiagnosticRelatedInformationCapability) { diagnostic.relatedInformation = [ @@ -221,6 +225,9 @@ connection.onCompletionResolve( return item; } ); +connection.onCodeAction((params) => { + return []; +}); // Make the text document manager listen on the connection // for open, change and close text document events