Merge pull request #114186 from voylin/language_server_highlight_support

Add highlight support to Language Server for external editors
This commit is contained in:
Thaddeus Crews
2026-01-28 12:26:51 -06:00
4 changed files with 44 additions and 1 deletions
@@ -150,6 +150,25 @@ Array GDScriptTextDocument::documentSymbol(const Dictionary &p_params) {
return arr;
}
Array GDScriptTextDocument::documentHighlight(const Dictionary &p_params) {
Array arr;
LSP::TextDocumentPositionParams params;
params.load(p_params);
const LSP::DocumentSymbol *symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_symbol(params);
if (symbol) {
String path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(params.textDocument.uri);
Vector<LSP::Location> usages = GDScriptLanguageProtocol::get_singleton()->get_workspace()->find_usages_in_file(*symbol, path);
for (const LSP::Location &usage : usages) {
LSP::DocumentHighlight highlight;
highlight.range = usage.range;
arr.push_back(highlight.to_json());
}
}
return arr;
}
Array GDScriptTextDocument::completion(const Dictionary &p_params) {
Array arr;