Skip to content

Commit

Permalink
fix some requests when client doesn't send language IDs
Browse files Browse the repository at this point in the history
fixes calltips, code lens, goto definition, hover, formatting and document outline
  • Loading branch information
WebFreak001 committed Apr 15, 2024
1 parent 932f3e9 commit f4ab37f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions source/served/commands/calltips.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/served/commands/code_lens.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions source/served/commands/definition.d
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions source/served/commands/format.d
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand All @@ -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 [];
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion source/served/commands/symbol_search.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f4ab37f

Please sign in to comment.