mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-23 09:42:49 +03:00
Stop using Rule.withMetadata in plugin rules
This commit is contained in:
parent
0fa1005f4d
commit
dddba5c1cf
@ -192,12 +192,7 @@ type alias MaybeExposedLinkData =
|
||||
fromProjectToModule : Rule.ContextCreator ProjectContext ModuleContext
|
||||
fromProjectToModule =
|
||||
Rule.initContextCreator
|
||||
(\metadata projectContext ->
|
||||
let
|
||||
moduleName : ModuleName
|
||||
moduleName =
|
||||
Rule.moduleNameFromMetadata metadata
|
||||
in
|
||||
(\moduleName projectContext ->
|
||||
{ isModuleExposed = Set.member moduleName projectContext.exposedModules
|
||||
, exposedElements = Set.empty
|
||||
, moduleName = moduleName
|
||||
@ -206,7 +201,7 @@ fromProjectToModule =
|
||||
, links = []
|
||||
}
|
||||
)
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
fromModuleToProject : Rule.ContextCreator ModuleContext ProjectContext
|
||||
|
@ -158,12 +158,7 @@ type DeprecationReason
|
||||
fromProjectToModule : StableConfiguration -> Rule.ContextCreator ProjectContext ModuleContext
|
||||
fromProjectToModule (StableConfiguration configuration) =
|
||||
Rule.initContextCreator
|
||||
(\metadata lookupTable projectContext ->
|
||||
let
|
||||
moduleName : ModuleName
|
||||
moduleName =
|
||||
Rule.moduleNameFromMetadata metadata
|
||||
in
|
||||
(\moduleName lookupTable projectContext ->
|
||||
{ lookupTable = lookupTable
|
||||
, currentModuleName = moduleName
|
||||
, deprecatedModules = Dict.fromList projectContext.deprecatedModules
|
||||
@ -172,24 +167,24 @@ fromProjectToModule (StableConfiguration configuration) =
|
||||
, localDeprecatedElements = []
|
||||
}
|
||||
)
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withModuleName
|
||||
|> Rule.withModuleNameLookupTable
|
||||
|
||||
|
||||
fromModuleToProject : Rule.ContextCreator ModuleContext ProjectContext
|
||||
fromModuleToProject =
|
||||
Rule.initContextCreator
|
||||
(\metadata moduleContext ->
|
||||
(\moduleName moduleContext ->
|
||||
{ deprecatedModules =
|
||||
if moduleContext.isModuleDeprecated then
|
||||
[ ( Rule.moduleNameFromMetadata metadata, DeprecatedModule ) ]
|
||||
[ ( moduleName, DeprecatedModule ) ]
|
||||
|
||||
else
|
||||
[]
|
||||
, deprecatedElements = moduleContext.localDeprecatedElements
|
||||
}
|
||||
)
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
foldProjectContexts : ProjectContext -> ProjectContext -> ProjectContext
|
||||
|
@ -122,16 +122,16 @@ fromProjectToModule =
|
||||
fromModuleToProject : Rule.ContextCreator ModuleContext ProjectContext
|
||||
fromModuleToProject =
|
||||
Rule.initContextCreator
|
||||
(\metadata moduleContext ->
|
||||
(\moduleName moduleContext ->
|
||||
{ modulesThatExposeSubscriptionsAndUpdate =
|
||||
if moduleContext.definesSubscriptions && moduleContext.definesUpdate then
|
||||
Set.singleton (Rule.moduleNameFromMetadata metadata)
|
||||
Set.singleton moduleName
|
||||
|
||||
else
|
||||
Set.empty
|
||||
}
|
||||
)
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
foldProjectContexts : ProjectContext -> ProjectContext -> ProjectContext
|
||||
|
@ -610,11 +610,11 @@ formatTypeName ( moduleName, name ) =
|
||||
fromProjectToModuleContext : Rule.ContextCreator ProjectContext ModuleContext
|
||||
fromProjectToModuleContext =
|
||||
Rule.initContextCreator
|
||||
(\lookupTable metadata { exposedModules, moduleTypes } ->
|
||||
(\lookupTable moduleName { exposedModules, moduleTypes } ->
|
||||
let
|
||||
moduleType : ModuleType
|
||||
moduleType =
|
||||
if isModuleExposed exposedModules (Rule.moduleNameFromMetadata metadata) then
|
||||
if isModuleExposed exposedModules moduleName then
|
||||
initialExposedModuleType exposedModules moduleTypes
|
||||
|
||||
else
|
||||
@ -626,21 +626,21 @@ fromProjectToModuleContext =
|
||||
}
|
||||
)
|
||||
|> Rule.withModuleNameLookupTable
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
fromModuleToProjectContext : Rule.ContextCreator ModuleContext ProjectContext
|
||||
fromModuleToProjectContext =
|
||||
Rule.initContextCreator
|
||||
(\metadata context ->
|
||||
(\moduleName context ->
|
||||
case context.moduleType of
|
||||
InternalModule { exposedTypes } ->
|
||||
{ initialProjectContext | moduleTypes = Dict.singleton (Rule.moduleNameFromMetadata metadata) exposedTypes }
|
||||
{ initialProjectContext | moduleTypes = Dict.singleton moduleName exposedTypes }
|
||||
|
||||
ExposedModule _ ->
|
||||
initialProjectContext
|
||||
)
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
foldProjectContexts : ProjectContext -> ProjectContext -> ProjectContext
|
||||
|
@ -130,12 +130,12 @@ type alias Context =
|
||||
initialContext : Rule.ContextCreator () Context
|
||||
initialContext =
|
||||
Rule.initContextCreator
|
||||
(\metadata () ->
|
||||
(\isInSourceDirectories () ->
|
||||
{ inDeclarationOfNonTestValue = False
|
||||
, isInSourceDirectories = Rule.isInSourceDirectories metadata
|
||||
, isInSourceDirectories = isInSourceDirectories
|
||||
}
|
||||
)
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withIsInSourceDirectories
|
||||
|
||||
|
||||
|
||||
|
@ -195,11 +195,11 @@ fromProjectToModule =
|
||||
fromModuleToProject : Target -> Rule.ContextCreator ModuleContext ProjectContext
|
||||
fromModuleToProject target =
|
||||
Rule.initContextCreator
|
||||
(\metadata moduleContext ->
|
||||
{ foundTargetFunction = moduleContext.foundTargetFunction && (Rule.moduleNameFromMetadata metadata == target.moduleName)
|
||||
(\moduleName moduleContext ->
|
||||
{ foundTargetFunction = moduleContext.foundTargetFunction && (moduleName == target.moduleName)
|
||||
}
|
||||
)
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
foldProjectContexts : ProjectContext -> ProjectContext -> ProjectContext
|
||||
|
@ -159,9 +159,9 @@ initialProjectContext =
|
||||
fromProjectToModule : Rule.ContextCreator ProjectContext ModuleContext
|
||||
fromProjectToModule =
|
||||
Rule.initContextCreator
|
||||
(\lookupTable metadata projectContext ->
|
||||
(\lookupTable moduleName projectContext ->
|
||||
{ lookupTable = lookupTable
|
||||
, isModuleExposed = Set.member (Rule.moduleNameFromMetadata metadata) projectContext.exposedModules
|
||||
, isModuleExposed = Set.member moduleName projectContext.exposedModules
|
||||
, exposed = Exposing.Explicit []
|
||||
, customTypeArgs = []
|
||||
, usedArguments = Dict.empty
|
||||
@ -169,26 +169,26 @@ fromProjectToModule =
|
||||
}
|
||||
)
|
||||
|> Rule.withModuleNameLookupTable
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
fromModuleToProject : Rule.ContextCreator ModuleContext ProjectContext
|
||||
fromModuleToProject =
|
||||
Rule.initContextCreator
|
||||
(\moduleKey metadata moduleContext ->
|
||||
(\moduleKey moduleName moduleContext ->
|
||||
{ exposedModules = Set.empty
|
||||
, customTypeArgs =
|
||||
Dict.singleton
|
||||
(Rule.moduleNameFromMetadata metadata)
|
||||
moduleName
|
||||
{ moduleKey = moduleKey
|
||||
, args = getNonExposedCustomTypes moduleContext
|
||||
}
|
||||
, usedArguments = replaceLocalModuleNameForDict (Rule.moduleNameFromMetadata metadata) moduleContext.usedArguments
|
||||
, customTypesNotToReport = replaceLocalModuleNameForSet (Rule.moduleNameFromMetadata metadata) moduleContext.customTypesNotToReport
|
||||
, usedArguments = replaceLocalModuleNameForDict moduleName moduleContext.usedArguments
|
||||
, customTypesNotToReport = replaceLocalModuleNameForSet moduleName moduleContext.customTypesNotToReport
|
||||
}
|
||||
)
|
||||
|> Rule.withModuleKey
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
replaceLocalModuleNameForSet : ModuleName -> Set ( ModuleName, comparable ) -> Set ( ModuleName, comparable )
|
||||
|
@ -126,8 +126,8 @@ rule phantomTypes =
|
||||
|> Rule.withContextFromImportedModules
|
||||
|> Rule.withModuleVisitor moduleVisitor
|
||||
|> Rule.withModuleContextUsingContextCreator
|
||||
{ fromProjectToModule = Rule.initContextCreator fromProjectToModule |> Rule.withModuleNameLookupTable |> Rule.withMetadata
|
||||
, fromModuleToProject = Rule.initContextCreator fromModuleToProject |> Rule.withModuleKey |> Rule.withMetadata
|
||||
{ fromProjectToModule = fromProjectToModule
|
||||
, fromModuleToProject = fromModuleToProject
|
||||
, foldProjectContexts = foldProjectContexts
|
||||
}
|
||||
|> Rule.withElmJsonProjectVisitor elmJsonVisitor
|
||||
@ -229,115 +229,121 @@ initialProjectContext phantomTypes =
|
||||
}
|
||||
|
||||
|
||||
fromProjectToModule : ModuleNameLookupTable -> Rule.Metadata -> ProjectContext -> ModuleContext
|
||||
fromProjectToModule lookupTable metadata projectContext =
|
||||
{ lookupTable = lookupTable
|
||||
, exposedCustomTypesWithConstructors = Set.empty
|
||||
, isExposed = Set.member (Rule.moduleNameFromMetadata metadata |> String.join ".") projectContext.exposedModules
|
||||
, exposedConstructors = projectContext.declaredConstructors
|
||||
, exposesEverything = False
|
||||
, declaredTypesWithConstructors = Dict.empty
|
||||
, usedFunctionsOrValues = Dict.empty
|
||||
, phantomVariables = projectContext.phantomVariables
|
||||
, constructorsToIgnore = []
|
||||
, wasUsedInLocationThatNeedsItself = Set.empty
|
||||
, wasUsedInComparisons = Set.empty
|
||||
, wasUsedInOtherModules = Set.empty
|
||||
, fixesForRemovingConstructor = Dict.empty
|
||||
, ignoredComparisonRanges = []
|
||||
}
|
||||
fromProjectToModule : Rule.ContextCreator ProjectContext ModuleContext
|
||||
fromProjectToModule =
|
||||
Rule.initContextCreator
|
||||
(\lookupTable moduleName projectContext ->
|
||||
{ lookupTable = lookupTable
|
||||
, exposedCustomTypesWithConstructors = Set.empty
|
||||
, isExposed = Set.member (String.join "." moduleName) projectContext.exposedModules
|
||||
, exposedConstructors = projectContext.declaredConstructors
|
||||
, exposesEverything = False
|
||||
, declaredTypesWithConstructors = Dict.empty
|
||||
, usedFunctionsOrValues = Dict.empty
|
||||
, phantomVariables = projectContext.phantomVariables
|
||||
, constructorsToIgnore = []
|
||||
, wasUsedInLocationThatNeedsItself = Set.empty
|
||||
, wasUsedInComparisons = Set.empty
|
||||
, wasUsedInOtherModules = Set.empty
|
||||
, fixesForRemovingConstructor = Dict.empty
|
||||
, ignoredComparisonRanges = []
|
||||
}
|
||||
)
|
||||
|> Rule.withModuleNameLookupTable
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
fromModuleToProject : Rule.ModuleKey -> Rule.Metadata -> ModuleContext -> ProjectContext
|
||||
fromModuleToProject moduleKey metadata moduleContext =
|
||||
let
|
||||
localUsed : Set ConstructorName
|
||||
localUsed =
|
||||
moduleContext.usedFunctionsOrValues
|
||||
|> Dict.get ""
|
||||
|> Maybe.withDefault Set.empty
|
||||
fromModuleToProject : Rule.ContextCreator ModuleContext ProjectContext
|
||||
fromModuleToProject =
|
||||
Rule.initContextCreator
|
||||
(\moduleKey moduleName moduleContext ->
|
||||
let
|
||||
localUsed : Set ConstructorName
|
||||
localUsed =
|
||||
moduleContext.usedFunctionsOrValues
|
||||
|> Dict.get ""
|
||||
|> Maybe.withDefault Set.empty
|
||||
|
||||
localPhantomTypes : List ( CustomTypeName, Int )
|
||||
localPhantomTypes =
|
||||
moduleContext.phantomVariables
|
||||
|> Dict.get []
|
||||
|> Maybe.withDefault []
|
||||
localPhantomTypes : List ( CustomTypeName, Int )
|
||||
localPhantomTypes =
|
||||
moduleContext.phantomVariables
|
||||
|> Dict.get []
|
||||
|> Maybe.withDefault []
|
||||
|
||||
moduleName : ModuleName
|
||||
moduleName =
|
||||
Rule.moduleNameFromMetadata metadata
|
||||
moduleNameAsString : ModuleNameAsString
|
||||
moduleNameAsString =
|
||||
String.join "." moduleName
|
||||
in
|
||||
{ exposedModules = Set.empty
|
||||
, declaredConstructors =
|
||||
if moduleContext.isExposed then
|
||||
if moduleContext.exposesEverything then
|
||||
Dict.empty
|
||||
|
||||
moduleNameAsString : ModuleNameAsString
|
||||
moduleNameAsString =
|
||||
String.join "." moduleName
|
||||
in
|
||||
{ exposedModules = Set.empty
|
||||
, declaredConstructors =
|
||||
if moduleContext.isExposed then
|
||||
if moduleContext.exposesEverything then
|
||||
Dict.empty
|
||||
else
|
||||
Dict.singleton
|
||||
moduleNameAsString
|
||||
(ExposedConstructors
|
||||
{ moduleKey = moduleKey
|
||||
, customTypes =
|
||||
moduleContext.declaredTypesWithConstructors
|
||||
|> Dict.filter (\typeName _ -> not <| Set.member typeName moduleContext.exposedCustomTypesWithConstructors)
|
||||
}
|
||||
)
|
||||
|
||||
else
|
||||
Dict.singleton
|
||||
moduleNameAsString
|
||||
(ExposedConstructors
|
||||
{ moduleKey = moduleKey
|
||||
, customTypes =
|
||||
moduleContext.declaredTypesWithConstructors
|
||||
|> Dict.filter (\typeName _ -> not <| Set.member typeName moduleContext.exposedCustomTypesWithConstructors)
|
||||
}
|
||||
else
|
||||
Dict.singleton
|
||||
moduleNameAsString
|
||||
(ExposedConstructors
|
||||
{ moduleKey = moduleKey
|
||||
, customTypes = moduleContext.declaredTypesWithConstructors
|
||||
}
|
||||
)
|
||||
, usedConstructors =
|
||||
moduleContext.usedFunctionsOrValues
|
||||
|> Dict.remove ""
|
||||
|> Dict.insert moduleNameAsString localUsed
|
||||
, phantomVariables = Dict.singleton moduleName localPhantomTypes
|
||||
, wasUsedInLocationThatNeedsItself =
|
||||
Set.map
|
||||
(\(( moduleName_, constructorName ) as untouched) ->
|
||||
if moduleName_ == "" then
|
||||
( moduleNameAsString, constructorName )
|
||||
|
||||
else
|
||||
untouched
|
||||
)
|
||||
moduleContext.wasUsedInLocationThatNeedsItself
|
||||
, wasUsedInComparisons =
|
||||
Set.map
|
||||
(\(( moduleName_, constructorName ) as untouched) ->
|
||||
if moduleName_ == "" then
|
||||
( moduleNameAsString, constructorName )
|
||||
|
||||
else
|
||||
Dict.singleton
|
||||
moduleNameAsString
|
||||
(ExposedConstructors
|
||||
{ moduleKey = moduleKey
|
||||
, customTypes = moduleContext.declaredTypesWithConstructors
|
||||
}
|
||||
)
|
||||
, usedConstructors =
|
||||
moduleContext.usedFunctionsOrValues
|
||||
|> Dict.remove ""
|
||||
|> Dict.insert moduleNameAsString localUsed
|
||||
, phantomVariables = Dict.singleton moduleName localPhantomTypes
|
||||
, wasUsedInLocationThatNeedsItself =
|
||||
Set.map
|
||||
(\(( moduleName_, constructorName ) as untouched) ->
|
||||
if moduleName_ == "" then
|
||||
( moduleNameAsString, constructorName )
|
||||
|
||||
else
|
||||
untouched
|
||||
)
|
||||
moduleContext.wasUsedInLocationThatNeedsItself
|
||||
, wasUsedInComparisons =
|
||||
Set.map
|
||||
(\(( moduleName_, constructorName ) as untouched) ->
|
||||
if moduleName_ == "" then
|
||||
( moduleNameAsString, constructorName )
|
||||
|
||||
else
|
||||
untouched
|
||||
)
|
||||
moduleContext.wasUsedInComparisons
|
||||
, wasUsedInOtherModules =
|
||||
List.foldl
|
||||
(\( moduleName_, constructors ) acc ->
|
||||
Set.union
|
||||
(Set.map (Tuple.pair moduleName_) constructors)
|
||||
acc
|
||||
)
|
||||
moduleContext.wasUsedInOtherModules
|
||||
-- TODO add test to make sure we don't fix something that is pattern matched in other modules
|
||||
(Dict.toList <| Dict.remove "" moduleContext.usedFunctionsOrValues)
|
||||
, fixesForRemovingConstructor =
|
||||
mapDictKeys
|
||||
(\constructorName ->
|
||||
( moduleNameAsString, constructorName )
|
||||
)
|
||||
moduleContext.fixesForRemovingConstructor
|
||||
}
|
||||
else
|
||||
untouched
|
||||
)
|
||||
moduleContext.wasUsedInComparisons
|
||||
, wasUsedInOtherModules =
|
||||
List.foldl
|
||||
(\( moduleName_, constructors ) acc ->
|
||||
Set.union
|
||||
(Set.map (Tuple.pair moduleName_) constructors)
|
||||
acc
|
||||
)
|
||||
moduleContext.wasUsedInOtherModules
|
||||
-- TODO add test to make sure we don't fix something that is pattern matched in other modules
|
||||
(Dict.toList <| Dict.remove "" moduleContext.usedFunctionsOrValues)
|
||||
, fixesForRemovingConstructor =
|
||||
mapDictKeys
|
||||
(\constructorName ->
|
||||
( moduleNameAsString, constructorName )
|
||||
)
|
||||
moduleContext.fixesForRemovingConstructor
|
||||
}
|
||||
)
|
||||
|> Rule.withModuleKey
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
foldProjectContexts : ProjectContext -> ProjectContext -> ProjectContext
|
||||
|
@ -133,24 +133,19 @@ fromProjectToModule =
|
||||
fromModuleToProject : Rule.ContextCreator ModuleContext ProjectContext
|
||||
fromModuleToProject =
|
||||
Rule.initContextCreator
|
||||
(\metadata { usedDependencies } ->
|
||||
let
|
||||
isSourceDir : Bool
|
||||
isSourceDir =
|
||||
Rule.isInSourceDirectories metadata
|
||||
in
|
||||
(\isInSourceDirectories { usedDependencies } ->
|
||||
{ moduleNameToDependency = Dict.empty
|
||||
, dependencies = Dict.empty
|
||||
, directProjectDependencies = Set.empty
|
||||
, directTestDependencies = Set.empty
|
||||
, usedDependencies =
|
||||
if isSourceDir then
|
||||
if isInSourceDirectories then
|
||||
usedDependencies
|
||||
|
||||
else
|
||||
Set.empty
|
||||
, usedDependenciesFromTest =
|
||||
if isSourceDir then
|
||||
if isInSourceDirectories then
|
||||
Set.empty
|
||||
|
||||
else
|
||||
@ -158,7 +153,7 @@ fromModuleToProject =
|
||||
, elmJsonKey = Nothing
|
||||
}
|
||||
)
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withIsInSourceDirectories
|
||||
|
||||
|
||||
foldProjectContexts : ProjectContext -> ProjectContext -> ProjectContext
|
||||
|
@ -57,8 +57,8 @@ rule =
|
||||
Rule.newProjectRuleSchema "NoUnused.Exports" initialProjectContext
|
||||
|> Rule.withModuleVisitor moduleVisitor
|
||||
|> Rule.withModuleContextUsingContextCreator
|
||||
{ fromProjectToModule = Rule.initContextCreator fromProjectToModule |> Rule.withModuleNameLookupTable
|
||||
, fromModuleToProject = Rule.initContextCreator fromModuleToProject |> Rule.withModuleKey |> Rule.withMetadata
|
||||
{ fromProjectToModule = fromProjectToModule
|
||||
, fromModuleToProject = fromModuleToProject
|
||||
, foldProjectContexts = foldProjectContexts
|
||||
}
|
||||
|> Rule.withContextFromImportedModules
|
||||
@ -136,51 +136,55 @@ initialProjectContext =
|
||||
}
|
||||
|
||||
|
||||
fromProjectToModule : ModuleNameLookupTable -> ProjectContext -> ModuleContext
|
||||
fromProjectToModule lookupTable _ =
|
||||
{ lookupTable = lookupTable
|
||||
, exposesEverything = False
|
||||
, exposed = Dict.empty
|
||||
, rawExposed = []
|
||||
, used = Set.empty
|
||||
, elementsNotToReport = Set.empty
|
||||
}
|
||||
|
||||
|
||||
fromModuleToProject : Rule.ModuleKey -> Rule.Metadata -> ModuleContext -> ProjectContext
|
||||
fromModuleToProject moduleKey metadata moduleContext =
|
||||
let
|
||||
moduleName : ModuleName
|
||||
moduleName =
|
||||
Rule.moduleNameFromMetadata metadata
|
||||
in
|
||||
{ projectType = IsApplication ElmApplication
|
||||
, modules =
|
||||
Dict.singleton
|
||||
moduleName
|
||||
{ moduleKey = moduleKey
|
||||
, exposed = moduleContext.exposed
|
||||
fromProjectToModule : Rule.ContextCreator ProjectContext ModuleContext
|
||||
fromProjectToModule =
|
||||
Rule.initContextCreator
|
||||
(\lookupTable _ ->
|
||||
{ lookupTable = lookupTable
|
||||
, exposesEverything = False
|
||||
, exposed = Dict.empty
|
||||
, rawExposed = []
|
||||
, used = Set.empty
|
||||
, elementsNotToReport = Set.empty
|
||||
}
|
||||
, used =
|
||||
moduleContext.elementsNotToReport
|
||||
|> Set.map (Tuple.pair moduleName)
|
||||
|> Set.union moduleContext.used
|
||||
, constructors =
|
||||
Dict.foldl
|
||||
(\name element acc ->
|
||||
case element.elementType of
|
||||
ExposedType constructorNames ->
|
||||
List.foldl
|
||||
(\constructorName listAcc -> Dict.insert ( moduleName, constructorName ) name listAcc)
|
||||
acc
|
||||
constructorNames
|
||||
)
|
||||
|> Rule.withModuleNameLookupTable
|
||||
|
||||
_ ->
|
||||
acc
|
||||
)
|
||||
Dict.empty
|
||||
moduleContext.exposed
|
||||
}
|
||||
|
||||
fromModuleToProject : Rule.ContextCreator ModuleContext ProjectContext
|
||||
fromModuleToProject =
|
||||
Rule.initContextCreator
|
||||
(\moduleKey moduleName moduleContext ->
|
||||
{ projectType = IsApplication ElmApplication
|
||||
, modules =
|
||||
Dict.singleton
|
||||
moduleName
|
||||
{ moduleKey = moduleKey
|
||||
, exposed = moduleContext.exposed
|
||||
}
|
||||
, used =
|
||||
moduleContext.elementsNotToReport
|
||||
|> Set.map (Tuple.pair moduleName)
|
||||
|> Set.union moduleContext.used
|
||||
, constructors =
|
||||
Dict.foldl
|
||||
(\name element acc ->
|
||||
case element.elementType of
|
||||
ExposedType constructorNames ->
|
||||
List.foldl
|
||||
(\constructorName listAcc -> Dict.insert ( moduleName, constructorName ) name listAcc)
|
||||
acc
|
||||
constructorNames
|
||||
|
||||
_ ->
|
||||
acc
|
||||
)
|
||||
Dict.empty
|
||||
moduleContext.exposed
|
||||
}
|
||||
)
|
||||
|> Rule.withModuleKey
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
foldProjectContexts : ProjectContext -> ProjectContext -> ProjectContext
|
||||
|
@ -252,17 +252,17 @@ fromProjectToModule =
|
||||
fromModuleToProject : Rule.ContextCreator ModuleContext ProjectContext
|
||||
fromModuleToProject =
|
||||
Rule.initContextCreator
|
||||
(\metadata moduleContext ->
|
||||
(\moduleName moduleContext ->
|
||||
{ customTypes =
|
||||
moduleContext.localTypes
|
||||
|> Dict.map (\_ customType -> customType.variants)
|
||||
|> Dict.singleton (Rule.moduleNameFromMetadata metadata)
|
||||
|> Dict.singleton moduleName
|
||||
|
||||
-- Will be ignored in foldProjectContexts
|
||||
, isApplication = True
|
||||
}
|
||||
)
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
foldProjectContexts : ProjectContext -> ProjectContext -> ProjectContext
|
||||
|
@ -770,9 +770,9 @@ fromModuleToProject =
|
||||
initialModuleContext : Rule.ContextCreator () ModuleContext
|
||||
initialModuleContext =
|
||||
Rule.initContextCreator
|
||||
(\lookupTable metadata () ->
|
||||
(\lookupTable moduleName () ->
|
||||
{ lookupTable = lookupTable
|
||||
, moduleName = Rule.moduleNameFromMetadata metadata
|
||||
, moduleName = moduleName
|
||||
, rangesToIgnore = []
|
||||
, rightSidesOfPlusPlus = []
|
||||
, localIgnoredCustomTypes = []
|
||||
@ -781,15 +781,15 @@ initialModuleContext =
|
||||
}
|
||||
)
|
||||
|> Rule.withModuleNameLookupTable
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
fromProjectToModule : Rule.ContextCreator ProjectContext ModuleContext
|
||||
fromProjectToModule =
|
||||
Rule.initContextCreator
|
||||
(\lookupTable metadata projectContext ->
|
||||
(\lookupTable moduleName projectContext ->
|
||||
{ lookupTable = lookupTable
|
||||
, moduleName = Rule.moduleNameFromMetadata metadata
|
||||
, moduleName = moduleName
|
||||
, rangesToIgnore = []
|
||||
, rightSidesOfPlusPlus = []
|
||||
, localIgnoredCustomTypes = []
|
||||
@ -798,7 +798,7 @@ fromProjectToModule =
|
||||
}
|
||||
)
|
||||
|> Rule.withModuleNameLookupTable
|
||||
|> Rule.withMetadata
|
||||
|> Rule.withModuleName
|
||||
|
||||
|
||||
buildConstructorsToIgnore : List Constructor -> Set ( ModuleName, String )
|
||||
|
Loading…
Reference in New Issue
Block a user