Skip to content

Commit fb8363a

Browse files
authored
Mappings for capabilities (#581)
* Add golden tests for client cap generation * Add mappings for capabilities * Fix commment
1 parent 89799f7 commit fb8363a

File tree

15 files changed

+1416
-333
lines changed

15 files changed

+1416
-333
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ hie
2020
.hie
2121
hie.yaml
2222
.envrc
23+
**/.golden/*/actual

lsp-test/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and [lsp-types](https://hackage.haskell.org/package/lsp-types)
88

99
```haskell
1010
import Language.LSP.Test
11-
main = runSession "hie" fullCaps "proj/dir" $ do
11+
main = runSession "hie" fullLatestClientCaps "proj/dir" $ do
1212
doc <- openDoc "Foo.hs" "haskell"
1313
skipMany anyNotification
1414
symbols <- getDocumentSymbols doc
@@ -19,7 +19,7 @@ main = runSession "hie" fullCaps "proj/dir" $ do
1919
### Unit tests with HSpec
2020
```haskell
2121
describe "diagnostics" $
22-
it "report errors" $ runSession "hie" fullCaps "test/data" $ do
22+
it "report errors" $ runSession "hie" fullLatestClientCaps "test/data" $ do
2323
openDoc "Error.hs" "haskell"
2424
[diag] <- waitForDiagnosticsSource "ghcmod"
2525
liftIO $ do

lsp-test/bench/SimpleBench.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ main = do
5656

5757
i <- newIORef (0 :: Integer)
5858

59-
Test.runSessionWithHandles hinWrite houtRead Test.defaultConfig Test.fullCaps "." $ do
59+
Test.runSessionWithHandles hinWrite houtRead Test.defaultConfig Test.fullLatestClientCaps "." $ do
6060
start <- liftIO offsetTime
6161
replicateM_ n $ do
6262
v <- liftIO $ readIORef i

lsp-test/example/Test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Language.LSP.Protocol.Types
77
import Language.LSP.Test
88

99
main :: IO ()
10-
main = runSession "lsp-demo-reactor-server" fullCaps "test/data/" $ do
10+
main = runSession "lsp-demo-reactor-server" fullLatestClientCaps "test/data/" $ do
1111
doc <- openDoc "Rename.hs" "haskell"
1212

1313
-- Use your favourite favourite combinators.

lsp-test/func-test/FuncTest.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ spec = do
8383
updater $ ProgressAmount (Just 75) (Just "step3")
8484
liftIO $ waitBarrier b3
8585

86-
runSessionWithServer logger definition Test.defaultConfig Test.fullCaps "." $ do
86+
runSessionWithServer logger definition Test.defaultConfig Test.fullLatestClientCaps "." $ do
8787
Test.sendRequest (SMethod_CustomMethod (Proxy @"something")) J.Null
8888

8989
-- Wait until we have seen a begin messsage. This means that the token setup
@@ -144,7 +144,7 @@ spec = do
144144
-- Wait around to be cancelled, set the MVar only if we are
145145
liftIO $ threadDelay (5 * 1000000) `Control.Exception.catch` (\(e :: ProgressCancelledException) -> modifyMVar_ wasCancelled (\_ -> pure True))
146146

147-
runSessionWithServer logger definition Test.defaultConfig Test.fullCaps "." $ do
147+
runSessionWithServer logger definition Test.defaultConfig Test.fullLatestClientCaps "." $ do
148148
Test.sendRequest (SMethod_CustomMethod (Proxy @"something")) J.Null
149149

150150
-- Wait until we have created the progress so the updates will be sent individually
@@ -190,7 +190,7 @@ spec = do
190190
takeMVar killVar
191191
Control.Exception.throwIO AsyncCancelled
192192

193-
runSessionWithServer logger definition Test.defaultConfig Test.fullCaps "." $ do
193+
runSessionWithServer logger definition Test.defaultConfig Test.fullLatestClientCaps "." $ do
194194
-- First make sure that we get a $/progress begin notification
195195
skipManyTill Test.anyMessage $ do
196196
x <- Test.message SMethod_Progress
@@ -235,7 +235,7 @@ spec = do
235235
updater $ ProgressAmount (Just 75) (Just "step3")
236236
liftIO $ waitBarrier b3
237237

238-
runSessionWithServer logger definition Test.defaultConfig Test.fullCaps "." $ do
238+
runSessionWithServer logger definition Test.defaultConfig Test.fullLatestClientCaps "." $ do
239239
Test.sendRequest SMethod_TextDocumentCodeLens (CodeLensParams (Just $ ProgressToken $ InR "hello") Nothing (TextDocumentIdentifier $ Uri "."))
240240

241241
-- First make sure that we get a $/progress begin notification
@@ -318,7 +318,7 @@ spec = do
318318
ps = DidChangeWorkspaceFoldersParams ev
319319
in Test.sendNotification SMethod_WorkspaceDidChangeWorkspaceFolders ps
320320

321-
runSessionWithServer logger definition config Test.fullCaps "." $ do
321+
runSessionWithServer logger definition config Test.fullLatestClientCaps "." $ do
322322
changeFolders [wf1] []
323323
changeFolders [wf2] [wf1]
324324

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module Language.LSP.Test (
3030
-- ** Config
3131
SessionConfig (..),
3232
defaultConfig,
33-
C.fullCaps,
33+
C.fullLatestClientCaps,
3434

3535
-- ** Exceptions
3636
module Language.LSP.Test.Exceptions,
@@ -181,7 +181,7 @@ import System.Process (CreateProcess, ProcessHandle)
181181

182182
{- | Starts a new session.
183183
184-
> runSession "hie" fullCaps "path/to/root/dir" $ do
184+
> runSession "hie" fullLatestClientCaps "path/to/root/dir" $ do
185185
> doc <- openDoc "Desktop/simple.hs" "haskell"
186186
> diags <- waitForDiagnostics
187187
> let pos = Position 12 5
@@ -243,7 +243,7 @@ runSessionWithConfigCustomProcess modifyCreateProcess config' serverExe caps roo
243243
> (houtRead, houtWrite) <- createPipe
244244
>
245245
> forkIO $ void $ runServerWithHandles hinRead houtWrite serverDefinition
246-
> runSessionWithHandles hinWrite houtRead defaultConfig fullCaps "." $ do
246+
> runSessionWithHandles hinWrite houtRead defaultConfig fullLatestClientCaps "." $ do
247247
> -- ...
248248
-}
249249
runSessionWithHandles ::

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ replaySession serverExe sessionDir = do
6767
runSessionWithHandles serverIn serverOut serverProc
6868
(listenServer serverMsgs requestMap reqSema rspSema passSema mainThread)
6969
def
70-
fullCaps
70+
fullLatestClientCaps
7171
sessionDir
7272
(return ()) -- No finalizer cleanup
7373
(sendMessages clientMsgs reqSema rspSema)

0 commit comments

Comments
 (0)