11{-# LANGUAGE ConstraintKinds #-}
2+ {-# LANGUAGE GADTs #-}
23{-# LANGUAGE ExistentialQuantification #-}
34{-# LANGUAGE ImplicitParams #-}
45{-# LANGUAGE ImpredicativeTypes #-}
6+ {-# OPTIONS_GHC -Wno-deprecations -Wno-unticked-promoted-constructors #-}
57
68module Experiments
79( Bench (.. )
@@ -23,16 +25,16 @@ import Control.Applicative.Combinators (skipManyTill)
2325import Control.Exception.Safe (IOException , handleAny , try )
2426import Control.Monad.Extra
2527import Control.Monad.IO.Class
26- import Data.Aeson (Value (Null ))
28+ import Data.Aeson (Value (Null ), toJSON )
2729import Data.List
2830import Data.Maybe
2931import qualified Data.Text as T
3032import Data.Version
3133import Development.IDE.Plugin.Test
3234import Experiments.Types
33- import Language.Haskell. LSP.Test
34- import Language.Haskell. LSP.Types
35- import Language.Haskell. LSP.Types.Capabilities
35+ import Language.LSP.Test
36+ import Language.LSP.Types
37+ import Language.LSP.Types.Capabilities
3638import Numeric.Natural
3739import Options.Applicative
3840import System.Directory
@@ -79,13 +81,13 @@ experiments =
7981 isJust <$> getHover doc (fromJust identifierP),
8082 ---------------------------------------------------------------------------------------
8183 bench " getDefinition" $ allWithIdentifierPos $ \ DocumentPositions {.. } ->
82- not . null <$> getDefinitions doc (fromJust identifierP),
84+ either ( not . null ) ( not . null ) . toEither <$> getDefinitions doc (fromJust identifierP),
8385 ---------------------------------------------------------------------------------------
8486 bench " getDefinition after edit" $ \ docs -> do
8587 forM_ docs $ \ DocumentPositions {.. } ->
8688 changeDoc doc [charEdit stringLiteralP]
8789 flip allWithIdentifierPos docs $ \ DocumentPositions {.. } ->
88- not . null <$> getDefinitions doc (fromJust identifierP),
90+ either ( not . null ) ( not . null ) . toEither <$> getDefinitions doc (fromJust identifierP),
8991 ---------------------------------------------------------------------------------------
9092 bench " documentSymbols" $ allM $ \ DocumentPositions {.. } -> do
9193 fmap (either (not . null ) (not . null )) . getDocumentSymbols $ doc,
@@ -148,7 +150,7 @@ experiments =
148150 ( \ docs -> do
149151 Just hieYaml <- uriToFilePath <$> getDocUri " hie.yaml"
150152 liftIO $ appendFile hieYaml " ##\n "
151- sendNotification WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
153+ sendNotification SWorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
152154 List [ FileEvent (filePathToUri " hie.yaml" ) FcChanged ]
153155 forM_ docs $ \ DocumentPositions {.. } ->
154156 changeDoc doc [charEdit stringLiteralP]
@@ -163,7 +165,7 @@ experiments =
163165 (\ docs -> do
164166 Just hieYaml <- uriToFilePath <$> getDocUri " hie.yaml"
165167 liftIO $ appendFile hieYaml " ##\n "
166- sendNotification WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
168+ sendNotification SWorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
167169 List [ FileEvent (filePathToUri " hie.yaml" ) FcChanged ]
168170 flip allWithIdentifierPos docs $ \ DocumentPositions {.. } -> isJust <$> getHover doc (fromJust identifierP)
169171 )
@@ -359,7 +361,9 @@ waitForProgressDone :: Session ()
359361waitForProgressDone = loop
360362 where
361363 loop = do
362- void (skipManyTill anyMessage message :: Session WorkDoneProgressEndNotification )
364+ ~ () <- skipManyTill anyMessage $ satisfyMaybe $ \ case
365+ FromServerMess SProgress (NotificationMessage _ _ (ProgressParams _ (End _))) -> Just ()
366+ _ -> Nothing
363367 done <- null <$> getIncompleteProgressSessions
364368 unless done loop
365369
@@ -393,8 +397,9 @@ runBench runSess b = handleAny (\e -> print e >> return badRun)
393397 else do
394398 output (showDuration t)
395399 -- Wait for the delayed actions to finish
396- waitId <- sendRequest (CustomClientMethod " test" ) WaitForShakeQueue
397- (td, resp) <- duration $ skipManyTill anyMessage $ responseForId waitId
400+ let m = SCustomMethod " test"
401+ waitId <- sendRequest m (toJSON WaitForShakeQueue )
402+ (td, resp) <- duration $ skipManyTill anyMessage $ responseForId m waitId
398403 case resp of
399404 ResponseMessage {_result= Right Null } -> do
400405 loop (userWaits+ t) (delayedWork+ td) (n - 1 )
@@ -562,7 +567,7 @@ searchSymbol doc@TextDocumentIdentifier{_uri} fileContents pos = do
562567 checkDefinitions pos = do
563568 defs <- getDefinitions doc pos
564569 case defs of
565- [Location uri _] -> return $ uri /= _uri
570+ ( InL [Location uri _]) -> return $ uri /= _uri
566571 _ -> return False
567572 checkCompletions pos =
568573 not . null <$> getCompletions doc pos
0 commit comments