Skip to content

Commit f508796

Browse files
committed
This sets our language server up to handle the codeLens requests coming from the language client. This just ensures that the server tells the client that sending codeLens requests is fine. Next we'll implement the actual functionality that resolves the code leneses.
1 parent 35ac5f2 commit f508796

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

server/src/server.ts

+22
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
DidChangeConfigurationNotification,
1414
InitializeParams,
1515
InlayHintParams,
16+
CodeLensParams,
1617
} from "vscode-languageserver-protocol";
1718
import * as utils from "./utils";
1819
import * as codeActions from "./codeActions";
@@ -411,6 +412,18 @@ function sendInlayHintsRefresh() {
411412
send(request);
412413
}
413414

415+
function codeLens(msg: p.RequestMessage) {
416+
const params = msg.params as p.CodeLensParams;
417+
const filePath = fileURLToPath(params.textDocument.uri);
418+
419+
const response = utils.runAnalysisCommand(
420+
filePath,
421+
["codeLens", filePath],
422+
msg
423+
);
424+
return response;
425+
}
426+
414427
function definition(msg: p.RequestMessage) {
415428
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition
416429
let params = msg.params as p.DefinitionParams;
@@ -1001,6 +1014,9 @@ function onMessage(msg: p.Message) {
10011014
full: true,
10021015
},
10031016
inlayHintProvider: extensionConfiguration.inlayHints.enable,
1017+
codeLensProvider: {
1018+
workDoneProgress: false
1019+
},
10041020
},
10051021
};
10061022
let response: p.ResponseMessage = {
@@ -1086,6 +1102,12 @@ function onMessage(msg: p.Message) {
10861102
if (extName === c.resExt) {
10871103
send(inlayHint(msg));
10881104
}
1105+
} else if (msg.method === p.CodeLensRequest.method) {
1106+
let params = msg.params as CodeLensParams;
1107+
let extName = path.extname(params.textDocument.uri);
1108+
if (extName === c.resExt) {
1109+
send(codeLens(msg));
1110+
}
10891111
} else {
10901112
let response: p.ResponseMessage = {
10911113
jsonrpc: c.jsonrpcVersion,

0 commit comments

Comments
 (0)