Ide.Plugin.Cabal.Completion.Types

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

Safe Haskell | None
Language | GHC2021

Ide.Plugin.Cabal.Completion.Types

Synopsis

- data Log
  - = LogFileSplitError Position
  - | LogUnknownKeyWordInContextError KeyWordName
  - | LogUnknownStanzaNameInContextError StanzaName
  - | LogFilePathCompleterIOError FilePath IOError
  - | LogUseWithStaleFastNoResult
  - | LogMapLookUpOfKnownKeyFailed Text
  - | LogCompletionContext Context
- data ParseCabalFile = ParseCabalFile
- data ParseCabalFields = ParseCabalFields
- type Context = (StanzaContext, FieldContext)
- data StanzaContext
  - = TopLevel
  - | Stanza !StanzaType !(Maybe StanzaName)
- data FieldContext
  - = KeyWord !KeyWordName
  - | None
- type KeyWordName = Text
- type StanzaName = Text
- type StanzaType = Text
- data CabalPrefixInfo = CabalPrefixInfo {
  - completionPrefix :: Text
  - isStringNotation :: Maybe Apostrophe
  - completionCursorPosition :: Position
  - completionRange :: Range
  - completionWorkingDir :: FilePath
  - completionFileName :: Text
  }
- data Apostrophe
  - = Surrounded
  - | LeftSide
- applyStringNotation :: Maybe Apostrophe -> Text -> Text
- lspPositionToCabalPosition :: Position -> Position

# Documentation

data Log #

Constructors

LogFileSplitError Position |
LogUnknownKeyWordInContextError KeyWordName | This should never occur since we extract the word to lookup from the same map we look it up in.
LogUnknownStanzaNameInContextError StanzaName | This should never occur since we extract the word to lookup from the same map we look it up in.
LogFilePathCompleterIOError FilePath IOError |
LogUseWithStaleFastNoResult |
LogMapLookUpOfKnownKeyFailed Text |
LogCompletionContext Context |

#### Instances

Instances details

Show Log # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods showsPrec :: Int -> Log -> ShowS # show :: Log -> String # showList :: [Log] -> ShowS #
Pretty Log # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods pretty :: Log -> Doc ann # prettyList :: [Log] -> Doc ann #

data ParseCabalFile #

Constructors

ParseCabalFile |

#### Instances

Instances details

NFData ParseCabalFile # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods rnf :: ParseCabalFile -> () #
Generic ParseCabalFile # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Associated Types
type Rep ParseCabalFile |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types type Rep ParseCabalFile = D1 ('MetaData "ParseCabalFile" "Ide.Plugin.Cabal.Completion.Types" "haskell-language-server-2.9.0.0-CdTZH9Xymiz9Eu8uA6iKxs-hls-cabal-plugin" 'False) (C1 ('MetaCons "ParseCabalFile" 'PrefixI 'False) (U1 :: Type -> Type))
Methods from :: ParseCabalFile -> Rep ParseCabalFile x # to :: Rep ParseCabalFile x -> ParseCabalFile #
Show ParseCabalFile # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods showsPrec :: Int -> ParseCabalFile -> ShowS # show :: ParseCabalFile -> String # showList :: [ParseCabalFile] -> ShowS #
Eq ParseCabalFile # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods (==) :: ParseCabalFile -> ParseCabalFile -> Bool # (/=) :: ParseCabalFile -> ParseCabalFile -> Bool #
Hashable ParseCabalFile # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods hashWithSalt :: Int -> ParseCabalFile -> Int # hash :: ParseCabalFile -> Int #
type Rep ParseCabalFile # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types type Rep ParseCabalFile = D1 ('MetaData "ParseCabalFile" "Ide.Plugin.Cabal.Completion.Types" "haskell-language-server-2.9.0.0-CdTZH9Xymiz9Eu8uA6iKxs-hls-cabal-plugin" 'False) (C1 ('MetaCons "ParseCabalFile" 'PrefixI 'False) (U1 :: Type -> Type))
type RuleResult ParseCabalFile # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types type RuleResult ParseCabalFile = GenericPackageDescription

data ParseCabalFields #

Constructors

ParseCabalFields |

#### Instances

Instances details

NFData ParseCabalFields # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods rnf :: ParseCabalFields -> () #
Generic ParseCabalFields # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Associated Types
type Rep ParseCabalFields |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types type Rep ParseCabalFields = D1 ('MetaData "ParseCabalFields" "Ide.Plugin.Cabal.Completion.Types" "haskell-language-server-2.9.0.0-CdTZH9Xymiz9Eu8uA6iKxs-hls-cabal-plugin" 'False) (C1 ('MetaCons "ParseCabalFields" 'PrefixI 'False) (U1 :: Type -> Type))
Methods from :: ParseCabalFields -> Rep ParseCabalFields x # to :: Rep ParseCabalFields x -> ParseCabalFields #
Show ParseCabalFields # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods showsPrec :: Int -> ParseCabalFields -> ShowS # show :: ParseCabalFields -> String # showList :: [ParseCabalFields] -> ShowS #
Eq ParseCabalFields # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods (==) :: ParseCabalFields -> ParseCabalFields -> Bool # (/=) :: ParseCabalFields -> ParseCabalFields -> Bool #
Hashable ParseCabalFields # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods hashWithSalt :: Int -> ParseCabalFields -> Int # hash :: ParseCabalFields -> Int #
type Rep ParseCabalFields # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types type Rep ParseCabalFields = D1 ('MetaData "ParseCabalFields" "Ide.Plugin.Cabal.Completion.Types" "haskell-language-server-2.9.0.0-CdTZH9Xymiz9Eu8uA6iKxs-hls-cabal-plugin" 'False) (C1 ('MetaCons "ParseCabalFields" 'PrefixI 'False) (U1 :: Type -> Type))
type RuleResult ParseCabalFields # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types type RuleResult ParseCabalFields = [Field Position]

type Context = (StanzaContext, FieldContext) #

The context a cursor can be in within a cabal file.

We can be in stanzas or the top level, and additionally we can be in a context where we have already written a keyword but no value for it yet

data StanzaContext #

Context inside a cabal file. Used to decide which keywords to suggest.

Constructors

TopLevel | Top level context in a cabal file such as `author`
Stanza !StanzaType !(Maybe StanzaName) | Nested context in a cabal file, such as `library`. Stanzas have their own fields which differ from top-level fields. Each stanza must be named, such as 'executable exe', except for the main library.

#### Instances

Instances details

Read StanzaContext # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods readsPrec :: Int -> ReadS StanzaContext # readList :: ReadS [StanzaContext] # readPrec :: ReadPrec StanzaContext # readListPrec :: ReadPrec [StanzaContext] #
Show StanzaContext # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods showsPrec :: Int -> StanzaContext -> ShowS # show :: StanzaContext -> String # showList :: [StanzaContext] -> ShowS #
Eq StanzaContext # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods (==) :: StanzaContext -> StanzaContext -> Bool # (/=) :: StanzaContext -> StanzaContext -> Bool #
Pretty StanzaContext # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods pretty :: StanzaContext -> Doc ann # prettyList :: [StanzaContext] -> Doc ann #

data FieldContext #

Keyword context in a cabal file.

Used to decide whether to suggest values or keywords.

Constructors

KeyWord !KeyWordName | Key word context, where a keyword occurs right before the current word to be completed
None | Keyword context where no keyword occurs right before the current word to be completed

#### Instances

Instances details

Read FieldContext # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods readsPrec :: Int -> ReadS FieldContext # readList :: ReadS [FieldContext] # readPrec :: ReadPrec FieldContext # readListPrec :: ReadPrec [FieldContext] #
Show FieldContext # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods showsPrec :: Int -> FieldContext -> ShowS # show :: FieldContext -> String # showList :: [FieldContext] -> ShowS #
Eq FieldContext # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods (==) :: FieldContext -> FieldContext -> Bool # (/=) :: FieldContext -> FieldContext -> Bool #
Pretty FieldContext # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods pretty :: FieldContext -> Doc ann # prettyList :: [FieldContext] -> Doc ann #

type KeyWordName = Text #

type StanzaName = Text #

type StanzaType = Text #

data CabalPrefixInfo #

Information regarding the current completion status

Example: `"dir1/fi` having been written to the file would correspond to:

       completionPrefix = "dir1/fi"
       isStringNotation = LeftSide
       ...

We define this type instead of simply using VFS.PosPrefixInfo since e.g. for filepaths we need more than just the word before the cursor (as can be seen above), since we want to capture the whole filepath before the cursor.

We also use this type to wrap all information necessary to complete filepaths and other values in a cabal file.

Constructors

CabalPrefixInfo |
Fields completionPrefix :: Text text prefix to complete isStringNotation :: Maybe Apostrophe Did the completion happen in the context of a string notation, i.e. are there apostrophes around the item to be completed completionCursorPosition :: Position the current position of the cursor in the file completionRange :: Range range where completion is to be inserted completionWorkingDir :: FilePath directory of the handled cabal file completionFileName :: Text filename of the handled cabal file

#### Instances

Instances details

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

data Apostrophe #

Where are the apostrophes around the item to be completed?

`Surrounded` means the item to complete already has the necessary apostrophes, while `LeftSide` means, a closing apostrophe has to be added after the completion item.

Constructors

Surrounded |
LeftSide |

#### Instances

Instances details

Show Apostrophe # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods showsPrec :: Int -> Apostrophe -> ShowS # show :: Apostrophe -> String # showList :: [Apostrophe] -> ShowS #
Eq Apostrophe # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods (==) :: Apostrophe -> Apostrophe -> Bool # (/=) :: Apostrophe -> Apostrophe -> Bool #
Ord Apostrophe # |
Instance details Defined in Ide.Plugin.Cabal.Completion.Types Methods compare :: Apostrophe -> Apostrophe -> Ordering # (<) :: Apostrophe -> Apostrophe -> Bool # (<=) :: Apostrophe -> Apostrophe -> Bool # (>) :: Apostrophe -> Apostrophe -> Bool # (>=) :: Apostrophe -> Apostrophe -> Bool # max :: Apostrophe -> Apostrophe -> Apostrophe # min :: Apostrophe -> Apostrophe -> Apostrophe #

applyStringNotation :: Maybe Apostrophe -> Text -> Text #

Wraps a completion in apostrophes where appropriate.

If a completion starts with an apostrophe we want to end it with an apostrophe. If a completed filepath contains a space, it can only be written in the cabal file if it is wrapped in apostrophes, thus we wrap it.

lspPositionToCabalPosition :: Position -> Position #

Convert an LSP `Position` to a `Position`.

Cabal Positions start their indexing at 1 while LSP starts at 0. This helper makes sure, the translation is done properly.