mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-12 13:51:10 +01:00
Make Lookup Symbol recognize assert, preload, and yield in the script editor
This commit is contained in:
parent
4bd8abc32b
commit
cdc646fd63
@ -3302,7 +3302,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) {
|
Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) {
|
||||||
//before parsing, try the usual stuff
|
// Before parsing, try the usual stuff.
|
||||||
if (ClassDB::class_exists(p_symbol)) {
|
if (ClassDB::class_exists(p_symbol)) {
|
||||||
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
|
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
|
||||||
r_result.class_name = p_symbol;
|
r_result.class_name = p_symbol;
|
||||||
@ -3536,15 +3536,23 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Must check GDScript functions after parsing to ensure functions like Array.max() are handled correctly.
|
||||||
|
bool function_in_gdscript_functions = false;
|
||||||
for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
|
for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
|
||||||
// this has to get run after parsing because otherwise functions like Array.max() will trigger it
|
|
||||||
if (GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i)) == p_symbol) {
|
if (GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i)) == p_symbol) {
|
||||||
|
function_in_gdscript_functions = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need special checks for assert, preload, and yield as they are technically
|
||||||
|
// keywords, so are not registered in GDScriptFunctions.
|
||||||
|
if (function_in_gdscript_functions || "yield" == p_symbol || "assert" == p_symbol || "preload" == p_symbol) {
|
||||||
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
|
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
|
||||||
r_result.class_name = "@GDScript";
|
r_result.class_name = "@GDScript";
|
||||||
r_result.class_member = p_symbol;
|
r_result.class_member = p_symbol;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ERR_CANT_RESOLVE;
|
return ERR_CANT_RESOLVE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user