Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ package *

write-ghc-environment-files: never

index-state: 2023-06-27T10:50:26Z
index-state: 2023-08-06T10:37:15Z

constraints:
-- For GHC 9.4, older versions of entropy fail to build on Windows
Expand Down
6 changes: 3 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.0/lsp-test-0.15.0.1.tar.gz";
flake = false;
};

Expand Down
2 changes: 1 addition & 1 deletion ghcide-bench/ghcide-bench.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ghcide/src/Development/IDE/LSP/LanguageServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 2 additions & 10 deletions ghcide/test/exe/CompletionTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 $
Expand Down
2 changes: 1 addition & 1 deletion ghcide/test/ghcide-test-utils.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hls-plugin-api/hls-plugin-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions hls-test-utils/hls-test-utils.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions plugins/hls-cabal-plugin/hls-cabal-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 0 additions & 14 deletions plugins/hls-explicit-imports-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugins/hls-floskell-plugin/hls-floskell-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugins/hls-gadt-plugin/hls-gadt-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions plugins/hls-hlint-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 4 additions & 23 deletions plugins/hls-overloaded-record-dot-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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


Expand All @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions stack-lts21.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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:
Expand Down
Loading