ghcide-2.9.0.0: The core of an IDE

Safe Haskell | None
Language | GHC2021

Development.IDE.Core.PositionMapping

Synopsis

- newtype PositionMapping = PositionMapping PositionDelta
- data PositionResult a
  - = PositionRange {
    - unsafeLowerRange :: a
    - unsafeUpperRange :: a
    }
  - | PositionExact !a
- lowerRange :: PositionResult a -> a
- upperRange :: PositionResult a -> a
- positionResultToMaybe :: PositionResult a -> Maybe a
- fromCurrentPosition :: PositionMapping -> Position -> Maybe Position
- toCurrentPosition :: PositionMapping -> Position -> Maybe Position
- data PositionDelta = PositionDelta {
  - toDelta :: !(Position -> PositionResult Position)
  - fromDelta :: !(Position -> PositionResult Position)
  }
- addOldDelta :: PositionDelta -> PositionMapping -> PositionMapping
- idDelta :: PositionDelta
- composeDelta :: PositionDelta -> PositionDelta -> PositionDelta
- mkDelta :: [TextDocumentContentChangeEvent] -> PositionDelta
- toCurrentRange :: PositionMapping -> Range -> Maybe Range
- fromCurrentRange :: PositionMapping -> Range -> Maybe Range
- applyChange :: PositionDelta -> TextDocumentContentChangeEvent -> PositionDelta
- zeroMapping :: PositionMapping
- deltaFromDiff :: Text -> Text -> PositionDelta
- toCurrent :: Range -> Text -> Position -> PositionResult Position
- fromCurrent :: Range -> Text -> Position -> PositionResult Position

# Documentation

newtype PositionMapping #

Constructors

PositionMapping PositionDelta |

data PositionResult a #

Either an exact position, or the range of text that was substituted

Constructors

PositionRange | Fields need to be non-strict otherwise bind is exponential
Fields unsafeLowerRange :: a unsafeUpperRange :: a
PositionExact !a |

#### Instances

Instances details

Applicative PositionResult # |
Instance details Defined in Development.IDE.Core.PositionMapping Methods pure :: a -> PositionResult a # (<*>) :: PositionResult (a -> b) -> PositionResult a -> PositionResult b # liftA2 :: (a -> b -> c) -> PositionResult a -> PositionResult b -> PositionResult c # (*>) :: PositionResult a -> PositionResult b -> PositionResult b # (<*) :: PositionResult a -> PositionResult b -> PositionResult a #
Functor PositionResult # |
Instance details Defined in Development.IDE.Core.PositionMapping Methods fmap :: (a -> b) -> PositionResult a -> PositionResult b # (<$) :: a -> PositionResult b -> PositionResult a #
Monad PositionResult # |
Instance details Defined in Development.IDE.Core.PositionMapping Methods (>>=) :: PositionResult a -> (a -> PositionResult b) -> PositionResult b # (>>) :: PositionResult a -> PositionResult b -> PositionResult b # return :: a -> PositionResult a #
Show a => Show (PositionResult a) # |
Instance details Defined in Development.IDE.Core.PositionMapping Methods showsPrec :: Int -> PositionResult a -> ShowS # show :: PositionResult a -> String # showList :: [PositionResult a] -> ShowS #
Eq a => Eq (PositionResult a) # |
Instance details Defined in Development.IDE.Core.PositionMapping Methods (==) :: PositionResult a -> PositionResult a -> Bool # (/=) :: PositionResult a -> PositionResult a -> Bool #
Ord a => Ord (PositionResult a) # |
Instance details Defined in Development.IDE.Core.PositionMapping Methods compare :: PositionResult a -> PositionResult a -> Ordering # (<) :: PositionResult a -> PositionResult a -> Bool # (<=) :: PositionResult a -> PositionResult a -> Bool # (>) :: PositionResult a -> PositionResult a -> Bool # (>=) :: PositionResult a -> PositionResult a -> Bool # max :: PositionResult a -> PositionResult a -> PositionResult a # min :: PositionResult a -> PositionResult a -> PositionResult a #

lowerRange :: PositionResult a -> a #

upperRange :: PositionResult a -> a #

positionResultToMaybe :: PositionResult a -> Maybe a #

fromCurrentPosition :: PositionMapping -> Position -> Maybe Position #

toCurrentPosition :: PositionMapping -> Position -> Maybe Position #

data PositionDelta #

Constructors

PositionDelta |
Fields toDelta :: !(Position -> PositionResult Position) fromDelta :: !(Position -> PositionResult Position)

#### Instances

Instances details

NFData PositionDelta # |
Instance details Defined in Development.IDE.Core.PositionMapping Methods rnf :: PositionDelta -> () #
Show PositionDelta # |
Instance details Defined in Development.IDE.Core.PositionMapping Methods showsPrec :: Int -> PositionDelta -> ShowS # show :: PositionDelta -> String # showList :: [PositionDelta] -> ShowS #

addOldDelta #

Arguments

:: PositionDelta | delta from version k - 1 to version k
-> PositionMapping | The input mapping is from version k to version n
-> PositionMapping | The output mapping is from version k - 1 to version n

addOldDelta Add a old delta onto a Mapping k n to make a Mapping (k - 1) n

idDelta :: PositionDelta #

composeDelta :: PositionDelta -> PositionDelta -> PositionDelta #

Compose two position mappings. Composes in the same way as function composition (ie the second argument is applied to the position first).

mkDelta :: [TextDocumentContentChangeEvent] -> PositionDelta #

Convert a set of changes into a delta from k to k + 1

toCurrentRange :: PositionMapping -> Range -> Maybe Range #

fromCurrentRange :: PositionMapping -> Range -> Maybe Range #

applyChange :: PositionDelta -> TextDocumentContentChangeEvent -> PositionDelta #

zeroMapping :: PositionMapping #

deltaFromDiff :: Text -> Text -> PositionDelta #

toCurrent :: Range -> Text -> Position -> PositionResult Position #

fromCurrent :: Range -> Text -> Position -> PositionResult Position #