summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_analyzer.cpp
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2020-07-06 12:24:24 -0300
committerGeorge Marques <george@gmarqu.es>2020-07-20 11:38:40 -0300
commitaa09b4f85d94b9d563a0b2cbaa399427527ce6fc (patch)
treeeaa75dc439a53a972fb377c24138c8b6957cf5f6 /modules/gdscript/gdscript_analyzer.cpp
parentb6a2628c48ce7639e5f42caf43525fc2b9dae450 (diff)
downloadredot-engine-aa09b4f85d94b9d563a0b2cbaa399427527ce6fc.tar.gz
Reintroduce code completion
Diffstat (limited to 'modules/gdscript/gdscript_analyzer.cpp')
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index 5b19460b0d..7201490cee 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -1134,6 +1134,10 @@ void GDScriptAnalyzer::resolve_return(GDScriptParser::ReturnNode *p_return) {
void GDScriptAnalyzer::reduce_expression(GDScriptParser::ExpressionNode *p_expression) {
// This one makes some magic happen.
+ if (p_expression == nullptr) {
+ return;
+ }
+
if (p_expression->reduced) {
// Don't do this more than once.
return;
@@ -1248,6 +1252,10 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
reduce_expression(p_assignment->assignee);
reduce_expression(p_assignment->assigned_value);
+ if (p_assignment->assigned_value == nullptr || p_assignment->assignee == nullptr) {
+ return;
+ }
+
if (p_assignment->assignee->get_datatype().is_constant) {
push_error("Cannot assign a new value to a constant.", p_assignment->assignee);
}
@@ -2038,6 +2046,9 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri
// Reduce index first. If it's a constant StringName, use attribute instead.
if (!p_subscript->is_attribute) {
+ if (p_subscript->index == nullptr) {
+ return;
+ }
reduce_expression(p_subscript->index);
if (p_subscript->index->is_constant && p_subscript->index->reduced_value.get_type() == Variant::STRING_NAME) {
@@ -2053,6 +2064,9 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri
}
if (p_subscript->is_attribute) {
+ if (p_subscript->attribute == nullptr) {
+ return;
+ }
if (p_subscript->base->is_constant) {
// Just try to get it.
bool valid = false;