More null checks (#517)

same as #513, just for a few more constructs. The switch statement already had the same thing in
This commit is contained in:
Jan Jurzitza 2017-08-13 19:06:23 +02:00 committed by Basile Burg
parent c98fa77f95
commit 8d53f8887e
1 changed files with 20 additions and 10 deletions

View File

@ -91,18 +91,26 @@ class UnusedVariableCheck : BaseAnalyzer
override void visit(const WhileStatement whileStatement) override void visit(const WhileStatement whileStatement)
{ {
interestDepth++; if (whileStatement.expression !is null)
whileStatement.expression.accept(this); {
interestDepth--; interestDepth++;
whileStatement.declarationOrStatement.accept(this); whileStatement.expression.accept(this);
interestDepth--;
}
if (whileStatement.declarationOrStatement !is null)
whileStatement.declarationOrStatement.accept(this);
} }
override void visit(const DoStatement doStatement) override void visit(const DoStatement doStatement)
{ {
interestDepth++; if (doStatement.expression !is null)
doStatement.expression.accept(this); {
interestDepth--; interestDepth++;
doStatement.statementNoCaseNoDefault.accept(this); doStatement.expression.accept(this);
interestDepth--;
}
if (doStatement.statementNoCaseNoDefault !is null)
doStatement.statementNoCaseNoDefault.accept(this);
} }
override void visit(const ForStatement forStatement) override void visit(const ForStatement forStatement)
@ -121,7 +129,8 @@ class UnusedVariableCheck : BaseAnalyzer
forStatement.increment.accept(this); forStatement.increment.accept(this);
interestDepth--; interestDepth--;
} }
forStatement.declarationOrStatement.accept(this); if (forStatement.declarationOrStatement !is null)
forStatement.declarationOrStatement.accept(this);
} }
override void visit(const IfStatement ifStatement) override void visit(const IfStatement ifStatement)
@ -157,7 +166,8 @@ class UnusedVariableCheck : BaseAnalyzer
override void visit(const AssignExpression assignExp) override void visit(const AssignExpression assignExp)
{ {
assignExp.ternaryExpression.accept(this); if (assignExp.ternaryExpression !is null)
assignExp.ternaryExpression.accept(this);
if (assignExp.expression !is null) if (assignExp.expression !is null)
{ {
interestDepth++; interestDepth++;