mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
GDScript LSP: Implement signatureHelp
Enable smart resolve default to true as it is required for script symbol lookup
This commit is contained in:
parent
bdcfc6d633
commit
d35c018a7a
8 changed files with 232 additions and 1 deletions
|
@ -522,6 +522,51 @@ const lsp::DocumentSymbol *ExtendGDScriptParser::search_symbol_defined_at_line(i
|
|||
return ret;
|
||||
}
|
||||
|
||||
Error ExtendGDScriptParser::get_left_function_call(const lsp::Position &p_position, lsp::Position &r_func_pos, int &r_arg_index) const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_position.line, lines.size(), ERR_INVALID_PARAMETER);
|
||||
|
||||
int bracket_stack = 0;
|
||||
int index = 0;
|
||||
|
||||
bool found = false;
|
||||
for (int l = p_position.line; l >= 0; --l) {
|
||||
String line = lines[l];
|
||||
int c = line.length() - 1;
|
||||
if (l == p_position.line) {
|
||||
c = MIN(c, p_position.character - 1);
|
||||
}
|
||||
|
||||
while (c >= 0) {
|
||||
const CharType &charactor = line[c];
|
||||
if (charactor == ')') {
|
||||
++bracket_stack;
|
||||
} else if (charactor == '(') {
|
||||
--bracket_stack;
|
||||
if (bracket_stack < 0) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (bracket_stack <= 0 && charactor == ',') {
|
||||
++index;
|
||||
}
|
||||
--c;
|
||||
if (found) {
|
||||
r_func_pos.character = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
r_func_pos.line = l;
|
||||
r_arg_index = index;
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
|
||||
return ERR_METHOD_NOT_FOUND;
|
||||
}
|
||||
|
||||
const lsp::DocumentSymbol *ExtendGDScriptParser::get_symbol_defined_at_line(int p_line) const {
|
||||
if (p_line <= 0) {
|
||||
return &class_symbol;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue