mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-08-17 12:00:29 +03:00
Rename types
This commit is contained in:
parent
e9628b2cdb
commit
e51537c44a
@ -21,7 +21,7 @@ import NonEmpty exposing (NonEmpty)
|
||||
import Review.ModuleNameLookupTable.Internal as ModuleNameLookupTableInternal exposing (ModuleNameLookupTable)
|
||||
import Review.Project.Dependency
|
||||
import Review.Project.ProjectCache as ProjectCache exposing (ProjectCache)
|
||||
import Review.Project.ProjectModule as ProjectModule exposing (ProjectModule)
|
||||
import Review.Project.ProjectModule as ProjectModule exposing (OpaqueProjectModule)
|
||||
import Review.Project.Valid as ValidProject exposing (ValidProject)
|
||||
import Set exposing (Set)
|
||||
import Vendor.ListExtra as ListExtra
|
||||
@ -73,7 +73,7 @@ emptyScope =
|
||||
}
|
||||
|
||||
|
||||
compute : ModuleName -> ProjectModule -> ValidProject -> ( ModuleNameLookupTable, ValidProject )
|
||||
compute : ModuleName -> OpaqueProjectModule -> ValidProject -> ( ModuleNameLookupTable, ValidProject )
|
||||
compute moduleName module_ project =
|
||||
let
|
||||
projectCache : ProjectCache
|
||||
@ -99,7 +99,7 @@ compute moduleName module_ project =
|
||||
Nothing ->
|
||||
computeDependencies project
|
||||
|
||||
modulesByModuleName : Dict ModuleName ProjectModule
|
||||
modulesByModuleName : Dict ModuleName OpaqueProjectModule
|
||||
modulesByModuleName =
|
||||
ValidProject.modulesByModuleName project
|
||||
|
||||
@ -162,8 +162,8 @@ compute moduleName module_ project =
|
||||
|
||||
computeOnlyModuleDocs :
|
||||
ModuleName
|
||||
-> ProjectModule
|
||||
-> Dict ModuleName ProjectModule
|
||||
-> OpaqueProjectModule
|
||||
-> Dict ModuleName OpaqueProjectModule
|
||||
-> Dict ModuleName Elm.Docs.Module
|
||||
-> ProjectCache
|
||||
-> ( Elm.Docs.Module, ProjectCache )
|
||||
@ -202,7 +202,7 @@ computeOnlyModuleDocs moduleName module_ modulesByModuleName deps projectCache =
|
||||
|
||||
|
||||
computeImportedModulesDocs :
|
||||
Dict ModuleName ProjectModule
|
||||
Dict ModuleName OpaqueProjectModule
|
||||
-> Dict ModuleName Elm.Docs.Module
|
||||
-> Node Import
|
||||
-> ( Dict ModuleName Elm.Docs.Module, ProjectCache )
|
||||
|
@ -93,7 +93,7 @@ new =
|
||||
{-| Represents a parsed file.
|
||||
-}
|
||||
type alias ProjectModule =
|
||||
ProjectModule.ProjectModuleRecord
|
||||
ProjectModule.ProjectModule
|
||||
|
||||
|
||||
{-| Add an Elm file to the project. If a file with the same path already exists,
|
||||
@ -158,7 +158,7 @@ addParsedModule { path, source, ast } project =
|
||||
|> forceModuleGraphRecomputation
|
||||
|
||||
|
||||
addModuleToProject : ProjectModule.ProjectModule -> Project -> Project
|
||||
addModuleToProject : ProjectModule.OpaqueProjectModule -> Project -> Project
|
||||
addModuleToProject module_ (Internal.Project project) =
|
||||
Internal.Project { project | modules = Dict.insert (ProjectModule.path module_) module_ project.modules }
|
||||
|
||||
@ -239,7 +239,7 @@ addElmJson elmJson_ (Internal.Project project) =
|
||||
sourceDirectories =
|
||||
Internal.sourceDirectoriesForProject elmJson_.project
|
||||
|
||||
modules_ : Dict String ProjectModule.ProjectModule
|
||||
modules_ : Dict String ProjectModule.OpaqueProjectModule
|
||||
modules_ =
|
||||
if project.sourceDirectories == sourceDirectories then
|
||||
project.modules
|
||||
|
@ -15,13 +15,13 @@ import Review.Cache.ContentHash exposing (ContentHash)
|
||||
import Review.FilePath exposing (FilePath)
|
||||
import Review.Project.Dependency exposing (Dependency)
|
||||
import Review.Project.ProjectCache exposing (ProjectCache)
|
||||
import Review.Project.ProjectModule exposing (ProjectModule)
|
||||
import Review.Project.ProjectModule exposing (OpaqueProjectModule)
|
||||
import Vendor.Graph exposing (Graph)
|
||||
|
||||
|
||||
type Project
|
||||
= Project
|
||||
{ modules : Dict String ProjectModule
|
||||
{ modules : Dict String OpaqueProjectModule
|
||||
, modulesThatFailedToParse : List { path : String, source : String }
|
||||
, elmJson : Maybe ( { path : String, raw : String, project : Elm.Project.Project }, ContentHash )
|
||||
, readme : Maybe ( { path : String, content : String }, ContentHash )
|
||||
|
@ -1,18 +1,18 @@
|
||||
module Review.Project.ProjectModule exposing
|
||||
( ProjectModule, create
|
||||
( OpaqueProjectModule, create
|
||||
, path, source, ast, contentHash, isInSourceDirectories
|
||||
, setIsInSourceDirectories
|
||||
, ProjectModuleRecord, toRecord
|
||||
, ProjectModule, toRecord
|
||||
)
|
||||
|
||||
{-| Represents a parsed file.
|
||||
|
||||
@docs ProjectModule, create
|
||||
@docs OpaqueProjectModule, create
|
||||
|
||||
@docs path, source, ast, contentHash, isInSourceDirectories
|
||||
@docs setIsInSourceDirectories
|
||||
|
||||
@docs ProjectModuleRecord, toRecord
|
||||
@docs ProjectModule, toRecord
|
||||
|
||||
-}
|
||||
|
||||
@ -21,8 +21,8 @@ import Elm.Syntax.Node exposing (Node(..))
|
||||
import Review.Cache.ContentHash as ContentHash exposing (ContentHash)
|
||||
|
||||
|
||||
type ProjectModule
|
||||
= ProjectModule
|
||||
type OpaqueProjectModule
|
||||
= OpaqueProjectModule
|
||||
{ path : String
|
||||
, source : String
|
||||
, ast : Elm.Syntax.File.File
|
||||
@ -37,9 +37,9 @@ create :
|
||||
, ast : Elm.Syntax.File.File
|
||||
, isInSourceDirectories : Bool
|
||||
}
|
||||
-> ProjectModule
|
||||
-> OpaqueProjectModule
|
||||
create params =
|
||||
ProjectModule
|
||||
OpaqueProjectModule
|
||||
{ path = params.path
|
||||
, source = params.source
|
||||
, ast = sanitizeModule params.ast
|
||||
@ -61,37 +61,37 @@ positionAsInt { row, column } =
|
||||
row * 1000000 + column
|
||||
|
||||
|
||||
path : ProjectModule -> String
|
||||
path (ProjectModule module_) =
|
||||
path : OpaqueProjectModule -> String
|
||||
path (OpaqueProjectModule module_) =
|
||||
module_.path
|
||||
|
||||
|
||||
source : ProjectModule -> String
|
||||
source (ProjectModule module_) =
|
||||
source : OpaqueProjectModule -> String
|
||||
source (OpaqueProjectModule module_) =
|
||||
module_.source
|
||||
|
||||
|
||||
ast : ProjectModule -> Elm.Syntax.File.File
|
||||
ast (ProjectModule module_) =
|
||||
ast : OpaqueProjectModule -> Elm.Syntax.File.File
|
||||
ast (OpaqueProjectModule module_) =
|
||||
module_.ast
|
||||
|
||||
|
||||
contentHash : ProjectModule -> ContentHash
|
||||
contentHash (ProjectModule module_) =
|
||||
contentHash : OpaqueProjectModule -> ContentHash
|
||||
contentHash (OpaqueProjectModule module_) =
|
||||
module_.contentHash
|
||||
|
||||
|
||||
isInSourceDirectories : ProjectModule -> Bool
|
||||
isInSourceDirectories (ProjectModule module_) =
|
||||
isInSourceDirectories : OpaqueProjectModule -> Bool
|
||||
isInSourceDirectories (OpaqueProjectModule module_) =
|
||||
module_.isInSourceDirectories
|
||||
|
||||
|
||||
setIsInSourceDirectories : Bool -> ProjectModule -> ProjectModule
|
||||
setIsInSourceDirectories isInSourceDirectories_ (ProjectModule module_) =
|
||||
ProjectModule { module_ | isInSourceDirectories = isInSourceDirectories_ }
|
||||
setIsInSourceDirectories : Bool -> OpaqueProjectModule -> OpaqueProjectModule
|
||||
setIsInSourceDirectories isInSourceDirectories_ (OpaqueProjectModule module_) =
|
||||
OpaqueProjectModule { module_ | isInSourceDirectories = isInSourceDirectories_ }
|
||||
|
||||
|
||||
type alias ProjectModuleRecord =
|
||||
type alias ProjectModule =
|
||||
{ path : String
|
||||
, source : String
|
||||
, ast : Elm.Syntax.File.File
|
||||
@ -100,6 +100,6 @@ type alias ProjectModuleRecord =
|
||||
}
|
||||
|
||||
|
||||
toRecord : ProjectModule -> ProjectModuleRecord
|
||||
toRecord (ProjectModule module_) =
|
||||
toRecord : OpaqueProjectModule -> ProjectModule
|
||||
toRecord (OpaqueProjectModule module_) =
|
||||
module_
|
||||
|
@ -36,7 +36,7 @@ import Review.Project.Dependency as Dependency exposing (Dependency)
|
||||
import Review.Project.Internal exposing (Project(..))
|
||||
import Review.Project.InvalidProjectError as InvalidProjectError exposing (InvalidProjectError)
|
||||
import Review.Project.ProjectCache exposing (ProjectCache)
|
||||
import Review.Project.ProjectModule as ProjectModule exposing (ProjectModule)
|
||||
import Review.Project.ProjectModule as ProjectModule exposing (OpaqueProjectModule)
|
||||
import Set exposing (Set)
|
||||
import Vendor.Graph as Graph exposing (Graph)
|
||||
import Vendor.Zipper as Zipper exposing (Zipper)
|
||||
@ -47,8 +47,8 @@ type ValidProject
|
||||
|
||||
|
||||
type alias ValidProjectData =
|
||||
{ modulesByPath : Dict String ProjectModule
|
||||
, modulesByModuleName : Dict ModuleName ProjectModule
|
||||
{ modulesByPath : Dict String OpaqueProjectModule
|
||||
, modulesByModuleName : Dict ModuleName OpaqueProjectModule
|
||||
, elmJson : Maybe ( { path : String, raw : String, project : Elm.Project.Project }, ContentHash )
|
||||
, readme : Maybe ( { path : String, content : String }, ContentHash )
|
||||
, dependencies : Dict String Dependency
|
||||
@ -85,7 +85,7 @@ parse ((Project p) as project) =
|
||||
|
||||
else
|
||||
let
|
||||
projectModules : List ProjectModule
|
||||
projectModules : List OpaqueProjectModule
|
||||
projectModules =
|
||||
Dict.values p.modules
|
||||
in
|
||||
@ -182,7 +182,7 @@ computeDependencyModules directDependencies_ =
|
||||
directDependencies_
|
||||
|
||||
|
||||
computeModulesByModuleName : Dict a ProjectModule -> Dict ModuleName ProjectModule
|
||||
computeModulesByModuleName : Dict a OpaqueProjectModule -> Dict ModuleName OpaqueProjectModule
|
||||
computeModulesByModuleName modules =
|
||||
Dict.foldl
|
||||
(\_ module_ acc ->
|
||||
@ -192,7 +192,7 @@ computeModulesByModuleName modules =
|
||||
modules
|
||||
|
||||
|
||||
duplicateModuleNames : Dict ModuleName String -> List ProjectModule -> Maybe { moduleName : ModuleName, paths : List String }
|
||||
duplicateModuleNames : Dict ModuleName String -> List OpaqueProjectModule -> Maybe { moduleName : ModuleName, paths : List String }
|
||||
duplicateModuleNames visitedModules projectModules =
|
||||
case projectModules of
|
||||
[] ->
|
||||
@ -227,7 +227,7 @@ duplicateModuleNames visitedModules projectModules =
|
||||
}
|
||||
|
||||
|
||||
buildModuleGraph : Dict a ProjectModule -> Graph FilePath ()
|
||||
buildModuleGraph : Dict a OpaqueProjectModule -> Graph FilePath ()
|
||||
buildModuleGraph mods =
|
||||
let
|
||||
moduleIds : Dict ModuleName Int
|
||||
@ -272,7 +272,7 @@ buildModuleGraph mods =
|
||||
Graph.fromNodesAndEdges nodes edges
|
||||
|
||||
|
||||
nodesAndEdges : (ModuleName -> Maybe Int) -> ProjectModule -> Int -> ( Graph.Node FilePath, List (Graph.Edge ()) )
|
||||
nodesAndEdges : (ModuleName -> Maybe Int) -> OpaqueProjectModule -> Int -> ( Graph.Node FilePath, List (Graph.Edge ()) )
|
||||
nodesAndEdges getModuleId module_ moduleId =
|
||||
( Graph.Node moduleId (ProjectModule.path module_)
|
||||
, importedModules module_
|
||||
@ -284,13 +284,13 @@ nodesAndEdges getModuleId module_ moduleId =
|
||||
)
|
||||
|
||||
|
||||
importedModules : ProjectModule -> List ModuleName
|
||||
importedModules : OpaqueProjectModule -> List ModuleName
|
||||
importedModules module_ =
|
||||
(ProjectModule.ast module_).imports
|
||||
|> List.map (Node.value >> .moduleName >> Node.value)
|
||||
|
||||
|
||||
getModuleName : ProjectModule -> ModuleName
|
||||
getModuleName : OpaqueProjectModule -> ModuleName
|
||||
getModuleName module_ =
|
||||
(ProjectModule.ast module_).moduleDefinition
|
||||
|> Node.value
|
||||
@ -344,12 +344,12 @@ moduleGraph (ValidProject project) =
|
||||
project.moduleGraph
|
||||
|
||||
|
||||
modulesByModuleName : ValidProject -> Dict ModuleName ProjectModule
|
||||
modulesByModuleName : ValidProject -> Dict ModuleName OpaqueProjectModule
|
||||
modulesByModuleName (ValidProject project) =
|
||||
project.modulesByModuleName
|
||||
|
||||
|
||||
getModuleByPath : String -> ValidProject -> Maybe ProjectModule
|
||||
getModuleByPath : String -> ValidProject -> Maybe OpaqueProjectModule
|
||||
getModuleByPath path (ValidProject project) =
|
||||
Dict.get path project.modulesByPath
|
||||
|
||||
@ -389,7 +389,7 @@ addParsedModule { path, source, ast } maybeModuleZipper (ValidProject project) =
|
||||
osAgnosticPath =
|
||||
Path.makeOSAgnostic path
|
||||
|
||||
module_ : ProjectModule
|
||||
module_ : OpaqueProjectModule
|
||||
module_ =
|
||||
ProjectModule.create
|
||||
{ path = path
|
||||
|
@ -326,7 +326,7 @@ import Review.Options.Internal as InternalOptions exposing (ReviewOptionsData, R
|
||||
import Review.Project.Dependency
|
||||
import Review.Project.Internal exposing (Project)
|
||||
import Review.Project.InvalidProjectError as InvalidProjectError
|
||||
import Review.Project.ProjectModule as ProjectModule exposing (ProjectModule)
|
||||
import Review.Project.ProjectModule as ProjectModule exposing (OpaqueProjectModule)
|
||||
import Review.Project.Valid as ValidProject exposing (ValidProject)
|
||||
import Review.RequestedData as RequestedData exposing (RequestedData(..))
|
||||
import Vendor.Graph as Graph exposing (Graph)
|
||||
@ -2061,7 +2061,7 @@ withContextFromImportedModules (ProjectRuleSchema schema) =
|
||||
ProjectRuleSchema { schema | traversalType = ImportedModulesFirst }
|
||||
|
||||
|
||||
setFilePathIfUnset : ProjectModule -> Error scope -> Error scope
|
||||
setFilePathIfUnset : OpaqueProjectModule -> Error scope -> Error scope
|
||||
setFilePathIfUnset module_ ((Error err) as rawError) =
|
||||
if err.filePath == "" then
|
||||
Error { err | filePath = ProjectModule.path module_ }
|
||||
@ -4825,7 +4825,7 @@ type alias DataToComputeModules projectContext moduleContext =
|
||||
|
||||
type alias DataToComputeSingleModule projectContext moduleContext =
|
||||
{ dataToComputeModules : DataToComputeModules projectContext moduleContext
|
||||
, module_ : ProjectModule
|
||||
, module_ : OpaqueProjectModule
|
||||
, isFileIgnored : Bool
|
||||
, projectContext : projectContext
|
||||
, project : ValidProject
|
||||
@ -5391,7 +5391,7 @@ isFixable predicate err =
|
||||
Nothing
|
||||
|
||||
|
||||
visitModuleForProjectRule : RunnableModuleVisitor moduleContext -> moduleContext -> ProjectModule -> ( List (Error {}), moduleContext )
|
||||
visitModuleForProjectRule : RunnableModuleVisitor moduleContext -> moduleContext -> OpaqueProjectModule -> ( List (Error {}), moduleContext )
|
||||
visitModuleForProjectRule schema initialContext module_ =
|
||||
let
|
||||
ast : File
|
||||
|
Loading…
Reference in New Issue
Block a user