Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState
- data Log
- findPosition :: Position -> CodeRange -> Maybe SelectionRange
- findFoldingRanges :: CodeRange -> [FoldingRange]
- createFoldingRange :: CodeRange -> Maybe FoldingRange
Documentation
descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState Source #
Internal
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:
- 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.
- 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