2
2
{-# LANGUAGE DuplicateRecordFields #-}
3
3
{-# LANGUAGE OverloadedStrings #-}
4
4
5
+ {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
6
+
5
7
import Control.Monad.IO.Class (liftIO )
6
8
import Data.Maybe (fromJust )
7
9
import Language.LSP.Protocol.Types
8
- ( CompletionItem (.. )
10
+ ( ClientCapabilities
11
+ , CompletionItem (.. )
9
12
, Diagnostic (.. )
10
13
, DiagnosticSeverity (.. )
11
14
, Hover (.. )
@@ -14,25 +17,38 @@ import Language.LSP.Protocol.Types
14
17
, Range (.. )
15
18
, toEither
16
19
)
17
- import Language.LSP.Test
18
20
import Test.Tasty
19
21
import Test.Tasty.Hspec
20
22
23
+ #if MIN_VERSION_lsp_types(2,3,0)
24
+ import Language.LSP.Test hiding (fullLatestClientCaps )
25
+ #else
26
+ import Language.LSP.Test
27
+ #endif
28
+
21
29
#if MIN_VERSION_tasty_hspec(1,1,7)
22
30
import Test.Hspec
23
31
#endif
24
32
25
33
import qualified Data.Text as T
26
34
import qualified GHC.IO.Encoding
35
+ import qualified Language.LSP.Protocol.Capabilities
27
36
28
37
baseDir :: FilePath -> FilePath
29
38
baseDir d = " tests/fixtures/" <> d
30
39
40
+ fullLatestClientCaps :: ClientCapabilities
41
+ #if MIN_VERSION_lsp_types(2,3,0)
42
+ fullLatestClientCaps = Language.LSP.Protocol.Capabilities. fullLatestClientCaps
43
+ #else
44
+ fullLatestClientCaps = Language.LSP.Protocol.Capabilities. fullCaps
45
+ #endif
46
+
31
47
hoveringSpec :: FilePath -> Spec
32
48
hoveringSpec dir =
33
49
describe " Dhall.Hover"
34
50
$ it " reports types on hover"
35
- $ runSession " dhall-lsp-server" fullCaps dir
51
+ $ runSession " dhall-lsp-server" fullLatestClientCaps dir
36
52
$ do
37
53
docId <- openDoc " Types.dhall" " dhall"
38
54
let typePos = Position 0 5
@@ -53,7 +69,7 @@ lintingSpec :: FilePath -> Spec
53
69
lintingSpec fixtureDir =
54
70
describe " Dhall.Lint" $ do
55
71
it " reports unused bindings"
56
- $ runSession " dhall-lsp-server" fullCaps fixtureDir
72
+ $ runSession " dhall-lsp-server" fullLatestClientCaps fixtureDir
57
73
$ do
58
74
_ <- openDoc " UnusedBindings.dhall" " dhall"
59
75
@@ -92,7 +108,7 @@ lintingSpec fixtureDir =
92
108
93
109
pure ()
94
110
it " reports multiple hints"
95
- $ runSession " dhall-lsp-server" fullCaps fixtureDir
111
+ $ runSession " dhall-lsp-server" fullLatestClientCaps fixtureDir
96
112
$ do
97
113
_ <- openDoc " SuperfluousIn.dhall" " dhall"
98
114
diags <- waitForDiagnosticsSource " Dhall.Lint"
@@ -109,7 +125,7 @@ codeCompletionSpec :: FilePath -> Spec
109
125
codeCompletionSpec fixtureDir =
110
126
describe " Dhall.Completion" $ do
111
127
it " suggests user defined types"
112
- $ runSession " dhall-lsp-server" fullCaps fixtureDir
128
+ $ runSession " dhall-lsp-server" fullLatestClientCaps fixtureDir
113
129
$ do
114
130
docId <- openDoc " CustomTypes.dhall" " dhall"
115
131
cs <- getCompletions docId (Position {_line = 2 , _character = 35 })
@@ -118,7 +134,7 @@ codeCompletionSpec fixtureDir =
118
134
_label firstItem `shouldBe` " Config"
119
135
_detail firstItem `shouldBe` Just " Type"
120
136
it " suggests user defined functions"
121
- $ runSession " dhall-lsp-server" fullCaps fixtureDir
137
+ $ runSession " dhall-lsp-server" fullLatestClientCaps fixtureDir
122
138
$ do
123
139
docId <- openDoc " CustomFunctions.dhall" " dhall"
124
140
cs <- getCompletions docId (Position {_line = 6 , _character = 7 })
@@ -127,7 +143,7 @@ codeCompletionSpec fixtureDir =
127
143
_label firstItem `shouldBe` " makeUser"
128
144
_detail firstItem `shouldBe` Just " \8704(user : Text) \8594 { home : Text }"
129
145
it " suggests user defined bindings"
130
- $ runSession " dhall-lsp-server" fullCaps fixtureDir
146
+ $ runSession " dhall-lsp-server" fullLatestClientCaps fixtureDir
131
147
$ do
132
148
docId <- openDoc " Bindings.dhall" " dhall"
133
149
cs <- getCompletions docId (Position {_line = 0 , _character = 59 })
@@ -136,7 +152,7 @@ codeCompletionSpec fixtureDir =
136
152
_label firstItem `shouldBe` " bob"
137
153
_detail firstItem `shouldBe` Just " Text"
138
154
it " suggests functions from imports"
139
- $ runSession " dhall-lsp-server" fullCaps fixtureDir
155
+ $ runSession " dhall-lsp-server" fullLatestClientCaps fixtureDir
140
156
$ do
141
157
docId <- openDoc " ImportedFunctions.dhall" " dhall"
142
158
cs <- getCompletions docId (Position {_line = 0 , _character = 33 })
@@ -147,7 +163,7 @@ codeCompletionSpec fixtureDir =
147
163
_detail firstItem `shouldBe` Just " \8704(user : Text) \8594 { home : Text }"
148
164
_detail secondItem `shouldBe` Just " \8704(user : Text) \8594 { home : Text }"
149
165
it " suggests union alternatives"
150
- $ runSession " dhall-lsp-server" fullCaps fixtureDir
166
+ $ runSession " dhall-lsp-server" fullLatestClientCaps fixtureDir
151
167
$ do
152
168
docId <- openDoc " Union.dhall" " dhall"
153
169
cs <- getCompletions docId (Position {_line = 2 , _character = 10 })
@@ -162,15 +178,15 @@ diagnosticsSpec :: FilePath -> Spec
162
178
diagnosticsSpec fixtureDir = do
163
179
describe " Dhall.TypeCheck" $ do
164
180
it " reports unbound variables"
165
- $ runSession " dhall-lsp-server" fullCaps fixtureDir
181
+ $ runSession " dhall-lsp-server" fullLatestClientCaps fixtureDir
166
182
$ do
167
183
_ <- openDoc " UnboundVar.dhall" " dhall"
168
184
[diag] <- waitForDiagnosticsSource " Dhall.TypeCheck"
169
185
liftIO $ do
170
186
_severity diag `shouldBe` Just DiagnosticSeverity_Error
171
187
T. unpack (_message diag) `shouldContain` " Unbound variable"
172
188
it " reports wrong type"
173
- $ runSession " dhall-lsp-server" fullCaps fixtureDir
189
+ $ runSession " dhall-lsp-server" fullLatestClientCaps fixtureDir
174
190
$ do
175
191
_ <- openDoc " WrongType.dhall" " dhall"
176
192
[diag] <- waitForDiagnosticsSource " Dhall.TypeCheck"
@@ -179,15 +195,15 @@ diagnosticsSpec fixtureDir = do
179
195
T. unpack (_message diag) `shouldContain` " Expression doesn't match annotation"
180
196
describe " Dhall.Import" $ do
181
197
it " reports invalid imports"
182
- $ runSession " dhall-lsp-server" fullCaps fixtureDir
198
+ $ runSession " dhall-lsp-server" fullLatestClientCaps fixtureDir
183
199
$ do
184
200
_ <- openDoc " InvalidImport.dhall" " dhall"
185
201
[diag] <- waitForDiagnosticsSource " Dhall.Import"
186
202
liftIO $ do
187
203
_severity diag `shouldBe` Just DiagnosticSeverity_Error
188
204
T. unpack (_message diag) `shouldContain` " Invalid input"
189
205
it " reports missing imports"
190
- $ runSession " dhall-lsp-server" fullCaps fixtureDir
206
+ $ runSession " dhall-lsp-server" fullLatestClientCaps fixtureDir
191
207
$ do
192
208
_ <- openDoc " MissingImport.dhall" " dhall"
193
209
[diag] <- waitForDiagnosticsSource " Dhall.Import"
@@ -196,7 +212,7 @@ diagnosticsSpec fixtureDir = do
196
212
T. unpack (_message diag) `shouldContain` " Missing file"
197
213
describe " Dhall.Parser"
198
214
$ it " reports invalid syntax"
199
- $ runSession " dhall-lsp-server" fullCaps fixtureDir
215
+ $ runSession " dhall-lsp-server" fullLatestClientCaps fixtureDir
200
216
$ do
201
217
_ <- openDoc " InvalidSyntax.dhall" " dhall"
202
218
[diag] <- waitForDiagnosticsSource " Dhall.Parser"
0 commit comments