Skip to content

Commit d1f6ef2

Browse files
committed
Add lenses
1 parent 48f1e85 commit d1f6ef2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lsp/example/Reactor.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,15 @@ handle logger = mconcat
282282
doc = params ^. J.textDocument
283283
(J.List diags) = params ^. J.context . J.diagnostics
284284
-- makeCommand only generates commands for diagnostics whose source is us
285-
makeCommand (J.Diagnostic (J.Range start _) _s _c (Just "lsp-hello") _m _t _l) = [J.Command title cmd cmdparams]
285+
makeCommand (J.Diagnostic (J.Range s _) _s _c (Just "lsp-hello") _m _t _l) = [J.Command title cmd cmdparams]
286286
where
287287
title = "Apply LSP hello command:" <> head (T.lines _m)
288288
-- NOTE: the cmd needs to be registered via the InitializeResponse message. See lspOptions above
289289
cmd = "lsp-hello-command"
290290
-- need 'file' and 'start_pos'
291291
args = J.List
292292
[ J.object [("file", J.object [("textDocument",J.toJSON doc)])]
293-
, J.object [("start_pos",J.object [("position", J.toJSON start)])]
293+
, J.object [("start_pos",J.object [("position", J.toJSON s)])]
294294
]
295295
cmdparams = Just args
296296
makeCommand (J.Diagnostic _r _s _c _source _m _t _l) = []

lsp/src/Language/LSP/VFS.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ module Language.LSP.VFS
4646

4747
-- * Positions and transformations
4848
, CodePointPosition (..)
49+
, line
50+
, character
4951
, codePointPositionToPosition
5052
, positionToCodePointPosition
5153
, CodePointRange (..)
54+
, start
55+
, end
5256
, codePointRangeToRange
5357
, rangeToCodePointRange
5458

@@ -80,7 +84,7 @@ import Data.Maybe
8084
import qualified Data.Text.Rope as URope
8185
import Data.Text.Utf16.Rope ( Rope )
8286
import qualified Data.Text.Utf16.Rope as Rope
83-
import Data.Text.Prettyprint.Doc
87+
import Data.Text.Prettyprint.Doc hiding (line)
8488
import qualified Language.LSP.Types as J
8589
import qualified Language.LSP.Types.Lens as J
8690
import System.FilePath
@@ -373,6 +377,9 @@ data CodePointRange =
373377
, _end :: CodePointPosition -- ^ The range's end position.
374378
} deriving (Show, Read, Eq, Ord)
375379

380+
makeFieldsNoPrefix ''CodePointPosition
381+
makeFieldsNoPrefix ''CodePointRange
382+
376383
{- Note [Converting between code points and code units]
377384
This is inherently a somewhat expensive operation, but we take some care to minimize the cost.
378385
In particular, we use the good asymptotics of 'Rope' to our advantage:

0 commit comments

Comments
 (0)