mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-11-22 22:33:13 +03:00
Move Project.Dependency to its own module
This commit is contained in:
parent
0a811c5b43
commit
c880709048
1
elm.json
1
elm.json
@ -7,6 +7,7 @@
|
||||
"exposed-modules": [
|
||||
"Review.Rule",
|
||||
"Review.Project",
|
||||
"Review.Project.Dependency",
|
||||
"Review.Fix",
|
||||
"Review.Test"
|
||||
],
|
||||
|
@ -16,7 +16,7 @@ import Elm.Syntax.Import exposing (Import)
|
||||
import Elm.Syntax.ModuleName exposing (ModuleName)
|
||||
import Elm.Syntax.Node as Node exposing (Node)
|
||||
import Elm.Syntax.Range exposing (Range)
|
||||
import Review.Project
|
||||
import Review.Project.Dependency exposing (Dependency)
|
||||
import Review.Rule as Rule exposing (Error, Rule)
|
||||
import Set exposing (Set)
|
||||
|
||||
@ -65,7 +65,7 @@ moduleVisitor schema =
|
||||
|> Rule.withImportVisitor importVisitor
|
||||
|
||||
|
||||
dependenciesVisitor : Dict String Review.Project.Dependency -> ProjectContext -> ProjectContext
|
||||
dependenciesVisitor : Dict String Dependency -> ProjectContext -> ProjectContext
|
||||
dependenciesVisitor dependencies projectContext =
|
||||
let
|
||||
moduleNameToDependency : Dict String String
|
||||
|
@ -2,7 +2,7 @@ module Review.Project exposing
|
||||
( Project, new
|
||||
, ProjectModule, addModule, addParsedModule, removeModule, modules, filesThatFailedToParse, moduleGraph, precomputeModuleGraph
|
||||
, withElmJson, elmJson
|
||||
, Dependency, withDependency, removeDependencies, dependencies
|
||||
, withDependency, removeDependencies, dependencies
|
||||
)
|
||||
|
||||
{-| Represents the contents of the project to be analyzed. This information will
|
||||
@ -33,12 +33,11 @@ in existing environments like the CLI tool.
|
||||
|
||||
# Project dependencies
|
||||
|
||||
@docs Dependency, withDependency, removeDependencies, dependencies
|
||||
@docs withDependency, removeDependencies, dependencies
|
||||
|
||||
-}
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Elm.Docs
|
||||
import Elm.Parser as Parser
|
||||
import Elm.Processing
|
||||
import Elm.Project
|
||||
@ -46,8 +45,8 @@ import Elm.Syntax.File exposing (File)
|
||||
import Elm.Syntax.Module
|
||||
import Elm.Syntax.ModuleName exposing (ModuleName)
|
||||
import Elm.Syntax.Node as Node
|
||||
import Elm.Version
|
||||
import Review.Dependencies
|
||||
import Review.Project.Dependency exposing (Dependency)
|
||||
import Vendor.Graph as Graph exposing (Graph)
|
||||
|
||||
|
||||
@ -289,20 +288,6 @@ elmJson (Project project) =
|
||||
project.elmJson
|
||||
|
||||
|
||||
|
||||
-- PROJECT DEPENDENCIES
|
||||
|
||||
|
||||
{-| TODO Documentation
|
||||
-}
|
||||
type alias Dependency =
|
||||
{ name : String
|
||||
, version : Elm.Version.Version
|
||||
, elmJson : Elm.Project.Project
|
||||
, modules : List Elm.Docs.Module
|
||||
}
|
||||
|
||||
|
||||
{-| Add a dependency to the project. These will be available for rules to make
|
||||
better assumptions on what is happening in the code.
|
||||
|
||||
|
36
src/Review/Project/Dependency.elm
Normal file
36
src/Review/Project/Dependency.elm
Normal file
@ -0,0 +1,36 @@
|
||||
module Review.Project.Dependency exposing (Dependency, create)
|
||||
|
||||
{-| TODO Documentation
|
||||
|
||||
@docs Dependency, create
|
||||
|
||||
-}
|
||||
|
||||
import Elm.Docs
|
||||
import Elm.Project
|
||||
import Elm.Version
|
||||
|
||||
|
||||
|
||||
-- DEFINITION
|
||||
|
||||
|
||||
{-| TODO Documentation
|
||||
-}
|
||||
type alias Dependency =
|
||||
{ name : String
|
||||
, version : Elm.Version.Version
|
||||
, elmJson : Elm.Project.Project
|
||||
, modules : List Elm.Docs.Module
|
||||
}
|
||||
|
||||
|
||||
{-| TODO Documentation
|
||||
-}
|
||||
create : String -> Elm.Version.Version -> Elm.Project.Project -> List Elm.Docs.Module -> Dependency
|
||||
create name_ version_ elmJson_ modules_ =
|
||||
{ name = name_
|
||||
, version = version_
|
||||
, elmJson = elmJson_
|
||||
, modules = modules_
|
||||
}
|
@ -237,6 +237,7 @@ import Elm.Syntax.Range exposing (Range)
|
||||
import Review.Exceptions as Exceptions exposing (Exceptions)
|
||||
import Review.Fix exposing (Fix)
|
||||
import Review.Project exposing (Project, ProjectModule)
|
||||
import Review.Project.Dependency
|
||||
import Set exposing (Set)
|
||||
import Vendor.Graph as Graph exposing (Graph)
|
||||
import Vendor.IntDict as IntDict
|
||||
@ -270,7 +271,7 @@ type ModuleRuleSchema configuration context
|
||||
{ name : String
|
||||
, initialContext : context
|
||||
, elmJsonVisitors : List (Maybe Elm.Project.Project -> context -> context)
|
||||
, dependenciesVisitors : List (Dict String Review.Project.Dependency -> context -> context)
|
||||
, dependenciesVisitors : List (Dict String Review.Project.Dependency.Dependency -> context -> context)
|
||||
, moduleDefinitionVisitors : List (Node Module -> context -> ( List Error, context ))
|
||||
, commentsVisitors : List (List (Node String) -> context -> ( List Error, context ))
|
||||
, importVisitors : List (Node Import -> context -> ( List Error, context ))
|
||||
@ -705,7 +706,7 @@ type ProjectRuleSchema projectContext moduleContext
|
||||
}
|
||||
, moduleVisitor : ModuleRuleSchema {} moduleContext -> ModuleRuleSchema { hasAtLeastOneVisitor : () } moduleContext
|
||||
, elmJsonVisitors : List (Maybe { elmJsonKey : ElmJsonKey, project : Elm.Project.Project } -> projectContext -> projectContext)
|
||||
, dependenciesVisitors : List (Dict String Review.Project.Dependency -> projectContext -> projectContext)
|
||||
, dependenciesVisitors : List (Dict String Review.Project.Dependency.Dependency -> projectContext -> projectContext)
|
||||
, finalEvaluationFns : List (projectContext -> List Error)
|
||||
, traversalType : TraversalType
|
||||
}
|
||||
@ -954,7 +955,7 @@ withElmJsonProjectVisitor visitor (ProjectRuleSchema schema) =
|
||||
{-| TODO documentation
|
||||
-}
|
||||
withDependenciesProjectVisitor :
|
||||
(Dict String Review.Project.Dependency -> projectContext -> projectContext)
|
||||
(Dict String Review.Project.Dependency.Dependency -> projectContext -> projectContext)
|
||||
-> ProjectRuleSchema projectContext moduleContext
|
||||
-> ProjectRuleSchema projectContext moduleContext
|
||||
withDependenciesProjectVisitor visitor (ProjectRuleSchema schema) =
|
||||
@ -1679,7 +1680,7 @@ withElmJsonModuleVisitor visitor (ModuleRuleSchema schema) =
|
||||
{-| TODO
|
||||
-}
|
||||
withDependenciesModuleVisitor :
|
||||
(Dict String Review.Project.Dependency -> moduleContext -> moduleContext)
|
||||
(Dict String Review.Project.Dependency.Dependency -> moduleContext -> moduleContext)
|
||||
-> ModuleRuleSchema { anything | withDependenciesModuleVisitor : () } moduleContext
|
||||
-> ModuleRuleSchema { anything | withDependenciesModuleVisitor : () } moduleContext
|
||||
withDependenciesModuleVisitor visitor (ModuleRuleSchema schema) =
|
||||
|
@ -40,7 +40,7 @@ import Elm.Syntax.Signature exposing (Signature)
|
||||
import Elm.Syntax.TypeAnnotation as TypeAnnotation exposing (TypeAnnotation)
|
||||
import Elm.Type
|
||||
import NonemptyList exposing (Nonempty)
|
||||
import Review.Project
|
||||
import Review.Project.Dependency exposing (Dependency)
|
||||
import Review.Rule as Rule exposing (Direction)
|
||||
|
||||
|
||||
@ -269,7 +269,7 @@ pairWithNoErrors fn visited context =
|
||||
-- DEPENDENCIES
|
||||
|
||||
|
||||
dependenciesVisitor : Dict String Review.Project.Dependency -> InnerProjectContext -> InnerProjectContext
|
||||
dependenciesVisitor : Dict String Dependency -> InnerProjectContext -> InnerProjectContext
|
||||
dependenciesVisitor dependencies innerContext =
|
||||
let
|
||||
dependenciesModules : Dict String Elm.Docs.Module
|
||||
|
Loading…
Reference in New Issue
Block a user