ghcide-2.4.0.0: The core of an IDE

Safe Haskell | Safe-Inferred
Language | Haskell2010

Development.IDE.Import.DependencyInformation

Synopsis

- data DependencyInformation = DependencyInformation {
  - depErrorNodes :: !(FilePathIdMap (NonEmpty NodeError))
  - depModules :: !(FilePathIdMap ShowableModule)
  - depModuleDeps :: !(FilePathIdMap FilePathIdSet)
  - depReverseModuleDeps :: !(IntMap IntSet)
  - depPathIdMap :: !PathIdMap
  - depBootMap :: !BootIdMap
  - depModuleFiles :: !(ShowableModuleEnv FilePathId)
  - depModuleGraph :: !ModuleGraph
  }
- newtype ModuleImports = ModuleImports {
  - moduleImports :: [(Located ModuleName, Maybe FilePathId)]
  }
- data RawDependencyInformation = RawDependencyInformation {
  - rawImports :: !(FilePathIdMap (Either ModuleParseError ModuleImports))
  - rawPathIdMap :: !PathIdMap
  - rawModuleMap :: !(FilePathIdMap ShowableModule)
  }
- data NodeError
  - = PartOfCycle (Located ModuleName) [FilePathId]
  - | FailedToLocateImport (Located ModuleName)
  - | ParseError ModuleParseError
  - | ParentOfErrorNode (Located ModuleName)
- data ModuleParseError = ModuleParseError
- newtype TransitiveDependencies = TransitiveDependencies {
  - transitiveModuleDeps :: [NormalizedFilePath]
  }
- newtype FilePathId = FilePathId {
  - getFilePathId :: Int
  }
- data NamedModuleDep = NamedModuleDep {
  - nmdFilePath :: !NormalizedFilePath
  - nmdModuleName :: !ModuleName
  - nmdModLocation :: !(Maybe ModLocation)
  }
- newtype ShowableModule = ShowableModule {
  - showableModule :: Module
  }
- newtype ShowableModuleEnv a = ShowableModuleEnv {
  - showableModuleEnv :: ModuleEnv a
  }
- data PathIdMap = PathIdMap {
  - idToPathMap :: !(FilePathIdMap ArtifactsLocation)
  - pathToIdMap :: !(HashMap NormalizedFilePath FilePathId)
  - nextFreshId :: !Int
  }
- emptyPathIdMap :: PathIdMap
- getPathId :: ArtifactsLocation -> PathIdMap -> (FilePathId, PathIdMap)
- lookupPathToId :: PathIdMap -> NormalizedFilePath -> Maybe FilePathId
- insertImport :: FilePathId -> Either ModuleParseError ModuleImports -> RawDependencyInformation -> RawDependencyInformation
- pathToId :: PathIdMap -> NormalizedFilePath -> Maybe FilePathId
- idToPath :: PathIdMap -> FilePathId -> NormalizedFilePath
- reachableModules :: DependencyInformation -> [NormalizedFilePath]
- processDependencyInformation :: RawDependencyInformation -> BootIdMap -> ModuleGraph -> DependencyInformation
- transitiveDeps :: DependencyInformation -> NormalizedFilePath -> Maybe TransitiveDependencies
- transitiveReverseDependencies :: NormalizedFilePath -> DependencyInformation -> Maybe [NormalizedFilePath]
- immediateReverseDependencies :: NormalizedFilePath -> DependencyInformation -> Maybe [NormalizedFilePath]
- lookupModuleFile :: Module -> DependencyInformation -> Maybe NormalizedFilePath
- type BootIdMap = FilePathIdMap FilePathId
- insertBootId :: FilePathId -> FilePathId -> BootIdMap -> BootIdMap

# Documentation

data DependencyInformation #

Constructors

DependencyInformation |
Fields depErrorNodes :: !(FilePathIdMap (NonEmpty NodeError)) Nodes that cannot be processed correctly. depModules :: !(FilePathIdMap ShowableModule) depModuleDeps :: !(FilePathIdMap FilePathIdSet) For a non-error node, this contains the set of module immediate dependencies in the same package. depReverseModuleDeps :: !(IntMap IntSet) Contains a reverse mapping from a module to all those that immediately depend on it. depPathIdMap :: !PathIdMap Map from FilePath to FilePathId depBootMap :: !BootIdMap Map from hs-boot file to the corresponding hs file depModuleFiles :: !(ShowableModuleEnv FilePathId) Map from Module to the corresponding non-boot hs file depModuleGraph :: !ModuleGraph

#### Instances

Instances details

Generic DependencyInformation # |
Instance details Defined in Development.IDE.Import.DependencyInformation Associated Types type Rep DependencyInformation :: Type -> Type Methods from :: DependencyInformation -> Rep DependencyInformation x to :: Rep DependencyInformation x -> DependencyInformation
Show DependencyInformation # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods showsPrec :: Int -> DependencyInformation -> ShowS # show :: DependencyInformation -> String # showList :: [DependencyInformation] -> ShowS #
NFData DependencyInformation # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: DependencyInformation -> () #
type Rep DependencyInformation # |
Instance details Defined in Development.IDE.Import.DependencyInformation type Rep DependencyInformation

newtype ModuleImports #

The imports for a given module.

Constructors

ModuleImports |
Fields moduleImports :: [(Located ModuleName, Maybe FilePathId)] Imports of a module in the current package and the file path of that module on disk (if we found it)

#### Instances

Instances details

Show ModuleImports # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods showsPrec :: Int -> ModuleImports -> ShowS # show :: ModuleImports -> String # showList :: [ModuleImports] -> ShowS #

data RawDependencyInformation #

Unprocessed results that we find by following imports recursively.

Constructors

RawDependencyInformation |
Fields rawImports :: !(FilePathIdMap (Either ModuleParseError ModuleImports)) rawPathIdMap :: !PathIdMap rawModuleMap :: !(FilePathIdMap ShowableModule)

#### Instances

Instances details

Show RawDependencyInformation # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods showsPrec :: Int -> RawDependencyInformation -> ShowS # show :: RawDependencyInformation -> String # showList :: [RawDependencyInformation] -> ShowS #

data NodeError #

An error attached to a node in the dependency graph.

Constructors

PartOfCycle (Located ModuleName) [FilePathId] | This module is part of an import cycle. The module name corresponds to the import that enters the cycle starting from this module. The list of filepaths represents the elements in the cycle in unspecified order.
FailedToLocateImport (Located ModuleName) | This module has an import that couldn’t be located.
ParseError ModuleParseError |
ParentOfErrorNode (Located ModuleName) | This module is the parent of a module that cannot be processed (either it cannot be parsed, is part of a cycle or the parent of another error node).

#### Instances

Instances details

Generic NodeError # |
Instance details Defined in Development.IDE.Import.DependencyInformation Associated Types type Rep NodeError :: Type -> Type Methods from :: NodeError -> Rep NodeError x to :: Rep NodeError x -> NodeError
Show NodeError # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods showsPrec :: Int -> NodeError -> ShowS # show :: NodeError -> String # showList :: [NodeError] -> ShowS #
NFData NodeError # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: NodeError -> () #
type Rep NodeError # |
Instance details Defined in Development.IDE.Import.DependencyInformation type Rep NodeError = D1 ('MetaData "NodeError" "Development.IDE.Import.DependencyInformation" "ghcide-2.4.0.0-2GLANXY6yWhIRmLZNYhiFQ" 'False) ((C1 ('MetaCons "PartOfCycle" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Located ModuleName)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [FilePathId])) :+: C1 ('MetaCons "FailedToLocateImport" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Located ModuleName)))) :+: (C1 ('MetaCons "ParseError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleParseError)) :+: C1 ('MetaCons "ParentOfErrorNode" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Located ModuleName)))))

data ModuleParseError #

This does not contain the actual parse error as that is already reported by GetParsedModule.

Constructors

ModuleParseError |

#### Instances

Instances details

Generic ModuleParseError # |
Instance details Defined in Development.IDE.Import.DependencyInformation Associated Types type Rep ModuleParseError :: Type -> Type Methods from :: ModuleParseError -> Rep ModuleParseError x to :: Rep ModuleParseError x -> ModuleParseError
Show ModuleParseError # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods showsPrec :: Int -> ModuleParseError -> ShowS # show :: ModuleParseError -> String # showList :: [ModuleParseError] -> ShowS #
NFData ModuleParseError # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: ModuleParseError -> () #
type Rep ModuleParseError # |
Instance details Defined in Development.IDE.Import.DependencyInformation type Rep ModuleParseError = D1 ('MetaData "ModuleParseError" "Development.IDE.Import.DependencyInformation" "ghcide-2.4.0.0-2GLANXY6yWhIRmLZNYhiFQ" 'False) (C1 ('MetaCons "ModuleParseError" 'PrefixI 'False) (U1 :: Type -> Type))

newtype TransitiveDependencies #

Constructors

TransitiveDependencies |
Fields transitiveModuleDeps :: [NormalizedFilePath] Transitive module dependencies in topological order. The module itself is not included.

#### Instances

Instances details

Generic TransitiveDependencies # |
Instance details Defined in Development.IDE.Import.DependencyInformation Associated Types type Rep TransitiveDependencies :: Type -> Type Methods from :: TransitiveDependencies -> Rep TransitiveDependencies x to :: Rep TransitiveDependencies x -> TransitiveDependencies
Show TransitiveDependencies # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods showsPrec :: Int -> TransitiveDependencies -> ShowS # show :: TransitiveDependencies -> String # showList :: [TransitiveDependencies] -> ShowS #
NFData TransitiveDependencies # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: TransitiveDependencies -> () #
Eq TransitiveDependencies # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods (==) :: TransitiveDependencies -> TransitiveDependencies -> Bool # (/=) :: TransitiveDependencies -> TransitiveDependencies -> Bool #
type Rep TransitiveDependencies # |
Instance details Defined in Development.IDE.Import.DependencyInformation type Rep TransitiveDependencies = D1 ('MetaData "TransitiveDependencies" "Development.IDE.Import.DependencyInformation" "ghcide-2.4.0.0-2GLANXY6yWhIRmLZNYhiFQ" 'True) (C1 ('MetaCons "TransitiveDependencies" 'PrefixI 'True) (S1 ('MetaSel ('Just "transitiveModuleDeps") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [NormalizedFilePath])))

newtype FilePathId #

For processing dependency information, we need lots of maps and sets of filepaths. Comparing Strings is really slow, so we work with IntMap/IntSet instead and only convert at the edges.

Constructors

FilePathId |
Fields getFilePathId :: Int

#### Instances

Instances details

Show FilePathId # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods showsPrec :: Int -> FilePathId -> ShowS # show :: FilePathId -> String # showList :: [FilePathId] -> ShowS #
NFData FilePathId # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: FilePathId -> () #
Eq FilePathId # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods (==) :: FilePathId -> FilePathId -> Bool # (/=) :: FilePathId -> FilePathId -> Bool #
Ord FilePathId # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods compare :: FilePathId -> FilePathId -> Ordering (<) :: FilePathId -> FilePathId -> Bool (<=) :: FilePathId -> FilePathId -> Bool (>) :: FilePathId -> FilePathId -> Bool (>=) :: FilePathId -> FilePathId -> Bool max :: FilePathId -> FilePathId -> FilePathId min :: FilePathId -> FilePathId -> FilePathId

data NamedModuleDep #

Constructors

NamedModuleDep |
Fields nmdFilePath :: !NormalizedFilePath nmdModuleName :: !ModuleName nmdModLocation :: !(Maybe ModLocation)

#### Instances

Instances details

Generic NamedModuleDep # |
Instance details Defined in Development.IDE.Import.DependencyInformation Associated Types type Rep NamedModuleDep :: Type -> Type Methods from :: NamedModuleDep -> Rep NamedModuleDep x to :: Rep NamedModuleDep x -> NamedModuleDep
Show NamedModuleDep # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods showsPrec :: Int -> NamedModuleDep -> ShowS # show :: NamedModuleDep -> String # showList :: [NamedModuleDep] -> ShowS #
NFData NamedModuleDep # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: NamedModuleDep -> () #
Eq NamedModuleDep # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods (==) :: NamedModuleDep -> NamedModuleDep -> Bool # (/=) :: NamedModuleDep -> NamedModuleDep -> Bool #
type Rep NamedModuleDep # |
Instance details Defined in Development.IDE.Import.DependencyInformation type Rep NamedModuleDep = D1 ('MetaData "NamedModuleDep" "Development.IDE.Import.DependencyInformation" "ghcide-2.4.0.0-2GLANXY6yWhIRmLZNYhiFQ" 'False) (C1 ('MetaCons "NamedModuleDep" 'PrefixI 'True) (S1 ('MetaSel ('Just "nmdFilePath") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NormalizedFilePath) :*: (S1 ('MetaSel ('Just "nmdModuleName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ModuleName) :*: S1 ('MetaSel ('Just "nmdModLocation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe ModLocation)))))

newtype ShowableModule #

Constructors

ShowableModule |
Fields showableModule :: Module

#### Instances

Instances details

Show ShowableModule # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods showsPrec :: Int -> ShowableModule -> ShowS # show :: ShowableModule -> String # showList :: [ShowableModule] -> ShowS #
NFData ShowableModule # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: ShowableModule -> () #

newtype ShowableModuleEnv a #

Constructors

ShowableModuleEnv |
Fields showableModuleEnv :: ModuleEnv a

#### Instances

Instances details

Show a => Show (ShowableModuleEnv a) # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods showsPrec :: Int -> ShowableModuleEnv a -> ShowS # show :: ShowableModuleEnv a -> String # showList :: [ShowableModuleEnv a] -> ShowS #
NFData a => NFData (ShowableModuleEnv a) # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: ShowableModuleEnv a -> () #

data PathIdMap #

Constructors

PathIdMap |
Fields idToPathMap :: !(FilePathIdMap ArtifactsLocation) pathToIdMap :: !(HashMap NormalizedFilePath FilePathId) nextFreshId :: !Int

#### Instances

Instances details

Generic PathIdMap # |
Instance details Defined in Development.IDE.Import.DependencyInformation Associated Types type Rep PathIdMap :: Type -> Type Methods from :: PathIdMap -> Rep PathIdMap x to :: Rep PathIdMap x -> PathIdMap
Show PathIdMap # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods showsPrec :: Int -> PathIdMap -> ShowS # show :: PathIdMap -> String # showList :: [PathIdMap] -> ShowS #
NFData PathIdMap # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: PathIdMap -> () #
type Rep PathIdMap # |
Instance details Defined in Development.IDE.Import.DependencyInformation type Rep PathIdMap

emptyPathIdMap :: PathIdMap #

getPathId :: ArtifactsLocation -> PathIdMap -> (FilePathId, PathIdMap) #

lookupPathToId :: PathIdMap -> NormalizedFilePath -> Maybe FilePathId #

insertImport :: FilePathId -> Either ModuleParseError ModuleImports -> RawDependencyInformation -> RawDependencyInformation #

pathToId :: PathIdMap -> NormalizedFilePath -> Maybe FilePathId #

idToPath :: PathIdMap -> FilePathId -> NormalizedFilePath #

reachableModules :: DependencyInformation -> [NormalizedFilePath] #

processDependencyInformation :: RawDependencyInformation -> BootIdMap -> ModuleGraph -> DependencyInformation #

transitiveDeps :: DependencyInformation -> NormalizedFilePath -> Maybe TransitiveDependencies #

returns all transitive dependencies in topological order.

transitiveReverseDependencies :: NormalizedFilePath -> DependencyInformation -> Maybe [NormalizedFilePath] #

Transitive reverse dependencies of a file

immediateReverseDependencies :: NormalizedFilePath -> DependencyInformation -> Maybe [NormalizedFilePath] #

Immediate reverse dependencies of a file

lookupModuleFile :: Module -> DependencyInformation -> Maybe NormalizedFilePath #

type BootIdMap = FilePathIdMap FilePathId #

insertBootId :: FilePathId -> FilePathId -> BootIdMap -> BootIdMap #