Skip to content

Commit 0b1da22

Browse files
author
kokobd
committed
fix haddock
1 parent 66f9829 commit 0b1da22

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

lsp-types/src/Language/LSP/Types/Location.hs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ instance Hashable Position
3434
data Range =
3535
Range
3636
{ _start :: Position -- ^ The range's start position. (inclusive)
37-
, _end :: Position -- ^ The range's end position. (exclusive)
37+
, _end :: Position -- ^ The range's end position. (exclusive, see: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#range )
3838
} deriving (Show, Read, Eq, Ord, Generic)
3939

4040
instance NFData Range
@@ -85,8 +85,10 @@ deriveJSON lspOptions ''LocationLink
8585
mkRange :: UInt -> UInt -> UInt -> UInt -> Range
8686
mkRange l c l' c' = Range (Position l c) (Position l' c')
8787

88-
subRange :: Range -> Range -> Bool
89-
subRange smallRange range = _start smallRange >= _start range && _end smallRange <= _end range
88+
-- | 'isSubrangeOf' returns true if for every 'Position' in the first 'Range', it's also in the second 'Range'.
89+
isSubrangeOf :: Range -> Range -> Bool
90+
isSubrangeOf smallRange range = _start smallRange >= _start range && _end smallRange <= _end range
9091

92+
-- | 'positionInRange' returns true if the given 'Position' is in the 'Range'.
9193
positionInRange :: Position -> Range -> Bool
92-
positionInRange p (Range sp ep) = sp <= p && p < ep
94+
positionInRange p (Range sp ep) = sp <= p && p < ep -- Range's end position is exclusive.

lsp-types/test/LocationSpec.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ main = hspec spec
1010

1111
spec :: Spec
1212
spec = do
13-
describe "subRange" $ do
13+
describe "isSubrangeOf" $ do
1414
it "is true if the first range is totally inside the second range" $
15-
subRange (mkRange 1 2 1 5) (mkRange 1 1 1 6) `shouldBe` True
15+
isSubrangeOf (mkRange 1 2 1 5) (mkRange 1 1 1 6) `shouldBe` True
1616
it "is true if two ranges equal" $
17-
subRange (mkRange 1 2 1 5) (mkRange 1 2 1 5) `shouldBe` True
17+
isSubrangeOf (mkRange 1 2 1 5) (mkRange 1 2 1 5) `shouldBe` True
1818
it "is false if the first range is outside of the second" $
19-
subRange (mkRange 1 1 1 5) (mkRange 1 2 1 5) `shouldBe` False
19+
isSubrangeOf (mkRange 1 1 1 5) (mkRange 1 2 1 5) `shouldBe` False
2020

2121
describe "positionInRange" $ do
2222
it "is false if position is after the end of a single line range" $

0 commit comments

Comments
 (0)