Rename withModuleDependenciesVisitor to withDependenciesModuleVisitor

This commit is contained in:
Jeroen Engels 2020-03-02 22:53:37 +01:00
parent c09c46e4eb
commit 5cfd68fb6b
5 changed files with 18 additions and 18 deletions

View File

@ -24,6 +24,6 @@ import Set exposing (Set)
rule : Rule
rule =
Rule.newModuleRuleSchema "NoWithInitialContextAfterHavingAddedAVisitor" ()
|> Rule.withModuleDependenciesVisitor (\_ context -> context)
|> Rule.withDependenciesModuleVisitor (\_ context -> context)
|> Rule.withDeclarationListVisitor (\_ context -> ( [], context ))
|> Rule.fromModuleRuleSchema

View File

@ -4,7 +4,7 @@ module Review.Rule exposing
, ModuleRuleSchema, newModuleRuleSchema, fromModuleRuleSchema
, withSimpleModuleDefinitionVisitor, withSimpleCommentsVisitor, withSimpleImportVisitor, withSimpleDeclarationVisitor, withSimpleExpressionVisitor
, withModuleDefinitionVisitor, withCommentsVisitor, withImportVisitor, Direction(..), withDeclarationVisitor, withDeclarationListVisitor, withExpressionVisitor, withFinalModuleEvaluation
, withElmJsonModuleVisitor, withModuleDependenciesVisitor
, withElmJsonModuleVisitor, withDependenciesModuleVisitor
, ProjectRuleSchema, newProjectRuleSchema, fromProjectRuleSchema, withElmJsonProjectVisitor, withProjectDependenciesVisitor, withFinalProjectEvaluation, withContextFromImportedModules
, Error, error, errorRuleName, errorMessage, errorDetails, errorRange, errorFixes, errorFilePath, ModuleKey, errorForFile, ElmJsonKey, errorForElmJson
, withFixes
@ -151,7 +151,7 @@ The traversal of a module rule is the following:
- Read project-related info (only collect data in the context in these steps)
- The `elm.json` file, visited by [`withElmJsonModuleVisitor`](#withElmJsonModuleVisitor)
- The definition for dependencies, visited by [`withModuleDependenciesVisitor`](#withModuleDependenciesVisitor)
- The definition for dependencies, visited by [`withDependenciesModuleVisitor`](#withDependenciesModuleVisitor)
- Visit the file (in the following order)
- The module definition, visited by [`withSimpleModuleDefinitionVisitor`](#withSimpleModuleDefinitionVisitor) and [`withModuleDefinitionVisitor`](#withModuleDefinitionVisitor)
- The module's list of comments, visited by [`withSimpleCommentsVisitor`](#withSimpleCommentsVisitor) and [`withCommentsVisitor`](#withCommentsVisitor)
@ -184,7 +184,7 @@ Evaluating/visiting a node means two things:
## Builder functions to analyze the project's data
@docs withElmJsonModuleVisitor, withModuleDependenciesVisitor
@docs withElmJsonModuleVisitor, withDependenciesModuleVisitor
## Creating a project rule
@ -521,7 +521,7 @@ take a look at [`withInitialContext`](#withInitialContext) and "with\*" function
newModuleRuleSchema :
String
-> moduleContext
-> ModuleRuleSchema { withElmJsonModuleVisitor : (), withModuleDependenciesVisitor : () } moduleContext
-> ModuleRuleSchema { withElmJsonModuleVisitor : (), withDependenciesModuleVisitor : () } moduleContext
newModuleRuleSchema name_ moduleContext =
emptySchema name_ moduleContext
@ -776,7 +776,7 @@ same visitors as for module rules. The exception are the following visitors, whi
are replaced by functions that you need to use on the project rule schema.
- [`withElmJsonModuleVisitor`](#withElmJsonModuleVisitor), replaced by [`withElmJsonProjectVisitor`](#withElmJsonProjectVisitor)
- [`withModuleDependenciesVisitor`](#withModuleDependenciesVisitor), replaced by [`withProjectDependenciesVisitor`](#withProjectDependenciesVisitor)
- [`withDependenciesModuleVisitor`](#withDependenciesModuleVisitor), replaced by [`withProjectDependenciesVisitor`](#withProjectDependenciesVisitor)
- [`withFinalModuleEvaluation`](#withFinalModuleEvaluation), replaced by [`withFinalProjectEvaluation`](#withFinalProjectEvaluation)
Let's look at the data that we will be working with.
@ -886,7 +886,7 @@ Before looking at modules...TODO
- Read project-related info (only collect data in the context in these steps)
- The `elm.json` file, visited by [`withElmJsonModuleVisitor`](#withElmJsonModuleVisitor)
- The definition for dependencies, visited by [`withModuleDependenciesVisitor`](#withModuleDependenciesVisitor)
- The definition for dependencies, visited by [`withDependenciesModuleVisitor`](#withDependenciesModuleVisitor)
- Visit the file (in the following order)
- The module definition, visited by [`withSimpleModuleDefinitionVisitor`](#withSimpleModuleDefinitionVisitor) and [`withModuleDefinitionVisitor`](#withModuleDefinitionVisitor)
- The module's list of comments, visited by [`withSimpleCommentsVisitor`](#withSimpleCommentsVisitor) and [`withCommentsVisitor`](#withCommentsVisitor)
@ -898,7 +898,7 @@ Before looking at modules...TODO
- A final evaluation is made when the module has fully been visited, using [`withFinalModuleEvaluation`](#withFinalModuleEvaluation)
- A final evaluation is made when the module has fully been visited, using [`withFinalModuleEvaluation`](#withFinalModuleEvaluation)
You can't use [`withElmJsonModuleVisitor`](#withElmJsonModuleVisitor) or [`withModuleDependenciesVisitor`](#withModuleDependenciesVisitor)
You can't use [`withElmJsonModuleVisitor`](#withElmJsonModuleVisitor) or [`withDependenciesModuleVisitor`](#withDependenciesModuleVisitor)
in project rules. Instead, you should use [`withElmJsonProjectVisitor`](#withElmJsonProjectVisitor) or [`withProjectDependenciesVisitor`](#withProjectDependenciesVisitor).
-}
@ -1684,11 +1684,11 @@ withElmJsonModuleVisitor visitor (ModuleRuleSchema schema) =
{-| TODO
-}
withModuleDependenciesVisitor :
withDependenciesModuleVisitor :
(Dict String Review.Project.Dependency -> moduleContext -> moduleContext)
-> ModuleRuleSchema { anything | withModuleDependenciesVisitor : () } moduleContext
-> ModuleRuleSchema { anything | withModuleDependenciesVisitor : () } moduleContext
withModuleDependenciesVisitor visitor (ModuleRuleSchema schema) =
-> ModuleRuleSchema { anything | withDependenciesModuleVisitor : () } moduleContext
-> ModuleRuleSchema { anything | withDependenciesModuleVisitor : () } moduleContext
withDependenciesModuleVisitor visitor (ModuleRuleSchema schema) =
ModuleRuleSchema { schema | dependenciesVisitors = visitor :: schema.dependenciesVisitors }

View File

@ -83,11 +83,11 @@ emptyScope =
addVisitors :
Rule.ModuleRuleSchema { anything | withModuleDependenciesVisitor : () } { context | scope : Context }
-> Rule.ModuleRuleSchema { anything | withModuleDependenciesVisitor : (), hasAtLeastOneVisitor : () } { context | scope : Context }
Rule.ModuleRuleSchema { anything | withDependenciesModuleVisitor : () } { context | scope : Context }
-> Rule.ModuleRuleSchema { anything | withDependenciesModuleVisitor : (), hasAtLeastOneVisitor : () } { context | scope : Context }
addVisitors schema =
schema
|> Rule.withModuleDependenciesVisitor
|> Rule.withDependenciesModuleVisitor
(mapInnerContext dependenciesVisitor)
|> Rule.withImportVisitor
(mapInnerContext importVisitor |> pairWithNoErrors)

View File

@ -22,7 +22,7 @@ all =
rule =
Rule.newModuleRuleSchema "TestRule" "\n0 - initial context"
|> Rule.withElmJsonModuleVisitor (\_ context -> context ++ "\n1 - withElmJsonModuleVisitor")
|> Rule.withModuleDependenciesVisitor (\_ context -> context ++ "\n2 - withModuleDependenciesVisitor")
|> Rule.withDependenciesModuleVisitor (\_ context -> context ++ "\n2 - withDependenciesModuleVisitor")
|> Rule.withModuleDefinitionVisitor (\_ context -> ( [], context ++ "\n3 - withModuleDefinitionVisitor" ))
|> Rule.withImportVisitor (\_ context -> ( [], context ++ "\n4 - withImportVisitor" ))
|> Rule.withDeclarationListVisitor (\_ context -> ( [], context ++ "\n5 - withDeclarationListVisitor" ))
@ -65,7 +65,7 @@ a = 1
{ message = """
0 - initial context
1 - withElmJsonModuleVisitor
2 - withModuleDependenciesVisitor
2 - withDependenciesModuleVisitor
3 - withModuleDefinitionVisitor
4 - withImportVisitor
5 - withDeclarationListVisitor

View File

@ -33,7 +33,7 @@ testRule rule string =
baseRule :
Rule.ModuleRuleSchema
{ hasAtLeastOneVisitor : ()
, withModuleDependenciesVisitor : ()
, withDependenciesModuleVisitor : ()
, withElmJsonModuleVisitor : ()
}
Context