Skip to content

Commit 472947c

Browse files
authored
Add 9.4.4 binaries and drop 9.4.2 (#3417)
1 parent 1916b57 commit 472947c

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ jobs:
225225
name: Test hls-call-hierarchy-plugin test suite
226226
run: cabal test hls-call-hierarchy-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-call-hierarchy-plugin --test-options="$TEST_OPTS"
227227

228-
- if: matrix.test && matrix.os != 'windows-latest' && matrix.ghc != '9.4.2' && matrix.ghc != '9.4.3'
228+
- if: matrix.test && matrix.os != 'windows-latest'
229229
name: Test hls-rename-plugin test suite
230230
run: cabal test hls-rename-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-rename-plugin --test-options="$TEST_OPTS"
231231

haskell-language-server.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ common refineImports
257257
cpp-options: -Dhls_refineImports
258258

259259
common rename
260-
if flag(rename) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds))
260+
if flag(rename)
261261
build-depends: hls-rename-plugin ^>= 1.0
262262
cpp-options: -Dhls_rename
263263

plugins/hls-rename-plugin/hls-rename-plugin.cabal

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ source-repository head
2121
location: https://github.com/haskell/haskell-language-server.git
2222

2323
library
24-
if impl(ghc >= 9.3)
25-
buildable: False
26-
else
27-
buildable: True
2824
exposed-modules: Ide.Plugin.Rename
2925
hs-source-dirs: src
3026
build-depends:
@@ -36,6 +32,7 @@ library
3632
, ghcide ^>=1.8 || ^>= 1.9
3733
, hashable
3834
, hiedb
35+
, hie-compat
3936
, hls-plugin-api ^>= 1.3 || ^>=1.4 || ^>= 1.5 || ^>= 1.6
4037
, hls-refactor-plugin
4138
, lsp
@@ -49,10 +46,6 @@ library
4946
default-language: Haskell2010
5047

5148
test-suite tests
52-
if impl(ghc >= 9.3)
53-
buildable: False
54-
else
55-
buildable: True
5649
type: exitcode-stdio-1.0
5750
default-language: Haskell2010
5851
hs-source-dirs: test

plugins/hls-rename-plugin/src/Ide/Plugin/Rename.hs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
{-# LANGUAGE RankNTypes #-}
99
{-# LANGUAGE ScopedTypeVariables #-}
1010
{-# LANGUAGE TypeApplications #-}
11+
{-# LANGUAGE RecordWildCards #-}
1112

1213
module Ide.Plugin.Rename (descriptor, E.Log) where
1314

@@ -21,11 +22,13 @@ import Control.Monad.IO.Class
2122
import Control.Monad.Trans.Class
2223
import Control.Monad.Trans.Except
2324
import Data.Generics
25+
import Data.Bifunctor (first)
2426
import Data.Hashable
2527
import Data.HashSet (HashSet)
2628
import qualified Data.HashSet as HS
2729
import Data.List.Extra hiding (length)
2830
import qualified Data.Map as M
31+
import qualified Data.Set as S
2932
import Data.Maybe
3033
import Data.Mod.Word
3134
import qualified Data.Text as T
@@ -51,6 +54,7 @@ import Ide.PluginUtils
5154
import Ide.Types
5255
import Language.LSP.Server
5356
import Language.LSP.Types
57+
import Compat.HieTypes
5458

5559
instance Hashable (Mod a) where hash n = hash (unMod n)
5660

@@ -74,7 +78,10 @@ renameProvider state pluginId (RenameParams (TextDocumentIdentifier uri) pos _pr
7478
See the `IndirectPuns` test for an example. -}
7579
indirectOldNames <- concat . filter ((>1) . Prelude.length) <$>
7680
mapM (uncurry (getNamesAtPos state) . locToFilePos) directRefs
77-
let oldNames = indirectOldNames ++ directOldNames
81+
let oldNames = (filter matchesDirect indirectOldNames) ++ directOldNames
82+
matchesDirect n = occNameFS (nameOccName n) `elem` directFS
83+
where
84+
directFS = map (occNameFS. nameOccName) directOldNames
7885
refs <- HS.fromList . concat <$> mapM (refsAtName state nfp) oldNames
7986

8087
-- Validate rename
@@ -220,7 +227,21 @@ handleGetHieAst ::
220227
ExceptT String m (HieAstResult, PositionMapping)
221228
handleGetHieAst state nfp = handleMaybeM
222229
("No AST for file: " ++ show nfp)
223-
(liftIO $ runAction "Rename.GetHieAst" state $ useWithStale GetHieAst nfp)
230+
(liftIO $ fmap (fmap (first removeGenerated)) $ runAction "Rename.GetHieAst" state $ useWithStale GetHieAst nfp)
231+
232+
-- | We don't want to rename in code generated by GHC as this gives false positives.
233+
-- So we restrict the HIE file to remove all the generated code.
234+
removeGenerated :: HieAstResult -> HieAstResult
235+
removeGenerated HAR{..} = HAR{hieAst = go hieAst,..}
236+
where
237+
go :: HieASTs a -> HieASTs a
238+
go hf =
239+
#if MIN_VERSION_ghc(9,2,1)
240+
HieASTs (fmap goAst (getAsts hf))
241+
goAst (Node nsi sp xs) = Node (SourcedNodeInfo $ M.restrictKeys (getSourcedNodeInfo nsi) (S.singleton SourceInfo)) sp (map goAst xs)
242+
#else
243+
hf
244+
#endif
224245

225246
handleUriToNfp :: (Monad m) => Uri -> ExceptT String m NormalizedFilePath
226247
handleUriToNfp uri = handleMaybe

0 commit comments

Comments
 (0)