From c67de5a96837bcc45ddc8fdaad32a6d86e3d865e Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 23 Oct 2020 08:51:12 +0200 Subject: [PATCH 1/8] Use last ghcide --- cabal.project | 5 +++-- ghcide | 2 +- stack-8.10.1.yaml | 1 + stack-8.10.2.yaml | 1 + stack-8.6.4.yaml | 1 + stack-8.6.5.yaml | 1 + stack-8.8.2.yaml | 1 + stack-8.8.3.yaml | 1 + stack-8.8.4.yaml | 1 + stack.yaml | 1 + 10 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cabal.project b/cabal.project index ef5e93a50a..39792b4f84 100644 --- a/cabal.project +++ b/cabal.project @@ -1,7 +1,8 @@ packages: ./ - ghcide - hls-plugin-api + ./ghcide/hie-compat + ./ghcide + ./hls-plugin-api ./plugins/tactics ./plugins/hls-hlint-plugin diff --git a/ghcide b/ghcide index c1678223bb..5bf1532b7e 160000 --- a/ghcide +++ b/ghcide @@ -1 +1 @@ -Subproject commit c1678223bbe9ec73628888ef466e0e471258040c +Subproject commit 5bf1532b7e029ba469538699a977f18467b3681d diff --git a/stack-8.10.1.yaml b/stack-8.10.1.yaml index 9190f33e18..d17432beba 100644 --- a/stack-8.10.1.yaml +++ b/stack-8.10.1.yaml @@ -2,6 +2,7 @@ resolver: nightly-2020-08-16 # Last 8.10.1 packages: - . +- ./ghcide/hie-compat - ./ghcide/ - ./hls-plugin-api - ./plugins/tactics diff --git a/stack-8.10.2.yaml b/stack-8.10.2.yaml index bb9e482840..efb08bad60 100644 --- a/stack-8.10.2.yaml +++ b/stack-8.10.2.yaml @@ -2,6 +2,7 @@ resolver: nightly-2020-10-19 packages: - . +- ./ghcide/hie-compat - ./ghcide/ - ./hls-plugin-api - ./plugins/tactics diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index 48fdc7c13c..a73a9950e5 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -3,6 +3,7 @@ compiler: ghc-8.6.4 packages: - . +- ./ghcide/hie-compat - ./ghcide/ - ./hls-plugin-api - ./plugins/tactics diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 564919937e..5a86a71f0c 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -2,6 +2,7 @@ resolver: lts-14.27 # Last 8.6.5 packages: - . +- ./ghcide/hie-compat - ./ghcide/ - ./hls-plugin-api - ./plugins/tactics diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index 3e704d09b9..fbfae13c8c 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -2,6 +2,7 @@ resolver: lts-15.3 # Last 8.8.2 packages: - . +- ./ghcide/hie-compat - ./ghcide/ - ./hls-plugin-api - ./plugins/tactics diff --git a/stack-8.8.3.yaml b/stack-8.8.3.yaml index db32b01a1f..6a7cc53f42 100644 --- a/stack-8.8.3.yaml +++ b/stack-8.8.3.yaml @@ -2,6 +2,7 @@ resolver: lts-16.11 # Last 8.8.3 packages: - . +- ./ghcide/hie-compat - ./ghcide/ - ./hls-plugin-api - ./plugins/tactics diff --git a/stack-8.8.4.yaml b/stack-8.8.4.yaml index 819c9f1680..3d160c7e35 100644 --- a/stack-8.8.4.yaml +++ b/stack-8.8.4.yaml @@ -2,6 +2,7 @@ resolver: lts-16.19 packages: - . +- ./ghcide/hie-compat - ./ghcide/ - ./hls-plugin-api - ./plugins/tactics diff --git a/stack.yaml b/stack.yaml index 89fd3d2f96..0eb07b430c 100644 --- a/stack.yaml +++ b/stack.yaml @@ -2,6 +2,7 @@ resolver: lts-14.27 # Last 8.6.5 packages: - . +- ./ghcide/hie-compat - ./ghcide/ - ./hls-plugin-api - ./plugins/tactics From a02e6c7ceb8d87b4983a6eb326dc724ad76eaf1d Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 23 Oct 2020 10:27:50 +0200 Subject: [PATCH 2/8] Adapt tactic plugin to last ghcide --- plugins/tactics/src/Ide/Plugin/Tactic.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/tactics/src/Ide/Plugin/Tactic.hs b/plugins/tactics/src/Ide/Plugin/Tactic.hs index c5744e811a..206bf8eb2c 100644 --- a/plugins/tactics/src/Ide/Plugin/Tactic.hs +++ b/plugins/tactics/src/Ide/Plugin/Tactic.hs @@ -61,6 +61,7 @@ import Language.Haskell.LSP.Types import OccName import SrcLoc (containsSpan) import System.Timeout +import TcRnTypes (tcg_binds) descriptor :: PluginId -> PluginDescriptor @@ -260,8 +261,8 @@ judgementForHole state nfp range = do resulting_range <- liftMaybe $ toCurrentRange amapping $ realSrcSpanToRange rss (tcmod, _) <- MaybeT $ runIde state $ useWithStale TypeCheck nfp - let tcg = fst $ tm_internals_ $ tmrModule tcmod - tcs = tm_typechecked_source $ tmrModule tcmod + let tcg = tmrTypechecked tcmod + tcs = tcg_binds tcg ctx = mkContext (mapMaybe (sequenceA . (occName *** coerce)) $ getDefiningBindings binds rss) From 915896937c4ce8f399488bf8efbd30d115910da6 Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 23 Oct 2020 10:28:11 +0200 Subject: [PATCH 3/8] Adapt imports plugin to last ghcide --- plugins/default/src/Ide/Plugin/ImportLens.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/default/src/Ide/Plugin/ImportLens.hs b/plugins/default/src/Ide/Plugin/ImportLens.hs index 4c910aeaf4..68e83a5c91 100644 --- a/plugins/default/src/Ide/Plugin/ImportLens.hs +++ b/plugins/default/src/Ide/Plugin/ImportLens.hs @@ -192,11 +192,11 @@ extractMinimalImports :: Maybe (HscEnvEq) -> Maybe (TcModuleResult) -> IO ([LImportDecl GhcRn], Maybe [LImportDecl GhcRn]) -extractMinimalImports (Just (hsc)) (Just (tmrModule -> TypecheckedModule {..})) = do +extractMinimalImports (Just (hsc)) (Just (TcModuleResult {..})) = do -- extract the original imports and the typechecking environment - let (tcEnv, _) = tm_internals_ - Just (_, imports, _, _) = tm_renamed_source - ParsedModule {pm_parsed_source = L loc _} = tm_parsed_module + let tcEnv = tmrTypechecked + (_, imports, _, _) = tmrRenamed + ParsedModule {pm_parsed_source = L loc _} = tmrParsed span = fromMaybe (error "expected real") $ realSpan loc -- GHC is secretly full of mutable state From 02a0ce8ab6950d9592d4df18424e8c147d18ab90 Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 23 Oct 2020 10:29:19 +0200 Subject: [PATCH 4/8] Adapt retrie plugin to last ghcide --- plugins/default/src/Ide/Plugin/Retrie.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/default/src/Ide/Plugin/Retrie.hs b/plugins/default/src/Ide/Plugin/Retrie.hs index 03fb22397b..1283e4000a 100644 --- a/plugins/default/src/Ide/Plugin/Retrie.hs +++ b/plugins/default/src/Ide/Plugin/Retrie.hs @@ -53,15 +53,14 @@ import Development.IDE.GHC.Compat (GenLocated (L), GhcRn, RuleDecls (HsRules), SrcSpan (..), TyClDecl (SynDecl), - TyClGroup (..), - TypecheckedModule (..), fun_id, + TyClGroup (..), fun_id, mi_fixities, moduleNameString, parseModule, rds_rules, srcSpanFile) import GHC.Generics (Generic) import GhcPlugins (Outputable, SourceText (NoSourceText), - isQual, isQual_maybe, + hm_iface, isQual, isQual_maybe, nameModule_maybe, nameRdrName, occNameFS, occNameString, rdrNameOcc, unpackFS) @@ -213,7 +212,7 @@ getBinds nfp = runMaybeT $ do -- we use the typechecked source instead of the parsed source -- to be able to extract module names from the Ids, -- so that we can include adding the required imports in the retrie command - let TypecheckedModule {tm_renamed_source = Just rn} = tmrModule tm + let rn = tmrRenamed tm ( HsGroup { hs_valds = XValBindsLR @@ -454,9 +453,9 @@ callRetrie state session rewrites origin restrictToOriginatingFile = do let fs = occNameFS n ] fixFixities f pm = do - HiFileResult {hirModIface} <- + HiFileResult {hirHomeMod} <- useOrFail "GetModIface" NoTypeCheck GetModIface f - let fixities = fixityEnvFromModIface hirModIface + let fixities = fixityEnvFromModIface $ hm_iface hirHomeMod res <- transformA pm (fix fixities) return (fixities, res) fixAnns ParsedModule {..} = From f4d5272b2157eb4a4e8ee5c1a2c89f43e39f4150 Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 23 Oct 2020 10:32:15 +0200 Subject: [PATCH 5/8] Get bleeding edge ghcide --- ghcide | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghcide b/ghcide index 5bf1532b7e..d76fbf9a5c 160000 --- a/ghcide +++ b/ghcide @@ -1 +1 @@ -Subproject commit 5bf1532b7e029ba469538699a977f18467b3681d +Subproject commit d76fbf9a5cb34312d8f13c3a908cc98779284313 From 24abcc36d32fbf99a62ecc798e3846a048cdac58 Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 23 Oct 2020 11:08:19 +0200 Subject: [PATCH 6/8] Replace missing runGhcEnv with evalGhcEnv --- plugins/default/src/Ide/Plugin/Retrie.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/default/src/Ide/Plugin/Retrie.hs b/plugins/default/src/Ide/Plugin/Retrie.hs index 1283e4000a..ebfee268cc 100644 --- a/plugins/default/src/Ide/Plugin/Retrie.hs +++ b/plugins/default/src/Ide/Plugin/Retrie.hs @@ -368,8 +368,8 @@ callRetrie state session rewrites origin restrictToOriginatingFile = do Just (stringToStringBuffer contents) } logPriority (ideLogger state) Info $ T.pack $ "Parsing module: " <> t - (_, parsed) <- - runGhcEnv session (parseModule ms') + parsed <- + evalGhcEnv session (parseModule ms') `catch` \e -> throwIO (GHCParseError nt (show @SomeException e)) (fixities, parsed) <- fixFixities f (fixAnns parsed) return (fixities, parsed) From d7f64de76da504221f08e8ff135cfc4276f1c1db Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 3 Nov 2020 10:55:32 +0100 Subject: [PATCH 7/8] Replace GhcSessionDeps with GhcSession --- plugins/default/src/Ide/Plugin/Eval.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/default/src/Ide/Plugin/Eval.hs b/plugins/default/src/Ide/Plugin/Eval.hs index cad3c0b588..2da1e7386f 100644 --- a/plugins/default/src/Ide/Plugin/Eval.hs +++ b/plugins/default/src/Ide/Plugin/Eval.hs @@ -172,7 +172,7 @@ runEvalCmd lsp state EvalParams {..} = withIndefiniteProgress lsp "Eval" Cancell session <- liftIO $ runAction "runEvalCmd.ghcSession" state $ - use_ GhcSessionDeps $ + use_ GhcSession $ toNormalizedFilePath' $ fp From e1a5752da1ca291359ac63c125a50e7cc16d0243 Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 3 Nov 2020 20:14:08 +0100 Subject: [PATCH 8/8] Retry test suite to avoid flaky tests --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d571f61acf..b55adc33e7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -69,7 +69,7 @@ defaults: &defaults # work ok, but given that these CircleCI runners aren't the beefiest # machine can cause some flakiness. So pass -j1 to Tasty (NOT Stack) to # tell it to go slow and steady. - command: stack --stack-yaml=${STACK_FILE} test haskell-language-server --dump-logs --test-arguments="-j1" + command: stack --stack-yaml=${STACK_FILE} test haskell-language-server --dump-logs --test-arguments="-j1 --rerun-update" || stack --stack-yaml=${STACK_FILE} test haskell-language-server --dump-logs --test-arguments="-j1 --rerun" || stack --stack-yaml=${STACK_FILE} test haskell-language-server --dump-logs --test-arguments="-j1 --rerun" no_output_timeout: 120m - run: