Skip to content

Commit 6327e0f

Browse files
authored
Use our normal auto-incrementing ids instead of UUIDs (#578)
* Use our normal auto-incrementing ids instead of UUIDs The spec just says they have to be unique IDs, not UUIDs, and we already have a tool for generating such things. * Remove random too
1 parent c15fa82 commit 6327e0f

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

lsp/lsp.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ library
7171
, lsp-types ^>=2.2
7272
, mtl >=2.2 && <2.4
7373
, prettyprinter ^>=1.7
74-
, random ^>=1.2
7574
, sorted-list ^>=0.2.1
7675
, stm ^>=2.5
7776
, text >=1 && <2.2
@@ -80,7 +79,6 @@ library
8079
, unliftio ^>=0.2
8180
, unliftio-core ^>=0.2
8281
, unordered-containers ^>=0.2
83-
, uuid >=1.3
8482

8583
executable lsp-demo-reactor-server
8684
import: warnings

lsp/src/Language/LSP/Server/Core.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import Data.Monoid (Ap (..))
4848
import Data.Ord (Down (Down))
4949
import Data.Text (Text)
5050
import Data.Text qualified as T
51-
import Data.UUID qualified as UUID
5251
import Language.LSP.Diagnostics
5352
import Language.LSP.Protocol.Capabilities
5453
import Language.LSP.Protocol.Lens qualified as L
@@ -61,7 +60,6 @@ import Language.LSP.Protocol.Utils.SMethodMap (SMethodMap)
6160
import Language.LSP.Protocol.Utils.SMethodMap qualified as SMethodMap
6261
import Language.LSP.VFS hiding (end)
6362
import Prettyprinter
64-
import System.Random hiding (next)
6563

6664
-- ---------------------------------------------------------------------
6765
{-# ANN module ("HLint: ignore Eta reduce" :: String) #-}
@@ -590,10 +588,10 @@ trySendRegistration logger method regOpts = do
590588
-- First, check to see if the client supports dynamic registration on this method
591589
if dynamicRegistrationSupported method clientCaps
592590
then do
593-
uuid <- liftIO $ UUID.toText <$> getStdRandom random
594-
let registration = L.TRegistration uuid method (Just regOpts)
591+
rid <- T.pack . show <$> freshLspId
592+
let registration = L.TRegistration rid method (Just regOpts)
595593
params = L.RegistrationParams [toUntypedRegistration registration]
596-
regId = RegistrationId uuid
594+
regId = RegistrationId rid
597595

598596
-- TODO: handle the scenario where this returns an error
599597
_ <- sendRequest SMethod_ClientRegisterCapability params $ \_res -> pure ()

0 commit comments

Comments
 (0)