1/** @Services.Lsp.Adapter — asks the installed language server once */2modulePuduLangMcp.Services.Lsp34importPuduLangMcp.Constants.ServerasServer5importPuduLangMcp.Domain.Lsp.ConversationasConversation6importPuduLangMcp.Errors.ToolErrorasToolError7importPuduLangMcp.Services.ToolchainasToolchain89/// The command the language server is started with.10constCOMMAND: Str = "pudu lsp"1112/// The language server's answer to one question, or why there is none.13exportfnask(toolchain: &Toolchain.Toolchain, rootUri: Str, uri: Str, source: Str, directory: Str, question: &Conversation.Question) -> Result[Conversation.Answer, ToolError.ToolFailure] {14if toolchain.compiler == None { returnErr(ToolError.ToolchainMissing) }15let said = Conversation.conversation(rootUri, uri, source, question)16let done = match toolchain.run(["lsp"], said, directory, Server.LSP_TIMEOUT_MS, Server.OUTPUT_CAP_BYTES) {17caseOk(finished) => finished18caseErr(problem) => { returnErr(ToolError.CommandFailed(problem)) }19 }20let answer = Conversation.answerIn(done.output)21if answer.result != None || answer.error != None { returnOk(answer) }22if done.timedOut { Err(ToolError.TimedOut(COMMAND, Server.LSP_TIMEOUT_MS)) } else { Err(ToolError.Unavailable("The language server ended without answering.")) }23}24