Ide.Plugin.Cabal.Completion.Completer.Paths

haskell-language-server-2.9.0.0: LSP server for GHC

Safe Haskell | None
Language | GHC2021

Ide.Plugin.Cabal.Completion.Completer.Paths

Synopsis

- data PathCompletionInfo = PathCompletionInfo {
  - pathSegment :: Text
  - queryDirectory :: FilePath
  - workingDirectory :: FilePath
  - isStringNotationPath :: Maybe Apostrophe
  }
- splitFileNameNoTrailingSlash :: FilePath -> (String, String)
- pathCompletionInfoFromCabalPrefixInfo :: FilePath -> CabalPrefixInfo -> PathCompletionInfo
- sourceDirsExtractionLibrary :: Maybe StanzaName -> GenericPackageDescription -> [FilePath]
- sourceDirsExtractionExecutable :: Maybe StanzaName -> GenericPackageDescription -> [FilePath]
- sourceDirsExtractionTestSuite :: Maybe StanzaName -> GenericPackageDescription -> [FilePath]
- sourceDirsExtractionBenchmark :: Maybe StanzaName -> GenericPackageDescription -> [FilePath]
- extractRelativeDirsFromStanza :: Maybe StanzaName -> GenericPackageDescription -> (GenericPackageDescription -> [(UnqualComponentName, CondTree b c a)]) -> (a -> BuildInfo) -> [FilePath]

# Documentation

data PathCompletionInfo #

Information used to query and build path completions.

Note that pathSegment combined with queryDirectory results in the original prefix.

Example: When given the written prefix, `dir1/dir2/fi`, the resulting PathCompletionInfo would be:

       pathSegment = "fi"
       queryDirectory  = "dir1/dir2/fi"
       ...

Constructors

PathCompletionInfo |
Fields pathSegment :: Text Partly written segment of the next part of the path. queryDirectory :: FilePath Written part of path, in posix format. workingDirectory :: FilePath Directory relative to which relative paths are interpreted, platform dependent. isStringNotationPath :: Maybe Apostrophe Did the completion happen in the context of a string notation, if yes, contains the state of the string notation.

#### Instances

Instances details

Show PathCompletionInfo # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Completer.Paths Methods showsPrec :: Int -> PathCompletionInfo -> ShowS # show :: PathCompletionInfo -> String # showList :: [PathCompletionInfo] -> ShowS #
Eq PathCompletionInfo # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Completer.Paths Methods (==) :: PathCompletionInfo -> PathCompletionInfo -> Bool # (/=) :: PathCompletionInfo -> PathCompletionInfo -> Bool #

splitFileNameNoTrailingSlash :: FilePath -> (String, String) #

Posix.splitFileName modification, that drops trailing ./ if if wasn't present in the original path.

Fix for the issue #3774 Examples:

    >>> splitFileNameNoTrailingSlash ""
    ("", "")
    >>> splitFileNameNoTrailingSlash "./"
    ("./", "")
    >>> splitFileNameNoTrailingSlash "dir"
    ("", "dir")
    >>> splitFileNameNoTrailingSlash "./dir"
    ("./", "dir")
    >>> splitFileNameNoTrailingSlash "dir1/dir2"
    ("dir1/","dir2")
    >>> splitFileNameNoTrailingSlash "./dir1/dir2"
    ("./dir1/","dir2")

pathCompletionInfoFromCabalPrefixInfo :: FilePath -> CabalPrefixInfo -> PathCompletionInfo #

Takes an optional source subdirectory and a prefix info and creates a path completion info accordingly.

The source directory represents some subdirectory of the working directory such as a path from the field `hs-source-dirs`.

If the source subdirectory is empty, then the working directory is simply set to the currently handled cabal file's directory.

sourceDirsExtractionLibrary :: Maybe StanzaName -> GenericPackageDescription -> [FilePath] #

Extracts the source directories of the library stanza.

sourceDirsExtractionExecutable :: Maybe StanzaName -> GenericPackageDescription -> [FilePath] #

Extracts the source directories of the executable stanza with the given name.

sourceDirsExtractionTestSuite :: Maybe StanzaName -> GenericPackageDescription -> [FilePath] #

Extracts the source directories of the test suite stanza with the given name.

sourceDirsExtractionBenchmark :: Maybe StanzaName -> GenericPackageDescription -> [FilePath] #

Extracts the source directories of benchmark stanza with the given name.

extractRelativeDirsFromStanza :: Maybe StanzaName -> GenericPackageDescription -> (GenericPackageDescription -> [(UnqualComponentName, CondTree b c a)]) -> (a -> BuildInfo) -> [FilePath] #

Takes a possible stanza name, a GenericPackageDescription, a function to access the stanza information we are interested in and a function to access the build info from the specific stanza.

Returns a list of relative source directory paths specified for the extracted stanza.