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