Merge pull request #69298 from Chaosus/gds_fix_lookup

Fix lookup code to pass functions with the same name as built-ins
This commit is contained in:
Rémi Verschelde 2022-11-28 14:48:57 +01:00
commit df4e80e0b8
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 15 additions and 11 deletions

View File

@ -3265,15 +3265,6 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
}
}
// Need special checks for assert and preload as they are technically
// keywords, so are not registered in GDScriptUtilityFunctions.
if (GDScriptUtilityFunctions::function_exists(p_symbol) || "assert" == p_symbol || "preload" == p_symbol) {
r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_METHOD;
r_result.class_name = "@GDScript";
r_result.class_member = p_symbol;
return OK;
}
if ("PI" == p_symbol || "TAU" == p_symbol || "INF" == p_symbol || "NAN" == p_symbol) {
r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT;
r_result.class_name = "@GDScript";
@ -3283,11 +3274,24 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
GDScriptParser parser;
parser.parse(p_code, p_path, true);
GDScriptAnalyzer analyzer(&parser);
analyzer.analyze();
GDScriptParser::CompletionContext context = parser.get_completion_context();
// Allows class functions with the names like built-ins to be handled properly.
if (context.type != GDScriptParser::COMPLETION_ATTRIBUTE) {
// Need special checks for assert and preload as they are technically
// keywords, so are not registered in GDScriptUtilityFunctions.
if (GDScriptUtilityFunctions::function_exists(p_symbol) || "assert" == p_symbol || "preload" == p_symbol) {
r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_METHOD;
r_result.class_name = "@GDScript";
r_result.class_member = p_symbol;
return OK;
}
}
GDScriptAnalyzer analyzer(&parser);
analyzer.analyze();
if (context.current_class && context.current_class->extends.size() > 0) {
bool success = false;
ClassDB::get_integer_constant(context.current_class->extends[0], p_symbol, &success);