GDScript: Fix POT generator crash on assignee with index
This commit is contained in:
parent
b467afe65d
commit
d991cc4998
|
@ -225,10 +225,15 @@ void GDScriptEditorTranslationParserPlugin::_assess_assignment(const GDScriptPar
|
||||||
if (p_assignment->assignee->type == GDScriptParser::Node::IDENTIFIER) {
|
if (p_assignment->assignee->type == GDScriptParser::Node::IDENTIFIER) {
|
||||||
assignee_name = static_cast<const GDScriptParser::IdentifierNode *>(p_assignment->assignee)->name;
|
assignee_name = static_cast<const GDScriptParser::IdentifierNode *>(p_assignment->assignee)->name;
|
||||||
} else if (p_assignment->assignee->type == GDScriptParser::Node::SUBSCRIPT) {
|
} else if (p_assignment->assignee->type == GDScriptParser::Node::SUBSCRIPT) {
|
||||||
assignee_name = static_cast<const GDScriptParser::SubscriptNode *>(p_assignment->assignee)->attribute->name;
|
const GDScriptParser::SubscriptNode *subscript = static_cast<const GDScriptParser::SubscriptNode *>(p_assignment->assignee);
|
||||||
|
if (subscript->is_attribute && subscript->attribute) {
|
||||||
|
assignee_name = subscript->attribute->name;
|
||||||
|
} else if (subscript->index && _is_constant_string(subscript->index)) {
|
||||||
|
assignee_name = subscript->index->reduced_value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assignment_patterns.has(assignee_name) && _is_constant_string(p_assignment->assigned_value)) {
|
if (assignee_name != StringName() && assignment_patterns.has(assignee_name) && _is_constant_string(p_assignment->assigned_value)) {
|
||||||
// If the assignment is towards one of the extract patterns (text, tooltip_text etc.), and the value is a constant string, we collect the string.
|
// If the assignment is towards one of the extract patterns (text, tooltip_text etc.), and the value is a constant string, we collect the string.
|
||||||
ids->push_back(p_assignment->assigned_value->reduced_value);
|
ids->push_back(p_assignment->assigned_value->reduced_value);
|
||||||
} else if (assignee_name == fd_filters && p_assignment->assigned_value->type == GDScriptParser::Node::CALL) {
|
} else if (assignee_name == fd_filters && p_assignment->assigned_value->type == GDScriptParser::Node::CALL) {
|
||||||
|
@ -236,7 +241,7 @@ void GDScriptEditorTranslationParserPlugin::_assess_assignment(const GDScriptPar
|
||||||
// get_node("FileDialog").filters = PackedStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"]).
|
// get_node("FileDialog").filters = PackedStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"]).
|
||||||
|
|
||||||
const GDScriptParser::CallNode *call_node = static_cast<const GDScriptParser::CallNode *>(p_assignment->assigned_value);
|
const GDScriptParser::CallNode *call_node = static_cast<const GDScriptParser::CallNode *>(p_assignment->assigned_value);
|
||||||
if (call_node->arguments[0]->type == GDScriptParser::Node::ARRAY) {
|
if (!call_node->arguments.is_empty() && call_node->arguments[0]->type == GDScriptParser::Node::ARRAY) {
|
||||||
const GDScriptParser::ArrayNode *array_node = static_cast<const GDScriptParser::ArrayNode *>(call_node->arguments[0]);
|
const GDScriptParser::ArrayNode *array_node = static_cast<const GDScriptParser::ArrayNode *>(call_node->arguments[0]);
|
||||||
|
|
||||||
// Extract the name in "extension ; name" of PackedStringArray.
|
// Extract the name in "extension ; name" of PackedStringArray.
|
||||||
|
|
Loading…
Reference in New Issue