Rename withModule to addModule and withParsedModule to addParsedModule

This commit is contained in:
Jeroen Engels 2020-01-28 23:06:45 +01:00
parent ef9374fc65
commit da24fcb57c
4 changed files with 15 additions and 15 deletions

View File

@ -65,7 +65,7 @@ g n = n + 1
"""
in
{ sourceCode = sourceCode
, project = Project.withModule (file sourceCode) Project.new
, project = Project.addModule (file sourceCode) Project.new
, reviewErrors = []
, noDebugEnabled = True
, noUnusedVariablesEnabled = True
@ -107,7 +107,7 @@ update action model =
UserEditedSourceCode sourceCode ->
{ model
| sourceCode = sourceCode
, project = Project.withModule (file sourceCode) model.project
, project = Project.addModule (file sourceCode) model.project
}
|> runReview

View File

@ -1,6 +1,6 @@
module Review.Project exposing
( Project, new
, ProjectModule, withModule, withParsedModule, removeModule, modules, filesThatFailedToParse, moduleGraph, precomputeModuleGraph
, ProjectModule, addModule, addParsedModule, removeModule, modules, filesThatFailedToParse, moduleGraph, precomputeModuleGraph
, ElmJson, withElmJson, elmJson
, withDependency, removeDependencies, dependencyModules
)
@ -23,7 +23,7 @@ in existing environments like the CLI tool.
## Adding files
@docs ProjectModule, withModule, withParsedModule, removeModule, modules, filesThatFailedToParse, moduleGraph, precomputeModuleGraph
@docs ProjectModule, addModule, addParsedModule, removeModule, modules, filesThatFailedToParse, moduleGraph, precomputeModuleGraph
# `elm.json`
@ -103,14 +103,14 @@ to parse, which you can get using [`filesThatFailedToParse`](#filesThatFailedToP
and for which a parsing error will be reported when running [`Review.review`](./Review#review).
-}
withModule : { path : String, source : String } -> Project -> Project
withModule { path, source } project =
addModule : { path : String, source : String } -> Project -> Project
addModule { path, source } project =
recomputeModuleGraphIfNeeded <|
case parseSource source of
Ok ast ->
project
|> removeFileFromProject path
|> addModule
|> addModuleToProject
{ path = path
, source = source
, ast = ast
@ -137,16 +137,16 @@ positionAsInt { row, column } =
{-| Add an already parsed module to the project. This module will then be analyzed by the rules.
-}
withParsedModule : { path : String, source : String, ast : Elm.Syntax.File.File } -> Project -> Project
withParsedModule module_ project =
addParsedModule : { path : String, source : String, ast : Elm.Syntax.File.File } -> Project -> Project
addParsedModule module_ project =
project
|> removeFileFromProject module_.path
|> addModule module_
|> addModuleToProject module_
|> recomputeModuleGraphIfNeeded
addModule : ProjectModule -> Project -> Project
addModule module_ (Project project) =
addModuleToProject : ProjectModule -> Project -> Project
addModuleToProject module_ (Project project) =
Project { project | modules = sanitizeModule module_ :: project.modules }

View File

@ -283,8 +283,8 @@ only need it if you try to make `elm-review` run in a new environment.
project : Project
project =
Project.new
|> Project.withModule { path = "src/A.elm", source = "module A exposing (a)\na = 1" }
|> Project.withModule { path = "src/B.elm", source = "module B exposing (b)\nb = 1" }
|> Project.addModule { path = "src/A.elm", source = "module A exposing (a)\na = 1" }
|> Project.addModule { path = "src/B.elm", source = "module B exposing (b)\nb = 1" }
doReview =
let

View File

@ -331,7 +331,7 @@ runOnModulesWithProjectData project rule sources =
, source = source
}
)
|> List.foldl Project.withModule project
|> List.foldl Project.addModule project
in
case Project.filesThatFailedToParse projectWithModules of
{ source } :: _ ->