Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix enum value lookup jump #102401

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions modules/gdscript/gdscript_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3956,10 +3956,14 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
} else {
const int dot_pos = doc_enum_name.rfind_char('.');
if (dot_pos >= 0) {
Error err = OK;
r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT;
r_result.class_name = doc_enum_name.left(dot_pos);
r_result.class_member = p_symbol;
if (base_type.class_type != nullptr) {
// For script enums the value isn't accessible as class constant so we need the full enum name.
r_result.class_name = doc_enum_name;
r_result.class_member = p_symbol;
r_result.script = GDScriptCache::get_shallow_script(base_type.script_path, err);
r_result.script_path = base_type.script_path;
const String enum_name = doc_enum_name.substr(dot_pos + 1);
if (base_type.class_type->has_member(enum_name)) {
const GDScriptParser::ClassNode::Member member = base_type.class_type->get_member(enum_name);
Expand All @@ -3972,8 +3976,19 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
}
}
}
} else if (base_type.script_type.is_valid()) {
// For script enums the value isn't accessible as class constant so we need the full enum name.
r_result.class_name = doc_enum_name;
r_result.class_member = p_symbol;
r_result.script = base_type.script_type;
r_result.script_path = base_type.script_path;
// TODO: Find a way to obtain enum value location for a script
r_result.location = base_type.script_type->get_member_line(doc_enum_name.substr(dot_pos + 1));
} else {
r_result.class_name = doc_enum_name.left(dot_pos);
r_result.class_member = p_symbol;
}
return OK;
return err;
}
}
} else if (Variant::has_builtin_method(Variant::DICTIONARY, p_symbol)) {
Expand Down