haskell-language-server-2.11.0.0: LSP server for GHC
Safe HaskellNone
LanguageGHC2021

Ide.Plugin.Cabal.Completion.CabalFields

Synopsis

Documentation

findStanzaForColumn :: Int -> NonEmpty (Int, StanzaContext) -> (StanzaContext, FieldContext) Source #

Determine the context of a cursor position within a stack of stanza contexts

If the cursor is indented more than one of the stanzas in the stack the respective stanza is returned if this is never the case, the toplevel stanza in the stack is returned.

getModulesNames :: [Field any] -> [([Maybe BuildTargetName], ModuleName)] Source #

Given a cabal AST returns pairs of all respective target names and the module name bound to them. If a target is a main library gives Nothing, otherwise Just target-name

Examples of input cabal files and the outputs:

  • Target is a main library module:
  library
    exposed-modules:
      MyLib
  • getModulesNames output:
  [([Nothing], "MyLib")]
  • Same module names in different targets:
  test-suite first-target
       other-modules:
         Config
  test-suite second-target
       other-modules:
         Config
  • getModulesNames output:
  [([Just "first-target", Just "second-target"], "Config")]

getFieldLSPRange :: Field Position -> Range Source #

Returns an LSP compatible range for a provided field

findFieldSection :: Position -> [Field Position] -> Maybe (Field Position) Source #

Determine the field the cursor is currently a part of.

The result is said field and its starting position or Nothing if the passed list of fields is empty.

This only looks at the row of the cursor and not at the cursor's position within the row.

TODO: we do not handle braces correctly. Add more tests!

findTextWord :: Position -> [Field Position] -> Maybe Text Source #

Determine the exact word at the current cursor position.

The result is said word or Nothing if the passed list is empty or the cursor position is not next to, or on a word. For this function, a word is a sequence of consecutive characters that are not a space or column.

This function currently only considers words inside of a FieldLine.

findFieldLine :: Position -> [Field Position] -> Maybe (FieldLine Position) Source #

Determine the field line the cursor is currently a part of.

The result is said field line and its starting position or Nothing if the passed list of fields is empty.

This function assumes that elements in a field's FieldLine list do not share the same row.

getOptionalSectionName :: [SectionArg ann] -> Maybe Text Source #

Returns the name of a section if it has a name.

This assumes that the given section args belong to named stanza in which case the stanza name is returned.

getAnnotation :: Field ann -> ann Source #

getFieldName :: Field ann -> FieldName Source #

onelineSectionArgs :: [SectionArg ann] -> Text Source #

Makes a single text line out of multiple SectionArgs. Allows to display conditions, flags, etc in one line, which is easier to read.

For example, flag ( pedantic ) will be joined in one line, instead of four SectionArgs separately.

getFieldEndPosition :: Field Position -> Position Source #

Returns the end position of a provided field

getSectionArgEndPosition :: SectionArg Position -> Position Source #

Returns the end position of a provided section arg

getNameEndPosition :: Name Position -> Position Source #

Returns the end position of a provided name

getFieldLineEndPosition :: FieldLine Position -> Position Source #

Returns the end position of a provided field line