Merge pull request #62713 from YuriSizov/docs-scripting-annotations
This commit is contained in:
commit
635d447a69
19 changed files with 462 additions and 17 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue