[LIGO-40] Implement LSP range cconversion function
Problem: We need to be able to convert squirrel ranges to lsp specific ones. Solution: Add `toLSPRange` function.
This commit is contained in:
parent
283f41738d
commit
0b1590e324
@ -7,13 +7,16 @@
|
||||
module Range
|
||||
( Range(..)
|
||||
, HasRange(..)
|
||||
, toLSPRange
|
||||
, cutOut
|
||||
, point
|
||||
)
|
||||
where
|
||||
|
||||
import qualified Data.ByteString as BS
|
||||
import qualified Language.Haskell.LSP.Types as LSP (Position (..), Range (..))
|
||||
|
||||
import Data.ByteString (ByteString)
|
||||
import qualified Data.ByteString as BS
|
||||
import Data.Text (Text)
|
||||
import Data.Text.Encoding
|
||||
|
||||
@ -54,6 +57,16 @@ instance HasRange Range where
|
||||
instance Contains Range xs => HasRange (Product xs) where
|
||||
getRange = getElem
|
||||
|
||||
-- | Convert `squirrel` range to `haskell-lsp` range.
|
||||
toLSPRange :: Range -> LSP.Range
|
||||
toLSPRange Range
|
||||
{ rStart = (rsl, rsc, _)
|
||||
, rFinish = (rfl, rfc, _)
|
||||
} = LSP.Range
|
||||
{ LSP._start = LSP.Position { LSP._line = rsl, LSP._character = rsc }
|
||||
, LSP._end = LSP.Position { LSP._line = rfl, LSP._character = rfc }
|
||||
}
|
||||
|
||||
-- | Extract textual representation of given range.
|
||||
cutOut :: Range -> ByteString -> Text
|
||||
cutOut (Range (_, _, s) (_, _, f) _) bs =
|
||||
|
Loading…
Reference in New Issue
Block a user