Skip to content

Commit a621e14

Browse files
authored
Bumped LSP dependencies of dhall-lsp-server package (#2634)
The following additional versions are allowed now: - lsp >=2.2 && <2.8 - lsp-types >=2.1 && <2.4 - lsp-test >=0.16 && <0.18
1 parent 529dc40 commit a621e14

File tree

4 files changed

+56
-19
lines changed

4 files changed

+56
-19
lines changed

dhall-lsp-server/dhall-lsp-server.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ library
5353
, dhall >= 1.38.0 && < 1.43
5454
, dhall-json >= 1.4 && < 1.8
5555
, filepath >= 1.4.2 && < 1.6
56-
, lsp >= 2.1.0.0 && < 2.2
56+
, lsp >= 2.1.0.0 && < 2.8
5757
, lens >= 4.16.1 && < 5.4
5858
-- megaparsec follows SemVer: https://github.com/mrkkrp/megaparsec/issues/469#issuecomment-927918469
5959
, megaparsec >= 7.0.2 && < 10
@@ -104,9 +104,9 @@ Test-Suite tests
104104
GHC-Options: -Wall
105105
Build-Depends:
106106
base >= 4.11 && < 5 ,
107-
lsp-types >= 2.0.1 && < 2.1 ,
107+
lsp-types >= 2.0.1 && < 2.4 ,
108108
hspec >= 2.7 && < 2.12,
109-
lsp-test >= 0.15.0.0 && < 0.16,
109+
lsp-test >= 0.15.0.0 && < 0.18,
110110
tasty >= 0.11.2 && < 1.6 ,
111111
tasty-hspec >= 1.1 && < 1.3 ,
112112
text >= 0.11 && < 2.2

dhall-lsp-server/src/Dhall/LSP/Handlers.hs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,18 @@ import Text.Megaparsec (SourcePos (..), unPos)
9191
import qualified Data.Aeson as Aeson
9292
import qualified Data.Map.Strict as Map
9393
import qualified Data.Text as Text
94-
import qualified Data.Text.Utf16.Rope as Rope
9594
import qualified Language.LSP.Protocol.Types as LSP.Types
9695
import qualified Language.LSP.Server as LSP
9796
import qualified Language.LSP.VFS as LSP
9897
import qualified Network.URI as URI
9998
import qualified Network.URI.Encode as URI
10099

100+
#if MIN_VERSION_lsp(2,4,0)
101+
import qualified Data.Text.Utf16.Rope.Mixed as Rope
102+
#else
103+
import qualified Data.Text.Utf16.Rope as Rope
104+
#endif
105+
101106
liftLSP :: LspT ServerConfig IO a -> HandlerM a
102107
liftLSP m = lift (lift m)
103108

@@ -226,15 +231,23 @@ documentLinkHandler =
226231
filePath <- localToPath prefix file
227232
let filePath' = basePath </> filePath -- absolute file path
228233
let _range = rangeToJSON range_
234+
#if MIN_VERSION_lsp(2,5,0)
235+
let _target = Just (filePathToUri filePath')
236+
#else
229237
let _target = Just (getUri (filePathToUri filePath'))
238+
#endif
230239
let _tooltip = Nothing
231240
let _data_ = Nothing
232241
return [DocumentLink {..}]
233242

234243
go (range_, Import (ImportHashed _ (Remote url)) _) = do
235244
let _range = rangeToJSON range_
236245
let url' = url { headers = Nothing }
246+
#if MIN_VERSION_lsp(2,5,0)
247+
let _target = Just (Uri (pretty url'))
248+
#else
237249
let _target = Just (pretty url')
250+
#endif
238251
let _tooltip = Nothing
239252
let _data_ = Nothing
240253
return [DocumentLink {..}]

dhall-lsp-server/src/Dhall/LSP/Server.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,15 @@ runWith settings = withLogger $ \ioLogger -> do
6767

6868
let defaultConfig = def
6969

70+
#if MIN_VERSION_lsp(2,2,0)
71+
let configSection = "dhall"
72+
73+
let onConfigChange _newConfig = return ()
74+
75+
let parseConfig _oldConfig json =
76+
#else
7077
let onConfigurationChange _oldConfig json =
78+
#endif
7179
case fromJSON json of
7280
Aeson.Success config -> Right config
7381
Aeson.Error string -> Left (Text.pack string)

dhall-lsp-server/tests/Main.hs

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
{-# LANGUAGE DuplicateRecordFields #-}
33
{-# LANGUAGE OverloadedStrings #-}
44

5+
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
6+
57
import Control.Monad.IO.Class (liftIO)
68
import Data.Maybe (fromJust)
79
import Language.LSP.Protocol.Types
8-
( CompletionItem (..)
10+
( ClientCapabilities
11+
, CompletionItem (..)
912
, Diagnostic (..)
1013
, DiagnosticSeverity (..)
1114
, Hover (..)
@@ -14,25 +17,38 @@ import Language.LSP.Protocol.Types
1417
, Range (..)
1518
, toEither
1619
)
17-
import Language.LSP.Test
1820
import Test.Tasty
1921
import Test.Tasty.Hspec
2022

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+
2129
#if MIN_VERSION_tasty_hspec(1,1,7)
2230
import Test.Hspec
2331
#endif
2432

2533
import qualified Data.Text as T
2634
import qualified GHC.IO.Encoding
35+
import qualified Language.LSP.Protocol.Capabilities
2736

2837
baseDir :: FilePath -> FilePath
2938
baseDir d = "tests/fixtures/" <> d
3039

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+
3147
hoveringSpec :: FilePath -> Spec
3248
hoveringSpec dir =
3349
describe "Dhall.Hover"
3450
$ it "reports types on hover"
35-
$ runSession "dhall-lsp-server" fullCaps dir
51+
$ runSession "dhall-lsp-server" fullLatestClientCaps dir
3652
$ do
3753
docId <- openDoc "Types.dhall" "dhall"
3854
let typePos = Position 0 5
@@ -53,7 +69,7 @@ lintingSpec :: FilePath -> Spec
5369
lintingSpec fixtureDir =
5470
describe "Dhall.Lint" $ do
5571
it "reports unused bindings"
56-
$ runSession "dhall-lsp-server" fullCaps fixtureDir
72+
$ runSession "dhall-lsp-server" fullLatestClientCaps fixtureDir
5773
$ do
5874
_ <- openDoc "UnusedBindings.dhall" "dhall"
5975

@@ -92,7 +108,7 @@ lintingSpec fixtureDir =
92108

93109
pure ()
94110
it "reports multiple hints"
95-
$ runSession "dhall-lsp-server" fullCaps fixtureDir
111+
$ runSession "dhall-lsp-server" fullLatestClientCaps fixtureDir
96112
$ do
97113
_ <- openDoc "SuperfluousIn.dhall" "dhall"
98114
diags <- waitForDiagnosticsSource "Dhall.Lint"
@@ -109,7 +125,7 @@ codeCompletionSpec :: FilePath -> Spec
109125
codeCompletionSpec fixtureDir =
110126
describe "Dhall.Completion" $ do
111127
it "suggests user defined types"
112-
$ runSession "dhall-lsp-server" fullCaps fixtureDir
128+
$ runSession "dhall-lsp-server" fullLatestClientCaps fixtureDir
113129
$ do
114130
docId <- openDoc "CustomTypes.dhall" "dhall"
115131
cs <- getCompletions docId (Position {_line = 2, _character = 35})
@@ -118,7 +134,7 @@ codeCompletionSpec fixtureDir =
118134
_label firstItem `shouldBe` "Config"
119135
_detail firstItem `shouldBe` Just "Type"
120136
it "suggests user defined functions"
121-
$ runSession "dhall-lsp-server" fullCaps fixtureDir
137+
$ runSession "dhall-lsp-server" fullLatestClientCaps fixtureDir
122138
$ do
123139
docId <- openDoc "CustomFunctions.dhall" "dhall"
124140
cs <- getCompletions docId (Position {_line = 6, _character = 7})
@@ -127,7 +143,7 @@ codeCompletionSpec fixtureDir =
127143
_label firstItem `shouldBe` "makeUser"
128144
_detail firstItem `shouldBe` Just "\8704(user : Text) \8594 { home : Text }"
129145
it "suggests user defined bindings"
130-
$ runSession "dhall-lsp-server" fullCaps fixtureDir
146+
$ runSession "dhall-lsp-server" fullLatestClientCaps fixtureDir
131147
$ do
132148
docId <- openDoc "Bindings.dhall" "dhall"
133149
cs <- getCompletions docId (Position {_line = 0, _character = 59})
@@ -136,7 +152,7 @@ codeCompletionSpec fixtureDir =
136152
_label firstItem `shouldBe` "bob"
137153
_detail firstItem `shouldBe` Just "Text"
138154
it "suggests functions from imports"
139-
$ runSession "dhall-lsp-server" fullCaps fixtureDir
155+
$ runSession "dhall-lsp-server" fullLatestClientCaps fixtureDir
140156
$ do
141157
docId <- openDoc "ImportedFunctions.dhall" "dhall"
142158
cs <- getCompletions docId (Position {_line = 0, _character = 33})
@@ -147,7 +163,7 @@ codeCompletionSpec fixtureDir =
147163
_detail firstItem `shouldBe` Just "\8704(user : Text) \8594 { home : Text }"
148164
_detail secondItem `shouldBe` Just "\8704(user : Text) \8594 { home : Text }"
149165
it "suggests union alternatives"
150-
$ runSession "dhall-lsp-server" fullCaps fixtureDir
166+
$ runSession "dhall-lsp-server" fullLatestClientCaps fixtureDir
151167
$ do
152168
docId <- openDoc "Union.dhall" "dhall"
153169
cs <- getCompletions docId (Position {_line = 2, _character = 10})
@@ -162,15 +178,15 @@ diagnosticsSpec :: FilePath -> Spec
162178
diagnosticsSpec fixtureDir = do
163179
describe "Dhall.TypeCheck" $ do
164180
it "reports unbound variables"
165-
$ runSession "dhall-lsp-server" fullCaps fixtureDir
181+
$ runSession "dhall-lsp-server" fullLatestClientCaps fixtureDir
166182
$ do
167183
_ <- openDoc "UnboundVar.dhall" "dhall"
168184
[diag] <- waitForDiagnosticsSource "Dhall.TypeCheck"
169185
liftIO $ do
170186
_severity diag `shouldBe` Just DiagnosticSeverity_Error
171187
T.unpack (_message diag) `shouldContain` "Unbound variable"
172188
it "reports wrong type"
173-
$ runSession "dhall-lsp-server" fullCaps fixtureDir
189+
$ runSession "dhall-lsp-server" fullLatestClientCaps fixtureDir
174190
$ do
175191
_ <- openDoc "WrongType.dhall" "dhall"
176192
[diag] <- waitForDiagnosticsSource "Dhall.TypeCheck"
@@ -179,15 +195,15 @@ diagnosticsSpec fixtureDir = do
179195
T.unpack (_message diag) `shouldContain` "Expression doesn't match annotation"
180196
describe "Dhall.Import" $ do
181197
it "reports invalid imports"
182-
$ runSession "dhall-lsp-server" fullCaps fixtureDir
198+
$ runSession "dhall-lsp-server" fullLatestClientCaps fixtureDir
183199
$ do
184200
_ <- openDoc "InvalidImport.dhall" "dhall"
185201
[diag] <- waitForDiagnosticsSource "Dhall.Import"
186202
liftIO $ do
187203
_severity diag `shouldBe` Just DiagnosticSeverity_Error
188204
T.unpack (_message diag) `shouldContain` "Invalid input"
189205
it "reports missing imports"
190-
$ runSession "dhall-lsp-server" fullCaps fixtureDir
206+
$ runSession "dhall-lsp-server" fullLatestClientCaps fixtureDir
191207
$ do
192208
_ <- openDoc "MissingImport.dhall" "dhall"
193209
[diag] <- waitForDiagnosticsSource "Dhall.Import"
@@ -196,7 +212,7 @@ diagnosticsSpec fixtureDir = do
196212
T.unpack (_message diag) `shouldContain` "Missing file"
197213
describe "Dhall.Parser"
198214
$ it "reports invalid syntax"
199-
$ runSession "dhall-lsp-server" fullCaps fixtureDir
215+
$ runSession "dhall-lsp-server" fullLatestClientCaps fixtureDir
200216
$ do
201217
_ <- openDoc "InvalidSyntax.dhall" "dhall"
202218
[diag] <- waitForDiagnosticsSource "Dhall.Parser"

0 commit comments

Comments
 (0)