You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
GDScript: Do phrase level recovery for match
This commit is contained in:
@@ -2359,8 +2359,16 @@ GDScriptParser::MatchBranchNode *GDScriptParser::parse_match_branch() {
|
||||
}
|
||||
|
||||
if (!consume(GDScriptTokenizer::Token::COLON, vformat(R"(Expected ":"%s after "match" %s.)", has_guard ? "" : R"( or "when")", has_guard ? "pattern guard" : "patterns"))) {
|
||||
branch->block = alloc_recovery_suite();
|
||||
complete_extents(branch);
|
||||
return nullptr;
|
||||
// Consume the whole line and treat the next one as new match branch.
|
||||
while (current.type != GDScriptTokenizer::Token::NEWLINE && !is_at_end()) {
|
||||
advance();
|
||||
}
|
||||
if (!is_at_end()) {
|
||||
advance();
|
||||
}
|
||||
return branch;
|
||||
}
|
||||
|
||||
SuiteNode *suite = alloc_node<SuiteNode>();
|
||||
|
||||
@@ -1463,6 +1463,14 @@ private:
|
||||
return node;
|
||||
}
|
||||
|
||||
SuiteNode *alloc_recovery_suite() {
|
||||
SuiteNode *suite = alloc_recovery_node<SuiteNode>();
|
||||
suite->parent_block = current_suite;
|
||||
suite->parent_function = current_function;
|
||||
suite->is_in_loop = current_suite->is_in_loop;
|
||||
return suite;
|
||||
}
|
||||
|
||||
void clear();
|
||||
void push_error(const String &p_message, const Node *p_origin = nullptr);
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
[output]
|
||||
include=[
|
||||
{"display": "AUTO_TRANSLATE_MODE_INHERIT"},
|
||||
]
|
||||
@@ -0,0 +1,7 @@
|
||||
extends Node
|
||||
|
||||
var t
|
||||
|
||||
func test():
|
||||
match t:
|
||||
AutoTranslateMode.➡
|
||||
@@ -0,0 +1,4 @@
|
||||
[output]
|
||||
include=[
|
||||
{"display": "VALUE"},
|
||||
]
|
||||
@@ -0,0 +1,11 @@
|
||||
extends Node
|
||||
|
||||
enum TestEnum {
|
||||
VALUE,
|
||||
}
|
||||
|
||||
var t
|
||||
|
||||
func test():
|
||||
match t:
|
||||
TestEnum.➡ where
|
||||
@@ -0,0 +1,4 @@
|
||||
[output]
|
||||
include=[
|
||||
{"display": "VALUE"},
|
||||
]
|
||||
@@ -0,0 +1,11 @@
|
||||
extends Node
|
||||
|
||||
enum TestEnum {
|
||||
VALUE,
|
||||
}
|
||||
|
||||
var t
|
||||
|
||||
func test():
|
||||
match t:
|
||||
TestEnum.➡:
|
||||
@@ -0,0 +1,4 @@
|
||||
[output]
|
||||
include=[
|
||||
{"display": "AUTO_TRANSLATE_MODE_INHERIT"},
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
extends Node
|
||||
|
||||
func test():
|
||||
match AutoTranslateMode.➡
|
||||
@@ -0,0 +1,4 @@
|
||||
[output]
|
||||
include=[
|
||||
{"display": "VALUE"},
|
||||
]
|
||||
@@ -0,0 +1,8 @@
|
||||
extends Node
|
||||
|
||||
enum TestEnum {
|
||||
VALUE,
|
||||
}
|
||||
|
||||
func test():
|
||||
match TestEnum.➡:
|
||||
@@ -0,0 +1,4 @@
|
||||
[output]
|
||||
include=[
|
||||
{"display": "AUTO_TRANSLATE_MODE_INHERIT"},
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
extends Node
|
||||
|
||||
func test():
|
||||
match AutoTranslateMode.➡:
|
||||
pass
|
||||
@@ -0,0 +1,4 @@
|
||||
[output]
|
||||
include=[
|
||||
{"display": "VALUE"},
|
||||
]
|
||||
@@ -0,0 +1,9 @@
|
||||
extends Node
|
||||
|
||||
enum TestEnum {
|
||||
VALUE,
|
||||
}
|
||||
|
||||
func test():
|
||||
match TestEnum.➡:
|
||||
TestEnum
|
||||
Reference in New Issue
Block a user