Skip to content

Commit d408b40

Browse files
committed
Merge remote-tracking branch 'upstream/master' into resolve-helper
2 parents a7425bf + cc33803 commit d408b40

File tree

14 files changed

+36
-21
lines changed

14 files changed

+36
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ main :: IO Int
7070
main = runServer $ ServerDefinition
7171
{ onConfigurationChange = const $ pure $ Right ()
7272
, doInitialize = \env _req -> pure $ Right env
73-
, staticHandlers = handlers
73+
, staticHandlers = \_caps -> handlers
7474
, interpretHandler = \env -> Iso (runLspT env) liftIO
7575
, options = defaultOptions
7676
}

lsp-test/bench/SimpleBench.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ server = ServerDefinition
3535
{ onConfigurationChange = const $ const $ Right ()
3636
, defaultConfig = ()
3737
, doInitialize = \env _req -> pure $ Right env
38-
, staticHandlers = handlers
38+
, staticHandlers = \_caps -> handlers
3939
, interpretHandler = \env -> Iso (runLspT env) liftIO
4040
, options = defaultOptions
4141
}

lsp-test/func-test/FuncTest.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ main = hspec $ do
3535
{ onConfigurationChange = const $ const $ Right ()
3636
, defaultConfig = ()
3737
, doInitialize = \env _req -> pure $ Right env
38-
, staticHandlers = handlers killVar
38+
, staticHandlers = \_caps -> handlers killVar
3939
, interpretHandler = \env -> Iso (runLspT env) liftIO
4040
, options = defaultOptions
4141
}
@@ -82,7 +82,7 @@ main = hspec $ do
8282
{ onConfigurationChange = const $ const $ Right ()
8383
, defaultConfig = ()
8484
, doInitialize = \env _req -> pure $ Right env
85-
, staticHandlers = handlers
85+
, staticHandlers = \_caps -> handlers
8686
, interpretHandler = \env -> Iso (runLspT env) liftIO
8787
, options = defaultOptions
8888
}

lsp-test/lsp-test.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.4
22
name: lsp-test
3-
version: 0.15.0.0
3+
version: 0.15.0.1
44
synopsis: Functional test framework for LSP servers.
55
description:
66
A test framework for writing tests against
@@ -59,7 +59,7 @@ library
5959
, filepath
6060
, Glob >=0.9 && <0.11
6161
, lens
62-
, lsp ^>=2.0
62+
, lsp ^>=2.1
6363
, lsp-types ^>=2.0
6464
, mtl <2.4
6565
, parser-combinators >=1.2
@@ -102,7 +102,7 @@ test-suite tests
102102
, filepath
103103
, hspec
104104
, lens
105-
, lsp ^>=2.0
105+
, lsp ^>=2.1
106106
, lsp-test
107107
, mtl <2.4
108108
, parser-combinators

lsp-test/test/DummyServer.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ withDummyServer f = do
3131
{ doInitialize = \env _req -> pure $ Right env
3232
, defaultConfig = ()
3333
, onConfigurationChange = const $ pure $ Right ()
34-
, staticHandlers = handlers
34+
, staticHandlers = \_caps -> handlers
3535
, interpretHandler = \env ->
3636
Iso (\m -> runLspT env (runReaderT m handlerEnv)) liftIO
3737
, options = defaultOptions {optExecuteCommandCommands = Just ["doAnEdit"]}

lsp-types/ChangeLog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Revision history for lsp-types
22

3-
## 2.0.0.2
3+
## 2.0.1.0
44

55
* Removed deprecation pragmas from fields, as these cannot currently be avoided.
6+
* Added `isOptionalMethod`, that checks whether a method is optional according to the spec.
67

78
## 2.0.0.1
89

lsp-types/lsp-types.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: lsp-types
3-
version: 2.0.0.2
3+
version: 2.0.1.0
44
synopsis:
55
Haskell library for the Microsoft Language Server Protocol, data types
66

lsp-types/src/Language/LSP/Protocol/Message/Method.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module Language.LSP.Protocol.Message.Method where
1414

1515
import Data.Aeson.Types
1616
import Data.Function (on)
17+
import Data.List (isPrefixOf)
1718
import Data.GADT.Compare
1819
import Data.Proxy
1920
import Data.Type.Equality
@@ -29,6 +30,11 @@ import Unsafe.Coerce
2930
-- SomeMethod
3031
---------------
3132

33+
-- | Is this an "optional" method which servers and clients are allowed to ignore?
34+
isOptionalMethod :: SomeMethod -> Bool
35+
-- See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#dollarRequests
36+
isOptionalMethod m = "$/" `isPrefixOf` someMethodToMethodString m
37+
3238
deriving stock instance Show SomeMethod
3339
instance Eq SomeMethod where
3440
(==) = (==) `on` someMethodToMethodString

lsp/ChangeLog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Revision history for lsp
22

3+
## 2.1.0.0
4+
5+
* Fix handling of optional methods.
6+
* `staticHandlers` now takes the client capabilities as an argument.
7+
These are static across the lifecycle of the server, so this allows
8+
a server to decide at construction e.g. whether to provide handlers
9+
for resolve methods depending on whether the client supports it.
10+
311
## 2.0.0.0
412

513
* Support `lsp-types-2.0.0.0`.

lsp/example/Reactor.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ run = flip E.catches handlers $ do
9696
J.Success cfg -> Right cfg
9797
, doInitialize = \env _ -> forkIO (reactor stderrLogger rin) >> pure (Right env)
9898
-- Handlers log to both the client and stderr
99-
, staticHandlers = lspHandlers dualLogger rin
99+
, staticHandlers = \_caps -> lspHandlers dualLogger rin
100100
, interpretHandler = \env -> Iso (runLspT env) liftIO
101101
, options = lspOptions
102102
}

0 commit comments

Comments
 (0)