mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-11-24 15:54:02 +03:00
Simplify the final evaluation by not having it return a context
This commit is contained in:
parent
e979393ef8
commit
68a4c9ab01
@ -22,7 +22,7 @@ createExitAndEnterWithChildren toVisitor node children =
|
||||
|
||||
moduleVisitor : Visitor context
|
||||
moduleVisitor rule context =
|
||||
finalEvaluation rule context
|
||||
( finalEvaluation rule context, context )
|
||||
|
||||
|
||||
moduleDefinitionVisitor : Node Module -> Visitor context
|
||||
|
@ -95,7 +95,7 @@ type Implementation context
|
||||
, importVisitor : context -> Node Import -> ( List Error, context )
|
||||
, expressionVisitor : context -> Direction -> Node Expression -> ( List Error, context )
|
||||
, declarationVisitor : context -> Direction -> Node Declaration -> ( List Error, context )
|
||||
, finalEvaluationFn : context -> ( List Error, context )
|
||||
, finalEvaluationFn : context -> List Error
|
||||
}
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ create initContext =
|
||||
, importVisitor = \ctx node -> ( [], ctx )
|
||||
, expressionVisitor = \ctx direction node -> ( [], ctx )
|
||||
, declarationVisitor = \ctx direction node -> ( [], ctx )
|
||||
, finalEvaluationFn = \ctx -> ( [], ctx )
|
||||
, finalEvaluationFn = \ctx -> []
|
||||
}
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ withDeclarationVisitor visitor (Implementation impl) =
|
||||
Implementation { impl | declarationVisitor = visitor }
|
||||
|
||||
|
||||
withFinalEvaluation : (context -> ( List Error, context )) -> Implementation context -> Implementation context
|
||||
withFinalEvaluation : (context -> List Error) -> Implementation context -> Implementation context
|
||||
withFinalEvaluation visitor (Implementation impl) =
|
||||
Implementation { impl | finalEvaluationFn = visitor }
|
||||
|
||||
@ -165,7 +165,7 @@ evaluateDeclaration (Implementation impl) =
|
||||
impl.declarationVisitor
|
||||
|
||||
|
||||
finalEvaluation : Implementation context -> context -> ( List Error, context )
|
||||
finalEvaluation : Implementation context -> context -> List Error
|
||||
finalEvaluation (Implementation impl) =
|
||||
impl.finalEvaluationFn
|
||||
|
||||
|
@ -315,20 +315,16 @@ declarationVisitor ctx direction node =
|
||||
( [], ctx )
|
||||
|
||||
|
||||
finalEvaluation : Context -> ( List Error, Context )
|
||||
finalEvaluation : Context -> List Error
|
||||
finalEvaluation ctx =
|
||||
let
|
||||
errors =
|
||||
if ctx.exposesEverything then
|
||||
[]
|
||||
if ctx.exposesEverything then
|
||||
[]
|
||||
|
||||
else
|
||||
ctx.scopes
|
||||
|> Nonempty.head
|
||||
|> makeReport
|
||||
|> Tuple.first
|
||||
in
|
||||
( errors, ctx )
|
||||
else
|
||||
ctx.scopes
|
||||
|> Nonempty.head
|
||||
|> makeReport
|
||||
|> Tuple.first
|
||||
|
||||
|
||||
registerFunction : Function -> Context -> Context
|
||||
|
Loading…
Reference in New Issue
Block a user