diff --git a/src/NoUnusedExports.elm b/src/NoUnusedExports.elm index f72458ea..0b5b4877 100644 --- a/src/NoUnusedExports.elm +++ b/src/NoUnusedExports.elm @@ -65,8 +65,8 @@ rule = |> Rule.withDeclarationListVisitor declarationListVisitor |> Rule.withExpressionVisitor expressionVisitor , initProjectContext = initProjectContext - , fromGlobalToModule = fromGlobalToModule - , fromModuleToGlobal = fromModuleToGlobal + , fromProjectToModule = fromProjectToModule + , fromModuleToProject = fromModuleToProject , foldProjectContexts = foldProjectContexts } |> Scope.addGlobalVisitors @@ -124,9 +124,9 @@ initProjectContext = } -fromGlobalToModule : Rule.FileKey -> Node ModuleName -> ProjectContext -> ModuleContext -fromGlobalToModule fileKey moduleName projectContext = - { scope = Scope.fromGlobalToModule projectContext.scope +fromProjectToModule : Rule.FileKey -> Node ModuleName -> ProjectContext -> ModuleContext +fromProjectToModule fileKey moduleName projectContext = + { scope = Scope.fromProjectToModule projectContext.scope , exposesEverything = False , exposed = Dict.empty , used = Set.empty @@ -134,9 +134,9 @@ fromGlobalToModule fileKey moduleName projectContext = } -fromModuleToGlobal : Rule.FileKey -> Node ModuleName -> ModuleContext -> ProjectContext -fromModuleToGlobal fileKey moduleName moduleContext = - { scope = Scope.fromModuleToGlobal moduleName moduleContext.scope +fromModuleToProject : Rule.FileKey -> Node ModuleName -> ModuleContext -> ProjectContext +fromModuleToProject fileKey moduleName moduleContext = + { scope = Scope.fromModuleToProject moduleName moduleContext.scope , projectType = IsApplication , modules = Dict.singleton diff --git a/src/NoUnusedModules.elm b/src/NoUnusedModules.elm index 6086617d..83a07453 100644 --- a/src/NoUnusedModules.elm +++ b/src/NoUnusedModules.elm @@ -53,8 +53,8 @@ rule = |> Rule.withImportVisitor importVisitor |> Rule.withDeclarationListVisitor declarationListVisitor , initProjectContext = initProjectContext - , fromGlobalToModule = fromGlobalToModule - , fromModuleToGlobal = fromModuleToGlobal + , fromProjectToModule = fromProjectToModule + , fromModuleToProject = fromModuleToProject , foldProjectContexts = foldProjectContexts } |> Rule.withProjectElmJsonVisitor elmJsonVisitor @@ -92,16 +92,16 @@ initProjectContext = } -fromGlobalToModule : Rule.FileKey -> Node ModuleName -> ProjectContext -> ModuleContext -fromGlobalToModule _ _ projectContext = +fromProjectToModule : Rule.FileKey -> Node ModuleName -> ProjectContext -> ModuleContext +fromProjectToModule _ _ projectContext = { importedModules = Set.empty , containsMainFunction = False , isPackage = projectContext.isPackage } -fromModuleToGlobal : Rule.FileKey -> Node ModuleName -> ModuleContext -> ProjectContext -fromModuleToGlobal fileKey moduleName moduleContext = +fromModuleToProject : Rule.FileKey -> Node ModuleName -> ModuleContext -> ProjectContext +fromModuleToProject fileKey moduleName moduleContext = { modules = Dict.singleton (Node.value moduleName) diff --git a/src/Review/Rule.elm b/src/Review/Rule.elm index 0384151e..5734f5c4 100644 --- a/src/Review/Rule.elm +++ b/src/Review/Rule.elm @@ -494,8 +494,8 @@ type ProjectRuleSchema projectContext moduleContext { name : String , context : { initProjectContext : projectContext - , fromGlobalToModule : FileKey -> Node ModuleName -> projectContext -> moduleContext - , fromModuleToGlobal : FileKey -> Node ModuleName -> moduleContext -> projectContext + , fromProjectToModule : FileKey -> Node ModuleName -> projectContext -> moduleContext + , fromModuleToProject : FileKey -> Node ModuleName -> moduleContext -> projectContext , foldProjectContexts : projectContext -> projectContext -> projectContext } , moduleVisitorSchema : ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext @@ -516,18 +516,18 @@ newProjectRuleSchema : -> { moduleVisitorSchema : ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext , initProjectContext : projectContext - , fromGlobalToModule : FileKey -> Node ModuleName -> projectContext -> moduleContext - , fromModuleToGlobal : FileKey -> Node ModuleName -> moduleContext -> projectContext + , fromProjectToModule : FileKey -> Node ModuleName -> projectContext -> moduleContext + , fromModuleToProject : FileKey -> Node ModuleName -> moduleContext -> projectContext , foldProjectContexts : projectContext -> projectContext -> projectContext } -> ProjectRuleSchema projectContext moduleContext -newProjectRuleSchema name_ { moduleVisitorSchema, initProjectContext, fromGlobalToModule, fromModuleToGlobal, foldProjectContexts } = +newProjectRuleSchema name_ { moduleVisitorSchema, initProjectContext, fromProjectToModule, fromModuleToProject, foldProjectContexts } = ProjectRuleSchema { name = name_ , context = { initProjectContext = initProjectContext - , fromGlobalToModule = fromGlobalToModule - , fromModuleToGlobal = fromModuleToGlobal + , fromProjectToModule = fromProjectToModule + , fromModuleToProject = fromModuleToProject , foldProjectContexts = foldProjectContexts } , moduleVisitorSchema = moduleVisitorSchema @@ -595,7 +595,7 @@ allModulesInParallelTraversal (ProjectRuleSchema schema) startCache project = initialModuleContext : moduleContext initialModuleContext = - schema.context.fromGlobalToModule + schema.context.fromProjectToModule fileKey moduleNameNode_ initialContext @@ -615,7 +615,7 @@ allModulesInParallelTraversal (ProjectRuleSchema schema) startCache project = { source = module_.source , errors = List.map (\(Error err) -> Error { err | filePath = module_.path }) fileErrors , context = - schema.context.fromModuleToGlobal + schema.context.fromModuleToProject fileKey moduleNameNode_ context @@ -711,7 +711,7 @@ importedModulesFirst (ProjectRuleSchema schema) startCache project = ) -- TODO Remove contexts from parents already handled by other parents |> List.foldl schema.context.foldProjectContexts initialContext - |> schema.context.fromGlobalToModule fileKey moduleNameNode_ + |> schema.context.fromProjectToModule fileKey moduleNameNode_ moduleVisitor : ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext moduleVisitor = @@ -728,7 +728,7 @@ importedModulesFirst (ProjectRuleSchema schema) startCache project = { source = module_.source , errors = List.map (\(Error err) -> Error { err | filePath = module_.path }) fileErrors , context = - schema.context.fromModuleToGlobal + schema.context.fromModuleToProject fileKey moduleNameNode_ context diff --git a/src/Scope2.elm b/src/Scope2.elm index 20c8507d..288f15eb 100644 --- a/src/Scope2.elm +++ b/src/Scope2.elm @@ -1,6 +1,6 @@ module Scope2 exposing ( ProjectContext, ModuleContext - , GlobalSetterGetter, addGlobalVisitors, ModuleSetterGetter, addModuleVisitors, initProjectContext, fromGlobalToModule, fromModuleToGlobal, foldProjectContexts + , GlobalSetterGetter, addGlobalVisitors, ModuleSetterGetter, addModuleVisitors, initProjectContext, fromProjectToModule, fromModuleToProject, foldProjectContexts , realFunctionOrType ) @@ -14,7 +14,7 @@ module Scope2 exposing # Usage -@docs GlobalSetterGetter, addGlobalVisitors, ModuleSetterGetter, addModuleVisitors, initProjectContext, fromGlobalToModule, fromModuleToGlobal, foldProjectContexts +@docs GlobalSetterGetter, addGlobalVisitors, ModuleSetterGetter, addModuleVisitors, initProjectContext, fromProjectToModule, fromModuleToProject, foldProjectContexts # Access @@ -56,8 +56,8 @@ import Review.Rule as Rule exposing (Direction, Error) schema |> Rule.withModuleDefinitionVisitor moduleDefinitionVisitor , initProjectContext = initProjectContext - , fromGlobalToModule = fromGlobalToModule - , fromModuleToGlobal = fromModuleToGlobal + , fromProjectToModule = fromProjectToModule + , fromModuleToProject = fromModuleToProject , foldProjectContexts = foldProjectContexts }) @@ -131,8 +131,8 @@ initProjectContext = } -fromGlobalToModule : ProjectContext -> ModuleContext -fromGlobalToModule (ProjectContext projectContext) = +fromProjectToModule : ProjectContext -> ModuleContext +fromProjectToModule (ProjectContext projectContext) = { scopes = NonemptyList.fromElement emptyScope , importAliases = Dict.empty , importedFunctionOrTypes = Dict.empty @@ -149,8 +149,8 @@ fromGlobalToModule (ProjectContext projectContext) = |> ModuleContext -fromModuleToGlobal : Node ModuleName -> ModuleContext -> ProjectContext -fromModuleToGlobal moduleName (ModuleContext moduleContext) = +fromModuleToProject : Node ModuleName -> ModuleContext -> ProjectContext +fromModuleToProject moduleName (ModuleContext moduleContext) = ProjectContext { dependencies = moduleContext.dependencies , modules = @@ -240,8 +240,8 @@ addModuleVisitors setterGetter schema = -- -> -- { moduleVisitorSchema : Rule.ModuleRuleSchema Rule.ForLookingAtSeveralFiles { hasNoVisitor : () } moduleContext -> Rule.ModuleRuleSchema Rule.ForLookingAtSeveralFiles { hasAtLeastOneVisitor : () } moduleContext -- , initProjectContext : projectContext --- , fromGlobalToModule : Rule.FileKey -> Node ModuleName -> projectContext -> moduleContext --- , fromModuleToGlobal : Rule.FileKey -> Node ModuleName -> moduleContext -> projectContext +-- , fromProjectToModule : Rule.FileKey -> Node ModuleName -> projectContext -> moduleContext +-- , fromModuleToProject : Rule.FileKey -> Node ModuleName -> moduleContext -> projectContext -- , foldProjectContexts : projectContext -> projectContext -> projectContext -- } -- -> Rule.ProjectRuleSchema projectContext moduleContext diff --git a/tests/Scope2Test.elm b/tests/Scope2Test.elm index a04b0597..560cf2c7 100644 --- a/tests/Scope2Test.elm +++ b/tests/Scope2Test.elm @@ -141,14 +141,14 @@ rule = |> Rule.withExpressionVisitor expressionVisitor |> Rule.withFinalEvaluation finalEvaluation , initProjectContext = { scope = Scope.initProjectContext } - , fromGlobalToModule = + , fromProjectToModule = \fileKey moduleNameNode projectContext -> - { scope = Scope.fromGlobalToModule projectContext.scope + { scope = Scope.fromProjectToModule projectContext.scope , text = "" } - , fromModuleToGlobal = + , fromModuleToProject = \fileKey moduleNameNode moduleContext -> - { scope = Scope.fromModuleToGlobal moduleNameNode moduleContext.scope + { scope = Scope.fromModuleToProject moduleNameNode moduleContext.scope } , foldProjectContexts = \a b -> { scope = Scope.foldProjectContexts a.scope b.scope } }