mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-08-17 12:00:29 +03:00
Fix type problems
This commit is contained in:
parent
f4ef7c2a3a
commit
e9628b2cdb
@ -93,7 +93,7 @@ new =
|
||||
{-| Represents a parsed file.
|
||||
-}
|
||||
type alias ProjectModule =
|
||||
ProjectModule.ProjectModule
|
||||
ProjectModule.ProjectModuleRecord
|
||||
|
||||
|
||||
{-| 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 -> Project -> Project
|
||||
addModuleToProject : ProjectModule.ProjectModule -> Project -> Project
|
||||
addModuleToProject module_ (Internal.Project project) =
|
||||
Internal.Project { project | modules = Dict.insert (ProjectModule.path module_) module_ project.modules }
|
||||
|
||||
@ -199,6 +199,7 @@ removeFileFromFilesThatFailedToParse path (Internal.Project project) =
|
||||
modules : Project -> List ProjectModule
|
||||
modules (Internal.Project project) =
|
||||
Dict.values project.modules
|
||||
|> List.map ProjectModule.toRecord
|
||||
|
||||
|
||||
{-| Get the list of file paths that failed to parse, because they were syntactically invalid Elm code.
|
||||
|
@ -2,6 +2,7 @@ module Review.Project.ProjectModule exposing
|
||||
( ProjectModule, create
|
||||
, path, source, ast, contentHash, isInSourceDirectories
|
||||
, setIsInSourceDirectories
|
||||
, ProjectModuleRecord, toRecord
|
||||
)
|
||||
|
||||
{-| Represents a parsed file.
|
||||
@ -11,6 +12,8 @@ module Review.Project.ProjectModule exposing
|
||||
@docs path, source, ast, contentHash, isInSourceDirectories
|
||||
@docs setIsInSourceDirectories
|
||||
|
||||
@docs ProjectModuleRecord, toRecord
|
||||
|
||||
-}
|
||||
|
||||
import Elm.Syntax.File
|
||||
@ -86,3 +89,17 @@ isInSourceDirectories (ProjectModule module_) =
|
||||
setIsInSourceDirectories : Bool -> ProjectModule -> ProjectModule
|
||||
setIsInSourceDirectories isInSourceDirectories_ (ProjectModule module_) =
|
||||
ProjectModule { module_ | isInSourceDirectories = isInSourceDirectories_ }
|
||||
|
||||
|
||||
type alias ProjectModuleRecord =
|
||||
{ path : String
|
||||
, source : String
|
||||
, ast : Elm.Syntax.File.File
|
||||
, contentHash : ContentHash
|
||||
, isInSourceDirectories : Bool
|
||||
}
|
||||
|
||||
|
||||
toRecord : ProjectModule -> ProjectModuleRecord
|
||||
toRecord (ProjectModule module_) =
|
||||
module_
|
||||
|
@ -323,11 +323,10 @@ import Review.ModuleNameLookupTable.Compute
|
||||
import Review.ModuleNameLookupTable.Internal as ModuleNameLookupTableInternal
|
||||
import Review.Options as ReviewOptions exposing (ReviewOptions)
|
||||
import Review.Options.Internal as InternalOptions exposing (ReviewOptionsData, ReviewOptionsInternal(..))
|
||||
import Review.Project exposing (ProjectModule)
|
||||
import Review.Project.Dependency
|
||||
import Review.Project.Internal exposing (Project)
|
||||
import Review.Project.InvalidProjectError as InvalidProjectError
|
||||
import Review.Project.ProjectModule as ProjectModule
|
||||
import Review.Project.ProjectModule as ProjectModule exposing (ProjectModule)
|
||||
import Review.Project.Valid as ValidProject exposing (ValidProject)
|
||||
import Review.RequestedData as RequestedData exposing (RequestedData(..))
|
||||
import Vendor.Graph as Graph exposing (Graph)
|
||||
|
@ -137,7 +137,6 @@ import Review.FileParser as FileParser
|
||||
import Review.Fix as Fix
|
||||
import Review.Options as ReviewOptions
|
||||
import Review.Project as Project exposing (Project, ProjectModule)
|
||||
import Review.Project.ProjectModule as ProjectModule
|
||||
import Review.Rule as Rule exposing (ReviewError, Rule)
|
||||
import Review.Test.Dependencies exposing (projectWithElmCore)
|
||||
import Review.Test.FailureMessage as FailureMessage
|
||||
@ -495,14 +494,14 @@ hasOneElement list =
|
||||
moduleToRunResult : List ReviewError -> ProjectModule -> SuccessfulRunResult
|
||||
moduleToRunResult errors projectModule =
|
||||
{ moduleName =
|
||||
(ProjectModule.ast projectModule).moduleDefinition
|
||||
projectModule.ast.moduleDefinition
|
||||
|> Node.value
|
||||
|> Module.moduleName
|
||||
|> String.join "."
|
||||
, inspector = codeInspectorForSource True (ProjectModule.source projectModule)
|
||||
, inspector = codeInspectorForSource True projectModule.source
|
||||
, errors =
|
||||
errors
|
||||
|> List.filter (\error_ -> Rule.errorFilePath error_ == ProjectModule.path projectModule)
|
||||
|> List.filter (\error_ -> Rule.errorFilePath error_ == projectModule.path)
|
||||
|> List.sortWith compareErrorPositions
|
||||
}
|
||||
|
||||
@ -583,7 +582,7 @@ findDuplicateModuleNames previousModuleNames modules =
|
||||
let
|
||||
moduleName : List String
|
||||
moduleName =
|
||||
(ProjectModule.ast module_).moduleDefinition
|
||||
module_.ast.moduleDefinition
|
||||
|> Node.value
|
||||
|> Module.moduleName
|
||||
in
|
||||
@ -888,7 +887,7 @@ doCheckResultsAreTheSameWhenIgnoringFiles allErrors rule project =
|
||||
filePaths : List String
|
||||
filePaths =
|
||||
Project.modules project
|
||||
|> List.map ProjectModule.path
|
||||
|> List.map .path
|
||||
|> maybeCons .path (Project.elmJson project)
|
||||
|> maybeCons .path (Project.readme project)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user