Skip to content

Commit 0cb5bf9

Browse files
committed
Bump lsp versions
Broadly: - A few places where we need to pipe `ProgressToken`s around. - I also just removed the progress reporting from resolve commands, since it's going to often be costly to do progress reporting on something that short. Possibly we could revisit after haskell/lsp#549 - Some changes to the registration options we infer - A few places where we need to adapt to ignoring registrations or not - Adapting to use the ghcide verison of `getCompletionPrefix` everywhere - Adapting to use the new mixed rope format
1 parent b91c907 commit 0cb5bf9

File tree

42 files changed

+153
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+153
-151
lines changed

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ packages:
99
./hls-plugin-api
1010
./hls-test-utils
1111

12-
index-state: 2024-01-21T00:00:00Z
12+
index-state: 2024-02-25T00:00:00Z
1313

1414
tests: True
1515
test-show-details: direct

ghcide-bench/ghcide-bench.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ test-suite test
9999
base,
100100
extra,
101101
ghcide-bench,
102-
lsp-test ^>= 0.16,
102+
lsp-test ^>= 0.17,
103103
tasty,
104104
tasty-hunit >= 0.10,
105105
tasty-rerun,

ghcide/ghcide.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ library
9090
, implicit-hie >= 0.1.4.0 && < 0.1.5
9191
, lens
9292
, list-t
93-
, lsp ^>=2.3.0.0
93+
, lsp ^>=2.4.0.0
9494
, lsp-types ^>=2.1.0.0
9595
, mtl
9696
, opentelemetry >=0.6.1
@@ -180,6 +180,7 @@ library
180180
Development.IDE.Plugin
181181
Development.IDE.Plugin.Completions
182182
Development.IDE.Plugin.Completions.Types
183+
Development.IDE.Plugin.Completions.Logic
183184
Development.IDE.Plugin.HLS
184185
Development.IDE.Plugin.HLS.GhcIde
185186
Development.IDE.Plugin.Test
@@ -207,7 +208,6 @@ library
207208
Development.IDE.Core.FileExists
208209
Development.IDE.GHC.CPP
209210
Development.IDE.GHC.Warnings
210-
Development.IDE.Plugin.Completions.Logic
211211
Development.IDE.Session.VersionCheck
212212
Development.IDE.Types.Action
213213

@@ -326,7 +326,7 @@ test-suite ghcide-tests
326326
, lens
327327
, list-t
328328
, lsp
329-
, lsp-test ^>=0.16.0.0
329+
, lsp-test ^>=0.17.0.0
330330
, lsp-types
331331
, monoid-subclasses
332332
, mtl

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} dir = do
635635
-- Display a user friendly progress message here: They probably don't know what a cradle is
636636
let progMsg = "Setting up " <> T.pack (takeBaseName (cradleRootDir cradle))
637637
<> " (for " <> T.pack lfp <> ")"
638-
eopts <- mRunLspTCallback lspEnv (withIndefiniteProgress progMsg NotCancellable) $
638+
eopts <- mRunLspTCallback lspEnv (\act -> withIndefiniteProgress progMsg Nothing NotCancellable (const act)) $
639639
withTrace "Load cradle" $ \addTag -> do
640640
addTag "file" lfp
641641
old_files <- readIORef cradle_files

ghcide/src/Development/IDE/Core/FileStore.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ getFileContentsImpl file = do
183183
time <- use_ GetModificationTime file
184184
res <- do
185185
mbVirtual <- getVirtualFile file
186-
pure $ Rope.toText . _file_text <$> mbVirtual
186+
pure $ virtualFileText <$> mbVirtual
187187
pure ([], Just (time, res))
188188

189189
-- | Returns the modification time and the contents.

ghcide/src/Development/IDE/Core/Rules.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ persistentHieFileRule recorder = addPersistentRule GetHieAst $ \file -> runMaybe
575575
vfsData <- liftIO $ _vfsMap <$> readTVarIO vfsRef
576576
(currentSource, ver) <- liftIO $ case M.lookup (filePathToUri' file) vfsData of
577577
Nothing -> (,Nothing) . T.decodeUtf8 <$> BS.readFile (fromNormalizedFilePath file)
578-
Just vf -> pure (Rope.toText $ _file_text vf, Just $ _lsp_version vf)
578+
Just vf -> pure (virtualFileText vf, Just $ virtualFileVersion vf)
579579
let refmap = Compat.generateReferencesMap . Compat.getAsts . Compat.hie_asts $ res
580580
del = deltaFromDiff (T.decodeUtf8 $ Compat.hie_hs_src res) currentSource
581581
pure (HAR (Compat.hie_module res) (Compat.hie_asts res) refmap mempty (HieFromDisk res),del,ver)

ghcide/src/Development/IDE/Plugin/Completions/Logic.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import qualified Language.LSP.VFS as VFS
6262
import Text.Fuzzy.Parallel (Scored (score),
6363
original)
6464

65-
import qualified Data.Text.Utf16.Rope as Rope
65+
import qualified Data.Text.Utf16.Rope.Mixed as Rope
6666
import Development.IDE hiding (line)
6767

6868
import Development.IDE.Spans.AtPoint (pointCommand)

ghcide/src/Development/IDE/Plugin/HLS.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ executeCommandHandlers recorder ecs = requestHandler SMethod_WorkspaceExecuteCom
177177

178178
-- The parameters to the HLS command are always the first element
179179
execCmd :: IdeState -> ExecuteCommandParams -> LSP.LspT Config IO (Either ResponseError (A.Value |? Null))
180-
execCmd ide (ExecuteCommandParams _ cmdId args) = do
180+
execCmd ide (ExecuteCommandParams mtoken cmdId args) = do
181181
let cmdParams :: A.Value
182182
cmdParams = case args of
183183
Just ((x:_)) -> x
@@ -201,23 +201,23 @@ executeCommandHandlers recorder ecs = requestHandler SMethod_WorkspaceExecuteCom
201201
A.Error _str -> return $ Right $ InR Null
202202

203203
-- Just an ordinary HIE command
204-
Just (plugin, cmd) -> runPluginCommand ide plugin cmd cmdParams
204+
Just (plugin, cmd) -> runPluginCommand ide plugin cmd mtoken cmdParams
205205

206206
-- Couldn't parse the command identifier
207207
_ -> do
208208
logWith recorder Warning LogInvalidCommandIdentifier
209209
return $ Left $ ResponseError (InR ErrorCodes_InvalidParams) "Invalid command identifier" Nothing
210210

211-
runPluginCommand :: IdeState -> PluginId -> CommandId -> A.Value -> LSP.LspT Config IO (Either ResponseError (A.Value |? Null))
212-
runPluginCommand ide p com arg =
211+
runPluginCommand :: IdeState -> PluginId -> CommandId -> Maybe ProgressToken -> A.Value -> LSP.LspT Config IO (Either ResponseError (A.Value |? Null))
212+
runPluginCommand ide p com mtoken arg =
213213
case Map.lookup p pluginMap of
214214
Nothing -> logAndReturnError recorder p (InR ErrorCodes_InvalidRequest) (pluginDoesntExist p)
215215
Just xs -> case List.find ((com ==) . commandId) xs of
216216
Nothing -> logAndReturnError recorder p (InR ErrorCodes_InvalidRequest) (commandDoesntExist com p xs)
217217
Just (PluginCommand _ _ f) -> case A.fromJSON arg of
218218
A.Error err -> logAndReturnError recorder p (InR ErrorCodes_InvalidParams) (failedToParseArgs com p err arg)
219219
A.Success a -> do
220-
res <- runExceptT (f ide a) `catchAny` -- See Note [Exception handling in plugins]
220+
res <- runExceptT (f ide mtoken a) `catchAny` -- See Note [Exception handling in plugins]
221221
(\e -> pure $ Left $ PluginInternalError (exceptionInPlugin p SMethod_WorkspaceExecuteCommand e))
222222
case res of
223223
(Left (PluginRequestRefused r)) ->

ghcide/src/Development/IDE/Plugin/Test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ blockCommandDescriptor plId = (defaultPluginDescriptor plId "") {
170170
}
171171

172172
blockCommandHandler :: CommandFunction state ExecuteCommandParams
173-
blockCommandHandler _ideState _params = do
173+
blockCommandHandler _ideState _ _params = do
174174
lift $ LSP.sendNotification (SMethod_CustomMethod (Proxy @"ghcide/blocking/command")) A.Null
175175
liftIO $ threadDelay maxBound
176176
pure $ InR Null

ghcide/src/Development/IDE/Plugin/TypeLenses.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ generateLensCommand pId uri title edit =
192192
-- recompute the edit upon command. Hence the command here just takes a edit
193193
-- and applies it.
194194
commandHandler :: CommandFunction IdeState WorkspaceEdit
195-
commandHandler _ideState wedit = do
195+
commandHandler _ideState _ wedit = do
196196
_ <- lift $ LSP.sendRequest SMethod_WorkspaceApplyEdit (ApplyWorkspaceEditParams Nothing wedit) (\_ -> pure ())
197197
pure $ InR Null
198198

0 commit comments

Comments
 (0)