{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
module Wingman.Range where
import Development.IDE hiding (rangeToRealSrcSpan, rangeToSrcSpan)
import Development.IDE.GHC.Compat.Core
import Development.IDE.GHC.Compat.Util as FS
rangeToSrcSpan :: String -> Range -> SrcSpan
rangeToSrcSpan :: String -> Range -> SrcSpan
rangeToSrcSpan String
file Range
range = RealSrcSpan -> Maybe BufSpan -> SrcSpan
RealSrcSpan (String -> Range -> RealSrcSpan
rangeToRealSrcSpan String
file Range
range) Maybe BufSpan
forall a. Maybe a
Nothing
rangeToRealSrcSpan :: String -> Range -> RealSrcSpan
rangeToRealSrcSpan :: String -> Range -> RealSrcSpan
rangeToRealSrcSpan String
file (Range (Position UInt
startLn UInt
startCh) (Position UInt
endLn UInt
endCh)) =
RealSrcLoc -> RealSrcLoc -> RealSrcSpan
mkRealSrcSpan
(FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc (String -> FastString
FS.fsLit String
file) (UInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (UInt -> Int) -> UInt -> Int
forall a b. (a -> b) -> a -> b
$ UInt
startLn UInt -> UInt -> UInt
forall a. Num a => a -> a -> a
+ UInt
1) (UInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (UInt -> Int) -> UInt -> Int
forall a b. (a -> b) -> a -> b
$ UInt
startCh UInt -> UInt -> UInt
forall a. Num a => a -> a -> a
+ UInt
1))
(FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc (String -> FastString
FS.fsLit String
file) (UInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (UInt -> Int) -> UInt -> Int
forall a b. (a -> b) -> a -> b
$ UInt
endLn UInt -> UInt -> UInt
forall a. Num a => a -> a -> a
+ UInt
1) (UInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (UInt -> Int) -> UInt -> Int
forall a b. (a -> b) -> a -> b
$ UInt
endCh UInt -> UInt -> UInt
forall a. Num a => a -> a -> a
+ UInt
1))