Do not visit and discover expressions if there is no expression visitor

This commit is contained in:
Jeroen Engels 2020-01-20 08:45:01 +01:00
parent d2f2ffa2cd
commit 11d8c925b2

View File

@ -1894,9 +1894,20 @@ visitDeclaration :
-> context
-> ( List Error, context )
visitDeclaration declarationVisitors expressionVisitors node context =
let
accumulateExpressionNodes : ( List Error, context ) -> ( List Error, context )
accumulateExpressionNodes =
if List.isEmpty expressionVisitors.onEnter then
identity
else
accumulateList
(visitExpression expressionVisitors)
(expressionsInDeclaration node)
in
( [], context )
|> visitNodeWithListOfVisitorsAndDirection OnEnter declarationVisitors.onEnter node
|> accumulateList (visitExpression expressionVisitors) (expressionsInDeclaration node)
|> accumulateExpressionNodes
|> visitNodeWithListOfVisitorsAndDirection OnExit declarationVisitors.onExit node