mirror of
https://github.com/godotengine/godot.git
synced 2024-12-15 10:12:40 +08:00
Merge pull request #59594 from dmaz/add-completion-opt-built-in-types
This commit is contained in:
commit
5a912b0444
@ -777,7 +777,22 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
|
||||
}
|
||||
}
|
||||
|
||||
static void _find_built_in_variants(Map<String, ScriptLanguage::CodeCompletionOption> &r_result, bool exclude_nil = false) {
|
||||
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
|
||||
if (!exclude_nil && Variant::Type(i) == Variant::Type::NIL) {
|
||||
ScriptLanguage::CodeCompletionOption option("null", ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
|
||||
r_result.insert(option.display, option);
|
||||
} else {
|
||||
ScriptLanguage::CodeCompletionOption option(Variant::get_type_name(Variant::Type(i)), ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void _list_available_types(bool p_inherit_only, GDScriptParser::CompletionContext &p_context, Map<String, ScriptLanguage::CodeCompletionOption> &r_result) {
|
||||
// Built-in Variant Types
|
||||
_find_built_in_variants(r_result, true);
|
||||
|
||||
List<StringName> native_types;
|
||||
ClassDB::get_class_list(&native_types);
|
||||
for (const StringName &E : native_types) {
|
||||
@ -1153,17 +1168,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool
|
||||
return;
|
||||
}
|
||||
|
||||
static const char *_type_names[Variant::VARIANT_MAX] = {
|
||||
"null", "bool", "int", "float", "String", "StringName", "Vector2", "Vector2i", "Rect2", "Rect2i", "Vector3", "Vector3i", "Transform2D", "Plane", "Quaternion", "AABB", "Basis", "Transform3D",
|
||||
"Color", "NodePath", "RID", "Signal", "Callable", "Object", "Dictionary", "Array", "PackedByteArray", "PackedInt32Array", "PackedInt64Array", "PackedFloat32Array", "PackedFloat64Array", "PackedStringArray",
|
||||
"PackedVector2Array", "PackedVector3Array", "PackedColorArray"
|
||||
};
|
||||
static_assert((sizeof(_type_names) / sizeof(*_type_names)) == Variant::VARIANT_MAX, "Completion for builtin types is incomplete");
|
||||
|
||||
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
|
||||
ScriptLanguage::CodeCompletionOption option(_type_names[i], ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
_find_built_in_variants(r_result);
|
||||
|
||||
static const char *_keywords[] = {
|
||||
"false", "PI", "TAU", "INF", "NAN", "self", "true", "breakpoint", "tool", "super",
|
||||
|
Loading…
Reference in New Issue
Block a user