mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-25 10:41:47 +03:00
Try to make visits simpler
This commit is contained in:
parent
a491c97059
commit
af030b9e7b
26
Lint.elm
26
Lint.elm
@ -93,24 +93,20 @@ statementToVisitors node =
|
||||
[]
|
||||
|
||||
|
||||
visitAndAccumulate : LintRule context -> Visitor context -> ( List Error, context ) -> ( List Error, context )
|
||||
visitAndAccumulate rule visitor ( errors, ctx ) =
|
||||
visitor rule ctx
|
||||
|> Tuple.mapFirst (\errors_ -> errors ++ errors_)
|
||||
|
||||
|
||||
lintWithVisitors : List (Visitor context) -> LintRule context -> List Error
|
||||
lintWithVisitors visitors rule =
|
||||
let
|
||||
( errors, _ ) =
|
||||
List.foldl
|
||||
(\visitor ( errors, ctx ) ->
|
||||
let
|
||||
( errors_, ctx_ ) =
|
||||
visitor rule ctx
|
||||
in
|
||||
( errors ++ errors_, ctx_ )
|
||||
)
|
||||
( [], rule.context )
|
||||
visitors
|
||||
in
|
||||
errors
|
||||
visitors
|
||||
|> List.foldl (visitAndAccumulate rule) ( [], rule.context )
|
||||
|> Tuple.first
|
||||
|
||||
|
||||
lint : List Statement -> LintRule context -> List Error
|
||||
lint statements =
|
||||
lintWithVisitors (List.concatMap statementToVisitors statements)
|
||||
List.concatMap statementToVisitors statements
|
||||
|> lintWithVisitors
|
||||
|
Loading…
Reference in New Issue
Block a user