Rename fromModuleToGlobal -> fromModuleToProject and fromGlobalToModule -> fromProjectToModule

This commit is contained in:
Jeroen Engels 2020-01-26 13:19:46 +01:00
parent fc65a5de9f
commit 35c6e53664
5 changed files with 39 additions and 39 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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 }
}