Add highlight support for language server
Update modules/gdscript/language_server/gdscript_text_document.cpp Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
This commit is contained in:
parent
1559ab34c6
commit
055648ea19
4 changed files with 44 additions and 1 deletions
|
|
@ -165,6 +165,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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue