diff --git a/cabal.project b/cabal.project index b4e5ec7d55..b1616e8236 100644 --- a/cabal.project +++ b/cabal.project @@ -55,7 +55,7 @@ package * write-ghc-environment-files: never -index-state: 2023-08-05T06:03:58Z +index-state: 2023-08-06T10:37:15Z constraints: -- For GHC 9.4, older versions of entropy fail to build on Windows diff --git a/flake.nix b/flake.nix index 12f9b21259..5556a81454 100644 --- a/flake.nix +++ b/flake.nix @@ -51,15 +51,15 @@ # not sure if this is the correct way to get lsp* packages in lsp = { - url = "https://hackage.haskell.org/package/lsp-2.0.0.0/lsp-2.0.0.0.tar.gz"; + url = "https://hackage.haskell.org/package/lsp-2.1.0.0/lsp-2.1.0.0.tar.gz"; flake = false; }; lsp-types = { - url = "https://hackage.haskell.org/package/lsp-types-2.0.0.1/lsp-types-2.0.0.1.tar.gz"; + url = "https://hackage.haskell.org/package/lsp-types-2.0.1.0/lsp-types-2.0.1.0.tar.gz"; flake = false; }; lsp-test = { - url = "https://hackage.haskell.org/package/lsp-test-0.15.0.0/lsp-test-0.15.0.0.tar.gz"; + url = "https://hackage.haskell.org/package/lsp-test-0.15.0.1/lsp-test-0.15.0.1.tar.gz"; flake = false; }; diff --git a/ghcide-bench/ghcide-bench.cabal b/ghcide-bench/ghcide-bench.cabal index d4e89061f8..9fff6db0fc 100644 --- a/ghcide-bench/ghcide-bench.cabal +++ b/ghcide-bench/ghcide-bench.cabal @@ -119,7 +119,7 @@ test-suite test base, extra, ghcide-bench, - lsp-test ^>= 0.15, + lsp-test ^>= 0.15.0.1, tasty, tasty-hunit >= 0.10, tasty-rerun, diff --git a/ghcide/ghcide.cabal b/ghcide/ghcide.cabal index 5e7523f823..3df6359a37 100644 --- a/ghcide/ghcide.cabal +++ b/ghcide/ghcide.cabal @@ -69,8 +69,8 @@ library lens, list-t, hiedb == 0.4.3.*, - lsp-types ^>= 2.0.0.1, - lsp ^>= 2.0.0.0 , + lsp-types ^>= 2.0.1.0, + lsp ^>= 2.1.0.0 , mtl, optparse-applicative, parallel, @@ -346,7 +346,7 @@ test-suite ghcide-tests hls-plugin-api, lens, list-t, - lsp-test ^>= 0.15, + lsp-test ^>= 0.15.0.1, mtl, monoid-subclasses, network-uri, diff --git a/ghcide/src/Development/IDE/LSP/LanguageServer.hs b/ghcide/src/Development/IDE/LSP/LanguageServer.hs index 80d7d1b7bf..d20f85adc1 100644 --- a/ghcide/src/Development/IDE/LSP/LanguageServer.hs +++ b/ghcide/src/Development/IDE/LSP/LanguageServer.hs @@ -107,7 +107,7 @@ runLanguageServer recorder options inH outH defaultConfig onConfigurationChange { LSP.onConfigurationChange = onConfigurationChange , LSP.defaultConfig = defaultConfig , LSP.doInitialize = doInitialize - , LSP.staticHandlers = staticHandlers + , LSP.staticHandlers = (const staticHandlers) , LSP.interpretHandler = interpretHandler , LSP.options = modifyOptions options } diff --git a/ghcide/test/exe/CompletionTests.hs b/ghcide/test/exe/CompletionTests.hs index c6953710ca..2e2be028ea 100644 --- a/ghcide/test/exe/CompletionTests.hs +++ b/ghcide/test/exe/CompletionTests.hs @@ -48,21 +48,13 @@ completionTest :: HasCallStack => String -> [T.Text] -> Position -> [(T.Text, Co completionTest name src pos expected = testSessionWait name $ do docId <- createDoc "A.hs" "haskell" (T.unlines src) _ <- waitForDiagnostics - compls <- getCompletions docId pos + compls <- getAndResolveCompletions docId pos let compls' = [ (_label, _kind, _insertText, _additionalTextEdits) | CompletionItem{..} <- compls] let emptyToMaybe x = if T.null x then Nothing else Just x liftIO $ sortOn (Lens.view Lens._1) (take (length expected) compls') @?= sortOn (Lens.view Lens._1) [ (l, Just k, emptyToMaybe t, at) | (l,k,t,_,_,at) <- expected] - forM_ (zip compls expected) $ \(item, (_,_,_,expectedSig, expectedDocs, _)) -> do - CompletionItem{..} <- - if (expectedSig || expectedDocs) && isJust (item ^. L.data_) - then do - rsp <- request SMethod_CompletionItemResolve item - case rsp ^. L.result of - Left err -> liftIO $ assertFailure ("completionItem/resolve failed with: " <> show err) - Right x -> pure x - else pure item + forM_ (zip compls expected) $ \(CompletionItem{..}, (_,_,_,expectedSig, expectedDocs, _)) -> do when expectedSig $ liftIO $ assertBool ("Missing type signature: " <> T.unpack _label) (isJust _detail) when expectedDocs $ diff --git a/ghcide/test/ghcide-test-utils.cabal b/ghcide/test/ghcide-test-utils.cabal index b6a876928e..4d08e88c26 100644 --- a/ghcide/test/ghcide-test-utils.cabal +++ b/ghcide/test/ghcide-test-utils.cabal @@ -35,7 +35,7 @@ library lsp-types, hls-plugin-api, lens, - lsp-test ^>= 0.15, + lsp-test ^>= 0.15.0.1, tasty-hunit >= 0.10, text, row-types, diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 068874f9e8..cb0e274f96 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -407,7 +407,7 @@ library , ghc , ghcide == 2.1.0.0 , githash >=0.1.6.1 - , lsp >= 2.0.0.0 + , lsp >= 2.1.0.0 , hie-bios , hiedb , hls-plugin-api == 2.1.0.0 diff --git a/hls-plugin-api/hls-plugin-api.cabal b/hls-plugin-api/hls-plugin-api.cabal index 636c2f921a..b1534beb7f 100644 --- a/hls-plugin-api/hls-plugin-api.cabal +++ b/hls-plugin-api/hls-plugin-api.cabal @@ -62,7 +62,7 @@ library , hls-graph == 2.1.0.0 , lens , lens-aeson - , lsp ^>=2.0.0.0 + , lsp ^>=2.1.0.0 , mtl , opentelemetry >=0.4 , optparse-applicative diff --git a/hls-test-utils/hls-test-utils.cabal b/hls-test-utils/hls-test-utils.cabal index 7955abed48..6f5808774b 100644 --- a/hls-test-utils/hls-test-utils.cabal +++ b/hls-test-utils/hls-test-utils.cabal @@ -45,9 +45,9 @@ library , hls-graph , hls-plugin-api == 2.1.0.0 , lens - , lsp ^>=2.0.0.0 - , lsp-test ^>=0.15 - , lsp-types ^>=2.0.0.1 + , lsp ^>=2.1.0.0 + , lsp-test ^>=0.15.0.1 + , lsp-types ^>=2.0.1.0 , tasty , tasty-expected-failure , tasty-golden diff --git a/plugins/hls-alternate-number-format-plugin/hls-alternate-number-format-plugin.cabal b/plugins/hls-alternate-number-format-plugin/hls-alternate-number-format-plugin.cabal index 384b8eaf61..4ab0ea6477 100644 --- a/plugins/hls-alternate-number-format-plugin/hls-alternate-number-format-plugin.cabal +++ b/plugins/hls-alternate-number-format-plugin/hls-alternate-number-format-plugin.cabal @@ -38,7 +38,7 @@ library , hls-plugin-api == 2.1.0.0 , hie-compat , lens - , lsp ^>=2.0.0.0 + , lsp ^>=2.1.0.0 , mtl , regex-tdfa , syb diff --git a/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal b/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal index f4bb539833..cdd614c653 100644 --- a/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal +++ b/plugins/hls-cabal-plugin/hls-cabal-plugin.cabal @@ -53,8 +53,8 @@ library , hls-plugin-api == 2.1.0.0 , hls-graph == 2.1.0.0 , lens - , lsp ^>=2.0.0.0 - , lsp-types ^>=2.0.0.1 + , lsp ^>=2.1.0.0 + , lsp-types ^>=2.0.1.0 , regex-tdfa ^>=1.3.1 , stm , text diff --git a/plugins/hls-call-hierarchy-plugin/hls-call-hierarchy-plugin.cabal b/plugins/hls-call-hierarchy-plugin/hls-call-hierarchy-plugin.cabal index 2a4d881f10..b28772192d 100644 --- a/plugins/hls-call-hierarchy-plugin/hls-call-hierarchy-plugin.cabal +++ b/plugins/hls-call-hierarchy-plugin/hls-call-hierarchy-plugin.cabal @@ -37,7 +37,7 @@ library , hiedb , hls-plugin-api == 2.1.0.0 , lens - , lsp >=1.2.0.1 + , lsp >=2.1.0.0 , sqlite-simple , text , unordered-containers diff --git a/plugins/hls-explicit-fixity-plugin/hls-explicit-fixity-plugin.cabal b/plugins/hls-explicit-fixity-plugin/hls-explicit-fixity-plugin.cabal index ae09d4569c..f5acaca0f9 100644 --- a/plugins/hls-explicit-fixity-plugin/hls-explicit-fixity-plugin.cabal +++ b/plugins/hls-explicit-fixity-plugin/hls-explicit-fixity-plugin.cabal @@ -33,7 +33,7 @@ library , ghcide == 2.1.0.0 , hashable , hls-plugin-api == 2.1.0.0 - , lsp >=1.2.0.1 + , lsp >=2.1.0.0 , text , transformers diff --git a/plugins/hls-explicit-imports-plugin/test/Main.hs b/plugins/hls-explicit-imports-plugin/test/Main.hs index 8cab24d707..2a45d16656 100644 --- a/plugins/hls-explicit-imports-plugin/test/Main.hs +++ b/plugins/hls-explicit-imports-plugin/test/Main.hs @@ -134,13 +134,6 @@ codeActionOnlyResolveGoldenTest fp l c = goldenWithImportActions " code action r resolved <- resolveCodeAction x executeCodeAction resolved --- TODO: use the one from lsp-test once that's released -resolveCodeAction :: CodeAction -> Session CodeAction -resolveCodeAction ca = do - resolveResponse <- request SMethod_CodeActionResolve ca - Right resolved <- pure $ resolveResponse ^. L.result - pure resolved - maybeResolveCodeAction :: CodeAction -> Session (Maybe CodeAction) maybeResolveCodeAction ca = do resolveResponse <- request SMethod_CodeActionResolve ca @@ -165,13 +158,6 @@ notRefineImports (CodeLens _ (Just (Command text _ _)) _) | "Refine imports to" `T.isPrefixOf` text = False notRefineImports _ = True --- TODO: use the one from lsp-test once that's released -resolveCodeLens :: CodeLens -> Session CodeLens -resolveCodeLens cl = do - resolveResponse <- request SMethod_CodeLensResolve cl - Right resolved <- pure $ resolveResponse ^. L.result - pure resolved - -- Execute command and wait for result executeCmd :: Command -> Session () executeCmd cmd = do diff --git a/plugins/hls-floskell-plugin/hls-floskell-plugin.cabal b/plugins/hls-floskell-plugin/hls-floskell-plugin.cabal index 88524d39cb..33a3149932 100644 --- a/plugins/hls-floskell-plugin/hls-floskell-plugin.cabal +++ b/plugins/hls-floskell-plugin/hls-floskell-plugin.cabal @@ -30,7 +30,7 @@ library , floskell ^>=0.10 , ghcide == 2.1.0.0 , hls-plugin-api == 2.1.0.0 - , lsp-types ^>=2.0.0.1 + , lsp-types ^>=2.0.1.0 , mtl , text , transformers diff --git a/plugins/hls-gadt-plugin/hls-gadt-plugin.cabal b/plugins/hls-gadt-plugin/hls-gadt-plugin.cabal index 62bda28301..d1a07d6578 100644 --- a/plugins/hls-gadt-plugin/hls-gadt-plugin.cabal +++ b/plugins/hls-gadt-plugin/hls-gadt-plugin.cabal @@ -36,7 +36,7 @@ library , hls-plugin-api == 2.1.0.0 , hls-refactor-plugin , lens - , lsp >=1.2.0.1 + , lsp >=2.1.0.0 , mtl , text , transformers diff --git a/plugins/hls-hlint-plugin/test/Main.hs b/plugins/hls-hlint-plugin/test/Main.hs index e58f8c85ee..9fca15bfb1 100644 --- a/plugins/hls-hlint-plugin/test/Main.hs +++ b/plugins/hls-hlint-plugin/test/Main.hs @@ -453,13 +453,9 @@ goldenResolveTest :: TestName -> FilePath -> Point -> T.Text -> TestTree goldenResolveTest testCaseName goldenFilename point hintText = setupGoldenHlintResolveTest testCaseName goldenFilename $ \document -> do waitForDiagnosticsFromSource document "hlint" - actions <- getCodeActions document $ pointToRange point + actions <- getAndResolveCodeActions document $ pointToRange point case find ((== Just hintText) . getCodeActionTitle) actions of - Just (InR codeAction) -> do - rsp <- request SMethod_CodeActionResolve codeAction - case rsp ^. L.result of - Right ca -> executeCodeAction ca - Left re -> liftIO $ assertFailure $ show re + Just (InR codeAction) -> executeCodeAction codeAction _ -> liftIO $ assertFailure $ makeCodeActionNotFoundAtString point setupGoldenHlintResolveTest :: TestName -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree diff --git a/plugins/hls-overloaded-record-dot-plugin/test/Main.hs b/plugins/hls-overloaded-record-dot-plugin/test/Main.hs index 25bfb583b1..f76d8b8843 100644 --- a/plugins/hls-overloaded-record-dot-plugin/test/Main.hs +++ b/plugins/hls-overloaded-record-dot-plugin/test/Main.hs @@ -5,27 +5,11 @@ module Main ( main ) where -import Control.Lens ((^.)) import Data.Either (rights) -import Data.Functor (void) -import Data.Maybe (isNothing) -import Data.Row import qualified Data.Text as T -import qualified Data.Text.Lazy as TL -import qualified Data.Text.Lazy.Encoding as TL -import Ide.Logger (Doc, Logger (Logger), - Pretty (pretty), - Priority (Debug), - Recorder (Recorder, logger_), - WithPriority (WithPriority, priority), - cfilter, cmapWithPrio, - makeDefaultStderrRecorder) import qualified Ide.Plugin.OverloadedRecordDot as OverloadedRecordDot -import Language.LSP.Protocol.Lens as L -import System.FilePath ((<.>), ()) +import System.FilePath (()) import Test.Hls -import Test.Hls.Util (codeActionNoResolveCaps, - codeActionResolveCaps) main :: IO () main = @@ -59,7 +43,7 @@ mkNoResolveTest title fp selectorName x1 y1 x2 y2 = mkResolveTest :: TestName -> FilePath -> T.Text -> UInt -> UInt -> UInt -> UInt -> TestTree mkResolveTest title fp selectorName x1 y1 x2 y2 = goldenWithHaskellAndCaps codeActionResolveCaps plugin title testDataDir fp "expected" "hs" $ \doc -> do - ((Right act):_) <- getAndResolveExplicitFieldsActions doc selectorName x1 y1 x2 y2 + (act:_) <- getAndResolveExplicitFieldsActions doc selectorName x1 y1 x2 y2 executeCodeAction act @@ -77,12 +61,9 @@ getAndResolveExplicitFieldsActions :: TextDocumentIdentifier -> T.Text -> UInt -> UInt -> UInt -> UInt - -> Session [Either ResponseError CodeAction] + -> Session [CodeAction] getAndResolveExplicitFieldsActions doc selectorName x1 y1 x2 y2 = do - actions <- findExplicitFieldsAction selectorName <$> getCodeActions doc range - rsp <- mapM (request SMethod_CodeActionResolve) (filter (\x -> isNothing (x ^. L.edit)) actions) - pure $ (^. L.result) <$> rsp - + findExplicitFieldsAction selectorName <$> getAndResolveCodeActions doc range where range = Range (Position x1 y1) (Position x2 y2) diff --git a/stack-lts21.yaml b/stack-lts21.yaml index 90f2c3953c..6d0a3f85a6 100644 --- a/stack-lts21.yaml +++ b/stack-lts21.yaml @@ -53,6 +53,10 @@ extra-deps: - algebraic-graphs-0.6.1 - retrie-1.2.2 - stylish-haskell-0.14.4.0 +- lsp-2.1.0.0@sha256:ef6fc28eac6dc27672cd8471c9f83f14de646a9c1fcaf993a451d2ae4de274e8,3533 +- lsp-test-0.15.0.1@sha256:31e3a9969706dbdf6713c2dec4cad02efd9a3d75bf9b26c95cb442535aeaf998,3822 +- lsp-types-2.0.1.0@sha256:70a822473de72c165495c2eed00f4c2a728f7fe1e6d7d8b4709d474a41860940,29317 + configure-options: ghcide: diff --git a/stack.yaml b/stack.yaml index 28847bc00e..7ad9a68af0 100644 --- a/stack.yaml +++ b/stack.yaml @@ -41,6 +41,8 @@ packages: ghc-options: "$everything": -haddock +allow-newer: true + extra-deps: - Cabal-syntax-3.10.1.0@sha256:bb835ebab577fd0f9c11dab96210dbb8d68ffc62652576f4b092563c345930e7,7434 # - floskell-0.10.7 @@ -53,6 +55,10 @@ extra-deps: - hw-fingertree-0.1.2.1 - hw-prim-0.6.3.2 - ansi-terminal-0.11.5 +- lsp-2.1.0.0@sha256:ef6fc28eac6dc27672cd8471c9f83f14de646a9c1fcaf993a451d2ae4de274e8,3533 +- lsp-test-0.15.0.1@sha256:31e3a9969706dbdf6713c2dec4cad02efd9a3d75bf9b26c95cb442535aeaf998,3822 +- lsp-types-2.0.1.0@sha256:70a822473de72c165495c2eed00f4c2a728f7fe1e6d7d8b4709d474a41860940,29317 + configure-options: ghcide: diff --git a/test/functional/Completion.hs b/test/functional/Completion.hs index 0511e75fcc..cc41f4bac3 100644 --- a/test/functional/Completion.hs +++ b/test/functional/Completion.hs @@ -4,10 +4,8 @@ module Completion(tests) where import Control.Lens hiding ((.=)) -import Control.Monad import Data.Aeson (object, (.=)) import Data.Foldable (find) -import Data.Maybe (isJust) import Data.Row.Records (focus) import qualified Data.Text as T import Ide.Plugin.Config (maxCompletions) @@ -15,18 +13,6 @@ import Language.LSP.Protocol.Lens hiding (applyEdit, length) import Test.Hls import Test.Hls.Command -getResolvedCompletions :: TextDocumentIdentifier -> Position -> Session [CompletionItem] -getResolvedCompletions doc pos = do - xs <- getCompletions doc pos - forM xs $ \item -> do - if isJust (item ^. data_) - then do - rsp <- request SMethod_CompletionItemResolve item - case rsp ^. result of - Left err -> liftIO $ assertFailure ("completionItem/resolve failed with: " <> show err) - Right x -> pure x - else pure item - tests :: TestTree tests = testGroup "completions" [ testCase "works" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do @@ -35,7 +21,7 @@ tests = testGroup "completions" [ let te = TextEdit (Range (Position 5 7) (Position 5 24)) "put" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 9) + compls <- getAndResolveCompletions doc (Position 5 9) item <- getCompletionByLabel "putStrLn" compls liftIO $ do item ^. label @?= "putStrLn" @@ -50,7 +36,7 @@ tests = testGroup "completions" [ let te = TextEdit (Range (Position 5 7) (Position 5 24)) "put" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 9) + compls <- getAndResolveCompletions doc (Position 5 9) item <- getCompletionByLabel "putStrLn" compls liftIO $ do item ^. label @?= "putStrLn" @@ -67,7 +53,7 @@ tests = testGroup "completions" [ let te = TextEdit (Range (Position 1 17) (Position 1 26)) "Data.M" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 1 23) + compls <- getAndResolveCompletions doc (Position 1 23) item <- getCompletionByLabel "Maybe" compls liftIO $ do item ^. label @?= "Maybe" @@ -82,7 +68,7 @@ tests = testGroup "completions" [ let te = TextEdit (Range (Position 2 17) (Position 2 25)) "Data.L" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 2 24) + compls <- getAndResolveCompletions doc (Position 2 24) item <- getCompletionByLabel "List" compls liftIO $ do item ^. label @?= "List" @@ -92,7 +78,7 @@ tests = testGroup "completions" [ , testCase "completes with no prefix" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - compls <- getResolvedCompletions doc (Position 5 7) + compls <- getAndResolveCompletions doc (Position 5 7) liftIO $ assertBool "Expected completions" $ not $ null compls , expectFailIfBeforeGhc92 "record dot syntax is introduced in GHC 9.2" @@ -103,7 +89,7 @@ tests = testGroup "completions" [ let te = TextEdit (Range (Position 25 0) (Position 25 5)) "z = x.a" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 25 6) + compls <- getAndResolveCompletions doc (Position 25 6) item <- getCompletionByLabel "a" compls liftIO $ do @@ -114,7 +100,7 @@ tests = testGroup "completions" [ let te = TextEdit (Range (Position 27 0) (Position 27 8)) "z2 = x.c.z" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 27 9) + compls <- getAndResolveCompletions doc (Position 27 9) item <- getCompletionByLabel "z" compls liftIO $ do @@ -128,7 +114,7 @@ tests = testGroup "completions" [ let te = TextEdit (Range (Position 5 0) (Position 5 2)) "acc" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 4) + compls <- getAndResolveCompletions doc (Position 5 4) item <- getCompletionByLabel "accessor" compls liftIO $ do item ^. label @?= "accessor" @@ -138,7 +124,7 @@ tests = testGroup "completions" [ let te = TextEdit (Range (Position 5 7) (Position 5 9)) "id" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 9) + compls <- getAndResolveCompletions doc (Position 5 9) item <- getCompletionByLabel "id" compls liftIO $ do item ^. detail @?= Just ":: a -> a\nfrom Prelude" @@ -148,7 +134,7 @@ tests = testGroup "completions" [ let te = TextEdit (Range (Position 5 7) (Position 5 24)) "flip" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 11) + compls <- getAndResolveCompletions doc (Position 5 11) item <- getCompletionByLabel "flip" compls liftIO $ item ^. detail @?= Just ":: (a -> b -> c) -> b -> a -> c\nfrom Prelude" @@ -156,7 +142,7 @@ tests = testGroup "completions" [ , testCase "maxCompletions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - compls <- getResolvedCompletions doc (Position 5 7) + compls <- getAndResolveCompletions doc (Position 5 7) liftIO $ length compls @?= maxCompletions def , testCase "import function completions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do @@ -165,7 +151,7 @@ tests = testGroup "completions" [ let te = TextEdit (Range (Position 0 30) (Position 0 41)) "A" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 0 31) + compls <- getAndResolveCompletions doc (Position 0 31) item <- getCompletionByLabel "Alternative" compls liftIO $ do item ^. label @?= "Alternative" @@ -178,7 +164,7 @@ tests = testGroup "completions" [ let te = TextEdit (Range (Position 0 39) (Position 0 39)) ", l" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 0 42) + compls <- getAndResolveCompletions doc (Position 0 42) item <- getCompletionByLabel "liftA" compls liftIO $ do item ^. label @?= "liftA" @@ -188,7 +174,7 @@ tests = testGroup "completions" [ , testCase "completes locally defined associated type family" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "AssociatedTypeFamily.hs" "haskell" - compls <- getResolvedCompletions doc (Position 5 20) + compls <- getAndResolveCompletions doc (Position 5 20) item <- getCompletionByLabel "Fam" compls liftIO $ do item ^. label @?= "Fam" @@ -206,7 +192,7 @@ snippetTests = testGroup "snippets" [ let te = TextEdit (Range (Position 5 7) (Position 5 24)) "Nothing" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 14) + compls <- getAndResolveCompletions doc (Position 5 14) item <- getCompletionByLabel "Nothing" compls liftIO $ do item ^. insertTextFormat @?= Just InsertTextFormat_Snippet @@ -218,7 +204,7 @@ snippetTests = testGroup "snippets" [ let te = TextEdit (Range (Position 5 7) (Position 5 24)) "fold" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 11) + compls <- getAndResolveCompletions doc (Position 5 11) item <- getCompletionByLabel "foldl" compls liftIO $ do item ^. label @?= "foldl" @@ -232,7 +218,7 @@ snippetTests = testGroup "snippets" [ let te = TextEdit (Range (Position 5 7) (Position 5 24)) "mapM" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 11) + compls <- getAndResolveCompletions doc (Position 5 11) item <- getCompletionByLabel "mapM" compls liftIO $ do item ^. label @?= "mapM" @@ -246,7 +232,7 @@ snippetTests = testGroup "snippets" [ let te = TextEdit (Range (Position 5 7) (Position 5 24)) "even `filte" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 18) + compls <- getAndResolveCompletions doc (Position 5 18) item <- getCompletionByLabel "filter" compls liftIO $ do item ^. label @?= "filter" @@ -260,7 +246,7 @@ snippetTests = testGroup "snippets" [ let te = TextEdit (Range (Position 5 7) (Position 5 24)) "even `filte`" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 18) + compls <- getAndResolveCompletions doc (Position 5 18) item <- getCompletionByLabel "filter" compls liftIO $ do item ^. label @?= "filter" @@ -274,7 +260,7 @@ snippetTests = testGroup "snippets" [ let te = TextEdit (Range (Position 5 7) (Position 5 24)) "\"\" `Data.List.interspe" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 29) + compls <- getAndResolveCompletions doc (Position 5 29) item <- getCompletionByLabel "intersperse" compls liftIO $ do item ^. label @?= "intersperse" @@ -288,7 +274,7 @@ snippetTests = testGroup "snippets" [ let te = TextEdit (Range (Position 5 7) (Position 5 24)) "\"\" `Data.List.interspe`" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 29) + compls <- getAndResolveCompletions doc (Position 5 29) item <- getCompletionByLabel "intersperse" compls liftIO $ do item ^. label @?= "intersperse" @@ -315,7 +301,7 @@ snippetTests = testGroup "snippets" [ let te = TextEdit (Range (Position 1 0) (Position 1 2)) "MkF" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 1 6) + compls <- getAndResolveCompletions doc (Position 1 6) item <- case find (\c -> (c ^. label == "MkFoo") && maybe False ("MkFoo {" `T.isPrefixOf`) (c ^. insertText)) compls of Just c -> pure c Nothing -> liftIO . assertFailure $ "Completion with label 'MkFoo' and insertText starting with 'MkFoo {' not found among " <> show compls @@ -328,7 +314,7 @@ snippetTests = testGroup "snippets" [ let te = TextEdit (Range (Position 5 7) (Position 5 24)) "fold" _ <- applyEdit doc te - compls <- getResolvedCompletions doc (Position 5 11) + compls <- getAndResolveCompletions doc (Position 5 11) item <- getCompletionByLabel "foldl" compls liftIO $ do item ^. label @?= "foldl" @@ -353,7 +339,7 @@ contextTests = testGroup "contexts" [ testCase "only provides type suggestions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Context.hs" "haskell" - compls <- getResolvedCompletions doc (Position 2 17) + compls <- getAndResolveCompletions doc (Position 2 17) liftIO $ do compls `shouldContainCompl` "Integer" compls `shouldNotContainCompl` "interact" @@ -361,7 +347,7 @@ contextTests = testGroup "contexts" [ , testCase "only provides value suggestions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Context.hs" "haskell" - compls <- getResolvedCompletions doc (Position 3 10) + compls <- getAndResolveCompletions doc (Position 3 10) liftIO $ do compls `shouldContainCompl` "abs" compls `shouldNotContainCompl` "Applicative" @@ -369,7 +355,7 @@ contextTests = testGroup "contexts" [ , testCase "completes qualified type suggestions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Context.hs" "haskell" - compls <- getResolvedCompletions doc (Position 2 26) + compls <- getAndResolveCompletions doc (Position 2 26) liftIO $ do compls `shouldNotContainCompl` "forkOn" compls `shouldContainCompl` "MVar"