Add expressionVisitor

This commit is contained in:
Jeroen Engels 2021-10-27 17:22:08 +02:00
parent 6f206f8392
commit 77390095c4

View File

@ -1317,6 +1317,14 @@ mergeModuleVisitors initialProjectContext maybeModuleContextCreator visitors =
fromModuleRuleSchemaToRunnableModuleVisitor : ModuleRuleSchema schemaState moduleContext -> RunnableModuleVisitor moduleContext
fromModuleRuleSchemaToRunnableModuleVisitor (ModuleRuleSchema schema) =
let
expressionVisitor : List (Node Expression) -> ( List (Error {}), moduleContext ) -> ( List (Error {}), moduleContext )
expressionVisitor =
if shouldVisitExpressions schema then
accumulateList (visitExpression expressionVisitorRecord)
else
\_ errorsAndContext -> errorsAndContext
declarationAndExpressionVisitor : List (Node Declaration) -> ( List (Error {}), moduleContext ) -> ( List (Error {}), moduleContext )
declarationAndExpressionVisitor =
if shouldVisitDeclarationsAndExpressions schema then
@ -4365,6 +4373,16 @@ shouldVisitDeclarationsAndExpressions schema =
|| not (List.isEmpty schema.caseBranchVisitorsOnExit)
shouldVisitExpressions : ModuleRuleSchemaData moduleContext -> Bool
shouldVisitExpressions schema =
not (List.isEmpty schema.expressionVisitorsOnEnter)
|| not (List.isEmpty schema.expressionVisitorsOnExit)
|| not (List.isEmpty schema.letDeclarationVisitorsOnEnter)
|| not (List.isEmpty schema.letDeclarationVisitorsOnExit)
|| not (List.isEmpty schema.caseBranchVisitorsOnEnter)
|| not (List.isEmpty schema.caseBranchVisitorsOnExit)
type alias ExpressionRelatedVisitors moduleContext =
{ expressionVisitorsOnEnter : List (Visitor Expression moduleContext)
, expressionVisitorsOnExit : List (Visitor Expression moduleContext)