Skip to content

Commit e11b7c0

Browse files
authored
Merge pull request #454 from codedownio/maybe-register-options
spec compliance: _registerOptions should be a Maybe
2 parents 596376a + 10b981a commit e11b7c0

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

lsp-test/src/Language/LSP/Test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ createDoc file languageId contents = do
430430
createHits (WatchKind create _ _) = create
431431

432432
regHits :: Registration WorkspaceDidChangeWatchedFiles -> Bool
433-
regHits reg = foldl' (\acc w -> acc || watchHits w) False (reg ^. registerOptions . watchers)
433+
regHits reg = foldl' (\acc w -> acc || watchHits w) False (reg ^. registerOptions . _Just . watchers)
434434

435435
clientCapsSupports =
436436
caps ^? workspace . _Just . didChangeWatchedFiles . _Just . dynamicRegistration . _Just

lsp-test/test/Test.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ main = hspec $ around withDummyServer $ do
370370
liftIO $ do
371371
case regMethod `mEqClient` SWorkspaceDidChangeWatchedFiles of
372372
Just (Right HRefl) ->
373-
regOpts `shouldBe` (DidChangeWatchedFilesRegistrationOptions $ List
374-
[ FileSystemWatcher "*.watch" (Just (WatchKind True True True)) ])
373+
regOpts `shouldBe` (Just (DidChangeWatchedFilesRegistrationOptions $ List
374+
[ FileSystemWatcher "*.watch" (Just (WatchKind True True True)) ]))
375375
_ -> expectationFailure "Registration wasn't on workspace/didChangeWatchedFiles"
376376

377377
-- now unregister it by sending a specific createDoc

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ data Registration (m :: Method FromClient t) =
111111
, _method :: SClientMethod m
112112
-- | Options necessary for the registration.
113113
-- Make this strict to aid the pattern matching exhaustiveness checker
114-
, _registerOptions :: !(RegistrationOptions m)
114+
, _registerOptions :: !(Maybe (RegistrationOptions m))
115115
}
116116
deriving Generic
117117

lsp-types/test/ServerCapabilitiesSpec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ spec = describe "server capabilities" $ do
3434
Just registrationParams = decode input :: Maybe RegistrationParams
3535
in registrationParams ^. registrations `shouldBe`
3636
List [SomeRegistration $ Registration "4a56f5ca-7188-4f4c-a366-652d6f9d63aa"
37-
SWorkspaceDidChangeConfiguration Empty]
37+
SWorkspaceDidChangeConfiguration (Just Empty)]
3838
where
3939
documentFilters = List [DocumentFilter (Just "haskell") Nothing Nothing]
4040
documentFiltersJson = "[{\"language\": \"haskell\"}]"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ registerCapability method regOpts f = do
503503
-- First, check to see if the client supports dynamic registration on this method
504504
| dynamicSupported clientCaps = do
505505
uuid <- liftIO $ UUID.toText <$> getStdRandom random
506-
let registration = J.Registration uuid method regOpts
506+
let registration = J.Registration uuid method (Just regOpts)
507507
params = J.RegistrationParams (J.List [J.SomeRegistration registration])
508508
regId = RegistrationId uuid
509509
rio <- askUnliftIO

0 commit comments

Comments
 (0)