From f4ab37f488c88762a1215ac434702e4ae92c97aa Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Tue, 16 Apr 2024 01:46:29 +0200 Subject: [PATCH] fix some requests when client doesn't send language IDs fixes calltips, code lens, goto definition, hover, formatting and document outline --- source/served/commands/calltips.d | 4 ++-- source/served/commands/code_lens.d | 2 +- source/served/commands/definition.d | 4 ++-- source/served/commands/format.d | 6 +++--- source/served/commands/symbol_search.d | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/served/commands/calltips.d b/source/served/commands/calltips.d index d55eef28..2894023f 100644 --- a/source/served/commands/calltips.d +++ b/source/served/commands/calltips.d @@ -123,9 +123,9 @@ SignatureHelp provideSignatureHelp(TextDocumentPositionParams params) { auto document = documents[params.textDocument.uri]; string file = document.uri.uriToFile; - if (document.languageId == "d") + if (document.getLanguageId == "d") return provideDSignatureHelp(params, file, document); - else if (document.languageId == "diet") + else if (document.getLanguageId == "diet") return provideDietSignatureHelp(params, file, document); else return SignatureHelp.init; diff --git a/source/served/commands/code_lens.d b/source/served/commands/code_lens.d index b2a72ce8..605486c6 100644 --- a/source/served/commands/code_lens.d +++ b/source/served/commands/code_lens.d @@ -22,7 +22,7 @@ CodeLens[] provideCodeLens(CodeLensParams params) { auto document = documents[params.textDocument.uri]; string file = document.uri.uriToFile; - if (document.languageId != "d") + if (document.getLanguageId != "d") return []; CodeLens[] ret; if (workspace(params.textDocument.uri).config.d.enableDMDImportTiming) diff --git a/source/served/commands/definition.d b/source/served/commands/definition.d index 4dc57de6..34ea98c8 100644 --- a/source/served/commands/definition.d +++ b/source/served/commands/definition.d @@ -105,7 +105,7 @@ ArrayOrSingle!Location provideDefinition(TextDocumentPositionParams params) return ArrayOrSingle!Location.init; auto document = documents[params.textDocument.uri]; - if (document.languageId != "d") + if (document.getLanguageId != "d") return ArrayOrSingle!Location.init; auto result = findDeclarationImpl(instance, document, @@ -125,7 +125,7 @@ Hover provideHover(TextDocumentPositionParams params) return Hover.init; auto document = documents[params.textDocument.uri]; - if (document.languageId != "d") + if (document.getLanguageId != "d") return Hover.init; DCDComponent dcd = instance.get!DCDComponent(); diff --git a/source/served/commands/format.d b/source/served/commands/format.d index 74a18189..8802bdaa 100644 --- a/source/served/commands/format.d +++ b/source/served/commands/format.d @@ -132,7 +132,7 @@ TextEdit[] provideFormatting(DocumentFormattingParams params) auto config = workspace(params.textDocument.uri).config; auto document = documents[params.textDocument.uri]; string result; - if (document.languageId == "d") + if (document.getLanguageId == "d") { if (!config.d.enableFormatting) return []; @@ -141,7 +141,7 @@ TextEdit[] provideFormatting(DocumentFormattingParams params) result = backend.get!DfmtComponent.format(document.rawText, generateDfmtArgs(config, document.eolAt(0))).getYield; } - else if (document.languageId == "sdl") + else if (document.getLanguageId == "sdl") { if (!config.sdl.enableFormatting) return []; @@ -163,7 +163,7 @@ TextEdit[] provideFormatting(DocumentFormattingParams params) } else { - trace("attemted to format code that has unsupported language: '", document.languageId, "'"); + trace("attemted to format code that has unsupported language: '", document.getLanguageId, "'"); return []; } return diff(document, result); diff --git a/source/served/commands/symbol_search.d b/source/served/commands/symbol_search.d index cb60b0cc..50231fac 100644 --- a/source/served/commands/symbol_search.d +++ b/source/served/commands/symbol_search.d @@ -76,7 +76,7 @@ SymbolInformationEx[] provideDocumentSymbolsOld(DocumentSymbolParamsEx params) if (cached.symbolsVerbose.length) return params.verbose ? cached.symbolsVerbose : cached.symbols; auto document = documents.tryGet(params.textDocument.uri); - if (document.languageId != "d") + if (document.getLanguageId != "d") return null; auto result = backend.best!DscannerComponent(params.textDocument.uri.uriToFile)