ghcide-2.9.0.0: The core of an IDE

Safe Haskell | None
Language | GHC2021

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

NFData DependencyInformation # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: DependencyInformation -> () #
Generic DependencyInformation # |

Instance details

Defined in Development.IDE.Import.DependencyInformation

Associated Types

type Rep DependencyInformation |
Instance details Defined in Development.IDE.Import.DependencyInformation type Rep DependencyInformation

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 #
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

NFData NodeError # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: NodeError -> () #
Generic NodeError # |

Instance details

Defined in Development.IDE.Import.DependencyInformation

Associated Types

type Rep NodeError |

Instance details

Defined in Development.IDE.Import.DependencyInformation

type Rep NodeError = D1 ('MetaData "NodeError" "Development.IDE.Import.DependencyInformation" "ghcide-2.9.0.0-1G3u1vh8JKWDpMQ8kfXrG1" '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)))))

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 #
type Rep NodeError # |

Instance details

Defined in Development.IDE.Import.DependencyInformation

type Rep NodeError = D1 ('MetaData "NodeError" "Development.IDE.Import.DependencyInformation" "ghcide-2.9.0.0-1G3u1vh8JKWDpMQ8kfXrG1" '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

NFData ModuleParseError # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: ModuleParseError -> () #
Generic ModuleParseError # |

Instance details

Defined in Development.IDE.Import.DependencyInformation

Associated Types

type Rep ModuleParseError |
Instance details Defined in Development.IDE.Import.DependencyInformation type Rep ModuleParseError = D1 ('MetaData "ModuleParseError" "Development.IDE.Import.DependencyInformation" "ghcide-2.9.0.0-1G3u1vh8JKWDpMQ8kfXrG1" 'False) (C1 ('MetaCons "ModuleParseError" 'PrefixI 'False) (U1 :: 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 #
type Rep ModuleParseError # |
Instance details Defined in Development.IDE.Import.DependencyInformation type Rep ModuleParseError = D1 ('MetaData "ModuleParseError" "Development.IDE.Import.DependencyInformation" "ghcide-2.9.0.0-1G3u1vh8JKWDpMQ8kfXrG1" '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

NFData TransitiveDependencies # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: TransitiveDependencies -> () #
Generic TransitiveDependencies # |

Instance details

Defined in Development.IDE.Import.DependencyInformation

Associated Types

type Rep TransitiveDependencies |

Instance details

Defined in Development.IDE.Import.DependencyInformation

type Rep TransitiveDependencies = D1 ('MetaData "TransitiveDependencies" "Development.IDE.Import.DependencyInformation" "ghcide-2.9.0.0-1G3u1vh8JKWDpMQ8kfXrG1" 'True) (C1 ('MetaCons "TransitiveDependencies" 'PrefixI 'True) (S1 ('MetaSel ('Just "transitiveModuleDeps") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [NormalizedFilePath])))

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 #
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.9.0.0-1G3u1vh8JKWDpMQ8kfXrG1" '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

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

NFData NamedModuleDep # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: NamedModuleDep -> () #
Generic NamedModuleDep # |

Instance details

Defined in Development.IDE.Import.DependencyInformation

Associated Types

type Rep NamedModuleDep |

Instance details

Defined in Development.IDE.Import.DependencyInformation

type Rep NamedModuleDep = D1 ('MetaData "NamedModuleDep" "Development.IDE.Import.DependencyInformation" "ghcide-2.9.0.0-1G3u1vh8JKWDpMQ8kfXrG1" '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)))))

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 #
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.9.0.0-1G3u1vh8JKWDpMQ8kfXrG1" '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

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

newtype ShowableModuleEnv a #

Constructors

ShowableModuleEnv |

Fields

- showableModuleEnv :: ModuleEnv a

#### Instances

Instances details

NFData a => NFData (ShowableModuleEnv a) # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: ShowableModuleEnv a -> () #
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 #

data PathIdMap #

Constructors

PathIdMap |

Fields

- idToPathMap :: !(FilePathIdMap ArtifactsLocation)
- pathToIdMap :: !(HashMap NormalizedFilePath FilePathId)
- nextFreshId :: !Int

#### Instances

Instances details

NFData PathIdMap # |
Instance details Defined in Development.IDE.Import.DependencyInformation Methods rnf :: PathIdMap -> () #
Generic PathIdMap # |

Instance details

Defined in Development.IDE.Import.DependencyInformation

Associated Types

type Rep PathIdMap |
Instance details Defined in Development.IDE.Import.DependencyInformation type Rep PathIdMap

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 #
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 #