-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | HLS Plugin to support smart selection range and Folding range -- -- Please see the README on GitHub at -- https://github.com/haskell/haskell-language-server#readme @package hls-code-range-plugin @version 2.2.0.0 module Ide.Plugin.CodeRange.Rules -- | A tree representing code ranges in a file. This can be useful for -- features like selection range and folding range data CodeRange CodeRange :: !Range -> !Vector CodeRange -> !CodeRangeKind -> CodeRange -- | Range for current level [_codeRange_range] :: CodeRange -> !Range -- | A vector of children, sorted by their ranges in ascending order. -- Children are guaranteed not to interleave, but some gaps may exist -- among them. [_codeRange_children] :: CodeRange -> !Vector CodeRange [_codeRange_kind] :: CodeRange -> !CodeRangeKind codeRange_range :: Lens' CodeRange Range codeRange_children :: Lens' CodeRange (Vector CodeRange) codeRange_kind :: Lens' CodeRange CodeRangeKind -- | CodeKind represents the kind of a code range data CodeRangeKind -- | ordinary code CodeKindRegion :: CodeRangeKind -- | the group of imports CodeKindImports :: CodeRangeKind -- | a comment CodeKindComment :: CodeRangeKind data GetCodeRange GetCodeRange :: GetCodeRange codeRangeRule :: Recorder (WithPriority Log) -> Rules () data Log LogShake :: Log -> Log LogNoAST :: Log LogFoundInterleaving :: CodeRange -> CodeRange -> Log -- | Remove interleaving of the list of CodeRanges. removeInterleaving :: [CodeRange] -> Writer [Log] [CodeRange] -- | Remove redundant nodes in CodeRange tree simplify :: CodeRange -> CodeRange -- | Maps type CodeRangeKind to FoldingRangeKind crkToFrk :: CodeRangeKind -> FoldingRangeKind instance GHC.Generics.Generic Ide.Plugin.CodeRange.Rules.GetCodeRange instance GHC.Show.Show Ide.Plugin.CodeRange.Rules.GetCodeRange instance GHC.Classes.Eq Ide.Plugin.CodeRange.Rules.GetCodeRange instance Data.Hashable.Class.Hashable Ide.Plugin.CodeRange.Rules.GetCodeRange instance Control.DeepSeq.NFData Ide.Plugin.CodeRange.Rules.GetCodeRange instance GHC.Classes.Eq Ide.Plugin.CodeRange.Rules.CodeRange instance GHC.Classes.Ord Ide.Plugin.CodeRange.Rules.CodeRange instance Control.DeepSeq.NFData Ide.Plugin.CodeRange.Rules.CodeRangeKind instance GHC.Generics.Generic Ide.Plugin.CodeRange.Rules.CodeRangeKind instance GHC.Classes.Eq Ide.Plugin.CodeRange.Rules.CodeRangeKind instance GHC.Show.Show Ide.Plugin.CodeRange.Rules.CodeRangeKind instance Control.DeepSeq.NFData Ide.Plugin.CodeRange.Rules.CodeRange instance GHC.Generics.Generic Ide.Plugin.CodeRange.Rules.CodeRange instance GHC.Show.Show Ide.Plugin.CodeRange.Rules.CodeRange instance GHC.Show.Show Ide.Plugin.CodeRange.Rules.Log instance Prettyprinter.Internal.Pretty Ide.Plugin.CodeRange.Rules.Log module Ide.Plugin.CodeRange descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState data Log -- | Find Position in CodeRange. This can fail, if the given -- position is not covered by the CodeRange. findPosition :: Position -> CodeRange -> Maybe SelectionRange -- | 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. --
  3. 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.
  4. --
-- -- 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 findFoldingRanges :: CodeRange -> [FoldingRange] -- | Parses code range to folding range createFoldingRange :: CodeRange -> Maybe FoldingRange instance Prettyprinter.Internal.Pretty Ide.Plugin.CodeRange.Log