mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-25 02:34:36 +03:00
Prepare for being able to supply multiple moduleVisitors to a project rule
This commit is contained in:
parent
3b2449af08
commit
8f83d4161f
@ -718,7 +718,7 @@ type ProjectRuleSchema projectContext moduleContext
|
|||||||
, fromModuleToProject : ModuleKey -> Node ModuleName -> moduleContext -> projectContext
|
, fromModuleToProject : ModuleKey -> Node ModuleName -> moduleContext -> projectContext
|
||||||
, foldProjectContexts : projectContext -> projectContext -> projectContext
|
, foldProjectContexts : projectContext -> projectContext -> projectContext
|
||||||
}
|
}
|
||||||
, moduleVisitor : ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext
|
, moduleVisitorCreators : List (ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext)
|
||||||
, elmJsonVisitors : List (Maybe { elmJsonKey : ElmJsonKey, project : Elm.Project.Project } -> projectContext -> ( List Error, projectContext ))
|
, elmJsonVisitors : List (Maybe { elmJsonKey : ElmJsonKey, project : Elm.Project.Project } -> projectContext -> ( List Error, projectContext ))
|
||||||
, readmeVisitors : List (Maybe { readmeKey : ReadmeKey, content : String } -> projectContext -> ( List Error, projectContext ))
|
, readmeVisitors : List (Maybe { readmeKey : ReadmeKey, content : String } -> projectContext -> ( List Error, projectContext ))
|
||||||
, dependenciesVisitors : List (Dict String Review.Project.Dependency.Dependency -> projectContext -> ( List Error, projectContext ))
|
, dependenciesVisitors : List (Dict String Review.Project.Dependency.Dependency -> projectContext -> ( List Error, projectContext ))
|
||||||
@ -934,7 +934,7 @@ newProjectRuleSchema name_ { moduleVisitor, initProjectContext, fromProjectToMod
|
|||||||
, fromModuleToProject = fromModuleToProject
|
, fromModuleToProject = fromModuleToProject
|
||||||
, foldProjectContexts = foldProjectContexts
|
, foldProjectContexts = foldProjectContexts
|
||||||
}
|
}
|
||||||
, moduleVisitor = moduleVisitor
|
, moduleVisitorCreators = [ moduleVisitor ]
|
||||||
, elmJsonVisitors = []
|
, elmJsonVisitors = []
|
||||||
, readmeVisitors = []
|
, readmeVisitors = []
|
||||||
, dependenciesVisitors = []
|
, dependenciesVisitors = []
|
||||||
@ -1119,6 +1119,8 @@ runProjectRule ((ProjectRuleSchema schema) as wrappedSchema) startCache exceptio
|
|||||||
|> List.map .path
|
|> List.map .path
|
||||||
|> Set.fromList
|
|> Set.fromList
|
||||||
|
|
||||||
|
-- TODO make it so we don't compute modules at all if there are no module visitors
|
||||||
|
-- We can probably do that by setting an initial context, and then just replacing in the call to visitModuleForProjectRule
|
||||||
computeModule : ProjectRuleCache projectContext -> List ProjectModule -> ProjectModule -> { source : String, errors : List Error, context : projectContext }
|
computeModule : ProjectRuleCache projectContext -> List ProjectModule -> ProjectModule -> { source : String, errors : List Error, context : projectContext }
|
||||||
computeModule cache importedModules module_ =
|
computeModule cache importedModules module_ =
|
||||||
let
|
let
|
||||||
@ -1149,10 +1151,15 @@ runProjectRule ((ProjectRuleSchema schema) as wrappedSchema) startCache exceptio
|
|||||||
|> List.foldl schema.context.foldProjectContexts initialContext
|
|> List.foldl schema.context.foldProjectContexts initialContext
|
||||||
|> schema.context.fromProjectToModule moduleKey moduleNameNode_
|
|> schema.context.fromProjectToModule moduleKey moduleNameNode_
|
||||||
|
|
||||||
|
-- TODO Make it so that we only compute the module visitors once
|
||||||
moduleVisitor : ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext
|
moduleVisitor : ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext
|
||||||
moduleVisitor =
|
moduleVisitor =
|
||||||
emptySchema "" initialModuleContext
|
List.foldl
|
||||||
|> schema.moduleVisitor
|
(\addVisitors (ModuleRuleSchema moduleVisitorSchema) ->
|
||||||
|
addVisitors (ModuleRuleSchema moduleVisitorSchema)
|
||||||
|
)
|
||||||
|
(emptySchema "" initialModuleContext)
|
||||||
|
schema.moduleVisitorCreators
|
||||||
|> reverseVisitors
|
|> reverseVisitors
|
||||||
|
|
||||||
( fileErrors, context ) =
|
( fileErrors, context ) =
|
||||||
@ -1286,7 +1293,7 @@ noImportedModulesHaveANewContext importedModules invalidatedModules =
|
|||||||
|> Set.isEmpty
|
|> Set.isEmpty
|
||||||
|
|
||||||
|
|
||||||
visitModuleForProjectRule : ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext -> moduleContext -> ProjectModule -> ( List Error, moduleContext )
|
visitModuleForProjectRule : ModuleRuleSchema a moduleContext -> moduleContext -> ProjectModule -> ( List Error, moduleContext )
|
||||||
visitModuleForProjectRule (ModuleRuleSchema schema) =
|
visitModuleForProjectRule (ModuleRuleSchema schema) =
|
||||||
let
|
let
|
||||||
declarationVisitors : InAndOut (DirectedVisitor Declaration moduleContext)
|
declarationVisitors : InAndOut (DirectedVisitor Declaration moduleContext)
|
||||||
|
Loading…
Reference in New Issue
Block a user