summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/gdscript_parser.h')
-rw-r--r--modules/gdscript/gdscript_parser.h39
1 files changed, 24 insertions, 15 deletions
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h
index 4c11fa7f8b..7840474a89 100644
--- a/modules/gdscript/gdscript_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -189,6 +189,8 @@ public:
GDScriptParser::DataType get_typed_container_type() const;
+ bool can_reference(const DataType &p_other) const;
+
bool operator==(const DataType &p_other) const {
if (type_source == UNDETECTED || p_other.type_source == UNDETECTED) {
return true; // Can be considered equal for parsing purposes.
@@ -1314,7 +1316,7 @@ public:
Variant::Type builtin_type = Variant::VARIANT_MAX;
Node *node = nullptr;
Object *base = nullptr;
- List<Ref<GDScriptParserRef>> dependent_parsers;
+ GDScriptParser *parser = nullptr;
};
struct CompletionCall {
@@ -1329,6 +1331,7 @@ private:
bool _is_tool = false;
String script_path;
bool for_completion = false;
+ bool parse_body = true;
bool panic_mode = false;
bool can_break = false;
bool can_continue = false;
@@ -1370,7 +1373,7 @@ private:
bool in_lambda = false;
bool lambda_ended = false; // Marker for when a lambda ends, to apply an end of statement if needed.
- typedef bool (GDScriptParser::*AnnotationAction)(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ typedef bool (GDScriptParser::*AnnotationAction)(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
struct AnnotationInfo {
enum TargetKind {
NONE = 0,
@@ -1454,9 +1457,14 @@ private:
}
void apply_pending_warnings();
#endif
-
- void make_completion_context(CompletionType p_type, Node *p_node, int p_argument = -1, bool p_force = false);
- void make_completion_context(CompletionType p_type, Variant::Type p_builtin_type, bool p_force = false);
+ // Setting p_force to false will prevent the completion context from being update if a context was already set before.
+ // This should only be done when we push context before we consumed any tokens for the corresponding structure.
+ // See parse_precedence for an example.
+ void make_completion_context(CompletionType p_type, Node *p_node, int p_argument = -1, bool p_force = true);
+ void make_completion_context(CompletionType p_type, Variant::Type p_builtin_type, bool p_force = true);
+ // In some cases it might become necessary to alter the completion context after parsing a subexpression.
+ // For example to not override COMPLETE_CALL_ARGUMENTS with COMPLETION_NONE from string literals.
+ void override_completion_context(const Node *p_for_node, CompletionType p_type, Node *p_node, int p_argument = -1);
void push_completion_call(Node *p_call);
void pop_completion_call();
void set_last_completion_call_arg(int p_argument);
@@ -1492,17 +1500,18 @@ private:
static bool register_annotation(const MethodInfo &p_info, uint32_t p_target_kinds, AnnotationAction p_apply, const Vector<Variant> &p_default_arguments = Vector<Variant>(), bool p_is_vararg = false);
bool validate_annotation_arguments(AnnotationNode *p_annotation);
void clear_unused_annotations();
- bool tool_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
- bool icon_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
- bool onready_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool tool_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool icon_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool onready_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
template <PropertyHint t_hint, Variant::Type t_type>
- bool export_annotations(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
- bool export_custom_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool export_annotations(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool export_storage_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool export_custom_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
template <PropertyUsageFlags t_usage>
- bool export_group_annotations(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
- bool warning_annotations(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
- bool rpc_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
- bool static_unload_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool export_group_annotations(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool warning_annotations(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool rpc_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool static_unload_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
// Statements.
Node *parse_statement();
VariableNode *parse_variable(bool p_is_static);
@@ -1559,7 +1568,7 @@ private:
#endif // TOOLS_ENABLED
public:
- Error parse(const String &p_source_code, const String &p_script_path, bool p_for_completion);
+ Error parse(const String &p_source_code, const String &p_script_path, bool p_for_completion, bool p_parse_body = true);
Error parse_binary(const Vector<uint8_t> &p_binary, const String &p_script_path);
ClassNode *get_tree() const { return head; }
bool is_tool() const { return _is_tool; }