haskell-language-server-2.7.0.0: LSP server for GHC
Safe HaskellSafe-Inferred
LanguageGHC2021

Ide.Plugin.CodeRange

Contents

Synopsis

Documentation

data Log Source #

Instances

Instances details
Pretty Log Source # 
Instance details

Defined in Ide.Plugin.CodeRange

Methods

pretty :: Log -> Doc ann #

prettyList :: [Log] -> Doc ann #

Internal

findPosition :: Position -> CodeRange -> Maybe SelectionRange Source #

Find Position in CodeRange. This can fail, if the given position is not covered by the CodeRange.

findFoldingRanges :: CodeRange -> [FoldingRange] Source #

Traverses through the code range and it children to a folding ranges.

It starts with the root node, converts that into a folding range then moves towards the children. It converts each child of each root node and parses it to folding range and moves to its children.

Two cases to that are assumed to be taken care on the client side are:

  1. When a folding range starts and ends on the same line, it is upto the client if it wants to fold a single line folding or not.
  2. As we are converting nodes of the ast into folding ranges, there are multiple nodes starting from a single line. A single line of code doesn't mean a single node in AST, so this function removes all the nodes that have a duplicate start line, ie. they start from the same line. Eg. A multi-line function that also has a multi-line if statement starting from the same line should have the folding according to the function.

We think the client can handle this, if not we could change to remove these in future

Discussion reference: https://github.com/haskell/haskell-language-server/pull/3058#discussion_r973737211

createFoldingRange :: CodeRange -> Maybe FoldingRange Source #

Parses code range to folding range