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

Autocomplete properties in tween_property #76591

Merged
merged 1 commit into from
Dec 14, 2023
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
58 changes: 58 additions & 0 deletions modules/gdscript/gdscript_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2601,6 +2601,64 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
r_arghint = _make_arguments_hint(info, p_argidx);
}

if (p_argidx == 1 && p_context.node && p_context.node->type == GDScriptParser::Node::CALL && ClassDB::is_parent_class(class_name, SNAME("Tween")) && p_method == SNAME("tween_property")) {
// Get tweened objects properties.
GDScriptParser::ExpressionNode *tweened_object = static_cast<GDScriptParser::CallNode *>(p_context.node)->arguments[0];
StringName native_type = tweened_object->datatype.native_type;
switch (tweened_object->datatype.kind) {
case GDScriptParser::DataType::SCRIPT: {
Ref<Script> script = tweened_object->datatype.script_type;
native_type = script->get_instance_base_type();
int n = 0;
while (script.is_valid()) {
List<PropertyInfo> properties;
script->get_script_property_list(&properties);
for (const PropertyInfo &E : properties) {
if (E.usage & (PROPERTY_USAGE_SUBGROUP | PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY | PROPERTY_USAGE_INTERNAL)) {
continue;
}
ScriptLanguage::CodeCompletionOption option(E.name.quote(quote_style), ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, ScriptLanguage::CodeCompletionLocation::LOCATION_LOCAL + n);
r_result.insert(option.display, option);
}
script = script->get_base_script();
n++;
}
} break;
case GDScriptParser::DataType::CLASS: {
GDScriptParser::ClassNode *clss = tweened_object->datatype.class_type;
native_type = clss->base_type.native_type;
int n = 0;
while (clss) {
for (GDScriptParser::ClassNode::Member member : clss->members) {
if (member.type == GDScriptParser::ClassNode::Member::VARIABLE) {
ScriptLanguage::CodeCompletionOption option(member.get_name().quote(quote_style), ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, ScriptLanguage::CodeCompletionLocation::LOCATION_LOCAL + n);
r_result.insert(option.display, option);
}
}
if (clss->base_type.kind == GDScriptParser::DataType::Kind::CLASS) {
clss = clss->base_type.class_type;
n++;
} else {
native_type = clss->base_type.native_type;
clss = nullptr;
}
}
} break;
default:
break;
}

List<PropertyInfo> properties;
ClassDB::get_property_list(native_type, &properties);
for (const PropertyInfo &E : properties) {
if (E.usage & (PROPERTY_USAGE_SUBGROUP | PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY | PROPERTY_USAGE_INTERNAL)) {
continue;
}
ScriptLanguage::CodeCompletionOption option(E.name.quote(quote_style), ScriptLanguage::CODE_COMPLETION_KIND_MEMBER);
r_result.insert(option.display, option);
}
}

if (p_argidx == 0 && ClassDB::is_parent_class(class_name, SNAME("Node")) && (p_method == SNAME("get_node") || p_method == SNAME("has_node"))) {
// Get autoloads
List<PropertyInfo> props;
Expand Down
Loading