From 77390095c43545b26477e0b4c30e5ef83d37b2c6 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Wed, 27 Oct 2021 17:22:08 +0200 Subject: [PATCH] Add expressionVisitor --- src/Review/Rule.elm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Review/Rule.elm b/src/Review/Rule.elm index 9c751bce..ab910090 100644 --- a/src/Review/Rule.elm +++ b/src/Review/Rule.elm @@ -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)