diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/doc_classes/@GDScript.xml | 141 | ||||
-rw-r--r-- | modules/gdscript/gdscript.h | 1 | ||||
-rw-r--r-- | modules/gdscript/gdscript_editor.cpp | 19 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 4 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.h | 1 | ||||
-rw-r--r-- | modules/mono/csharp_script.h | 1 | ||||
-rw-r--r-- | modules/visual_script/visual_script.cpp | 3 | ||||
-rw-r--r-- | modules/visual_script/visual_script.h | 1 |
8 files changed, 171 insertions, 0 deletions
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 70151c4d21..e672ea6454 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -257,4 +257,145 @@ [b]Note:[/b] "Not a Number" is only a concept with floating-point numbers, and has no equivalent for integers. Dividing an integer [code]0[/code] by [code]0[/code] will not result in [constant NAN] and will result in a run-time error instead. </constant> </constants> + <annotations> + <annotation name="@export"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@export_color_no_alpha"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@export_dir"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@export_enum" qualifiers="vararg"> + <return type="void" /> + <argument index="0" name="names" type="String" /> + <description> + </description> + </annotation> + <annotation name="@export_exp_easing"> + <return type="void" /> + <argument index="0" name="hint1" type="String" default="null" /> + <argument index="1" name="hint2" type="String" default="null" /> + <description> + </description> + </annotation> + <annotation name="@export_file" qualifiers="vararg"> + <return type="void" /> + <argument index="0" name="filter" type="String" default="null" /> + <description> + </description> + </annotation> + <annotation name="@export_flags" qualifiers="vararg"> + <return type="void" /> + <argument index="0" name="names" type="String" /> + <description> + </description> + </annotation> + <annotation name="@export_flags_2d_navigation"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@export_flags_2d_physics"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@export_flags_2d_render"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@export_flags_3d_navigation"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@export_flags_3d_physics"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@export_flags_3d_render"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@export_global_dir"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@export_global_file" qualifiers="vararg"> + <return type="void" /> + <argument index="0" name="filter" type="String" default="null" /> + <description> + </description> + </annotation> + <annotation name="@export_multiline"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@export_node_path" qualifiers="vararg"> + <return type="void" /> + <argument index="0" name="type" type="String" default="null" /> + <description> + </description> + </annotation> + <annotation name="@export_placeholder"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@export_range"> + <return type="void" /> + <argument index="0" name="min" type="float" /> + <argument index="1" name="max" type="float" /> + <argument index="2" name="step" type="float" default="null" /> + <argument index="3" name="slider1" type="String" default="null" /> + <argument index="4" name="slider2" type="String" default="null" /> + <argument index="5" name="slider3" type="String" default="null" /> + <description> + </description> + </annotation> + <annotation name="@icon"> + <return type="void" /> + <argument index="0" name="icon_path" type="String" /> + <description> + </description> + </annotation> + <annotation name="@onready"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@rpc" qualifiers="vararg"> + <return type="void" /> + <argument index="0" name="mode" type="String" default="null" /> + <argument index="1" name="sync" type="String" default="null" /> + <argument index="2" name="transfer_mode" type="String" default="null" /> + <argument index="3" name="transfer_channel" type="int" default="null" /> + <description> + </description> + </annotation> + <annotation name="@tool"> + <return type="void" /> + <description> + </description> + </annotation> + <annotation name="@warning_ignore" qualifiers="vararg"> + <return type="void" /> + <argument index="0" name="warning" type="String" /> + <description> + </description> + </annotation> + </annotations> </class> diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index feb0a237df..e9a206f48b 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -489,6 +489,7 @@ public: virtual void get_public_functions(List<MethodInfo> *p_functions) const override; virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const override; + virtual void get_public_annotations(List<MethodInfo> *p_annotations) const override; virtual void profiling_start() override; virtual void profiling_stop() override; diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index d50a139313..71ee437744 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -445,6 +445,16 @@ void GDScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_const p_constants->push_back(nan); } +void GDScriptLanguage::get_public_annotations(List<MethodInfo> *p_annotations) const { + GDScriptParser parser; + List<MethodInfo> annotations; + parser.get_annotation_list(&annotations); + + for (const MethodInfo &E : annotations) { + p_annotations->push_back(E); + } +} + String GDScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const { #ifdef TOOLS_ENABLED bool th = EditorSettings::get_singleton()->get_setting("text_editor/completion/add_type_hints"); @@ -3380,6 +3390,15 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co return OK; } } break; + case GDScriptParser::COMPLETION_ANNOTATION: { + const String annotation_symbol = "@" + p_symbol; + if (parser.annotation_exists(annotation_symbol)) { + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_ANNOTATION; + r_result.class_name = "@GDScript"; + r_result.class_member = annotation_symbol; + return OK; + } + } break; default: { } } diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 4e4f17f54b..11fa7575d8 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -105,6 +105,10 @@ void GDScriptParser::get_annotation_list(List<MethodInfo> *r_annotations) const } } +bool GDScriptParser::annotation_exists(const String &p_annotation_name) const { + return valid_annotations.has(p_annotation_name); +} + GDScriptParser::GDScriptParser() { // Register valid annotations. // TODO: Should this be static? diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 59afa45227..8d3295f25b 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -1434,6 +1434,7 @@ public: CompletionContext get_completion_context() const { return completion_context; } CompletionCall get_completion_call() const { return completion_call; } void get_annotation_list(List<MethodInfo> *r_annotations) const; + bool annotation_exists(const String &p_annotation_name) const; const List<ParserError> &get_errors() const { return errors; } const List<String> get_dependencies() const { diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index 69bd8703aa..91b14ba108 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -502,6 +502,7 @@ public: /* TODO? */ void get_public_functions(List<MethodInfo> *p_functions) const override {} /* TODO? */ void get_public_constants(List<Pair<String, Variant>> *p_constants) const override {} + /* TODO? */ void get_public_annotations(List<MethodInfo> *p_annotations) const override {} void reload_all_scripts() override; void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) override; diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index c5bcf23c8e..742fa75bb7 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -2435,6 +2435,9 @@ void VisualScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) c void VisualScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_constants) const { } +void VisualScriptLanguage::get_public_annotations(List<MethodInfo> *p_annotations) const { +} + void VisualScriptLanguage::profiling_start() { } diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index c2e4d0e597..716310f59b 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -599,6 +599,7 @@ public: virtual void get_recognized_extensions(List<String> *p_extensions) const override; virtual void get_public_functions(List<MethodInfo> *p_functions) const override; virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const override; + virtual void get_public_annotations(List<MethodInfo> *p_annotations) const override; virtual void profiling_start() override; virtual void profiling_stop() override; |