Skip to content

Commit 70bb0ab

Browse files
authored
[ghc-9.2] Fix refine-imports plugin (#2601)
* [ghc-9.2.1] Fix refine-imports plugin * Drop accidental top-level undefined
1 parent 5714207 commit 70bb0ab

File tree

8 files changed

+15
-12
lines changed

8 files changed

+15
-12
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ jobs:
198198
name: Test hls-tactics-plugin test suite
199199
run: cabal test hls-tactics-plugin --test-options="$TEST_OPTS" || cabal test hls-tactics-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-tactics-plugin --test-options="$TEST_OPTS"
200200

201-
- if: matrix.test && matrix.ghc != '9.2.1'
201+
- if: matrix.test
202202
name: Test hls-refine-imports-plugin test suite
203203
run: cabal test hls-refine-imports-plugin --test-options="$TEST_OPTS" || cabal test hls-refine-imports-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-refine-imports-plugin --test-options="$TEST_OPTS"
204204

cabal-ghc921.project

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ constraints:
5959
-eval
6060
-haddockComments
6161
-hlint
62-
-refineImports
6362
-retrie
6463
-splice
6564
-stylishhaskell

ghcide/src/Development/IDE/GHC/Compat/Core.hs

+8
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ module Development.IDE.GHC.Compat.Core (
193193
getLoc,
194194
getLocA,
195195
locA,
196+
noLocA,
196197
LocatedAn,
197198
#if MIN_VERSION_ghc(9,2,0)
198199
GHC.AnnListItem(..),
@@ -1021,6 +1022,13 @@ getLocA = GHC.getLocA
10211022
getLocA x = GHC.getLoc x
10221023
#endif
10231024

1025+
noLocA :: a -> LocatedAn an a
1026+
#if MIN_VERSION_ghc(9,2,0)
1027+
noLocA = GHC.noLocA
1028+
#else
1029+
noLocA = GHC.noLoc
1030+
#endif
1031+
10241032
#if !MIN_VERSION_ghc(9,2,0)
10251033
type AnnListItem = SrcLoc.SrcSpan
10261034
#endif

haskell-language-server.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ common importLens
234234
cpp-options: -DimportLens
235235

236236
common refineImports
237-
if flag(refineImports) && (impl(ghc < 9.2.1) || flag(ignore-plugins-ghc-bounds))
237+
if flag(refineImports)
238238
build-depends: hls-refine-imports-plugin ^>=1.0.0.0
239239
cpp-options: -DrefineImports
240240

plugins/hls-refine-imports-plugin/hls-refine-imports-plugin.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.4
22
name: hls-refine-imports-plugin
3-
version: 1.0.0.2
3+
version: 1.0.0.3
44
synopsis: Refine imports plugin for Haskell Language Server
55
description:
66
Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>

plugins/hls-refine-imports-plugin/src/Ide/Plugin/RefineImports.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ refineImportsRule = define $ \RefineImports nfp -> do
215215
i@(L lim id@ImportDecl
216216
{ideclName = L _ mn, ideclHiding = Just (hiding, L _ names)})
217217
(newModuleName, avails) = L lim id
218-
{ ideclName = noLoc newModuleName
219-
, ideclHiding = Just (hiding, noLoc newNames)
218+
{ ideclName = noLocA newModuleName
219+
, ideclHiding = Just (hiding, noLocA newNames)
220220
}
221221
where newNames = filter (\n -> any (n `containsAvail`) avails) names
222222
constructImport lim _ = lim
@@ -247,9 +247,9 @@ refineImportsRule = define $ \RefineImports nfp -> do
247247

248248
--------------------------------------------------------------------------------
249249

250-
mkExplicitEdit :: PositionMapping -> LImportDecl pass -> T.Text -> Maybe TextEdit
250+
mkExplicitEdit :: PositionMapping -> LImportDecl GhcRn -> T.Text -> Maybe TextEdit
251251
mkExplicitEdit posMapping (L src imp) explicit
252-
| RealSrcSpan l _ <- src,
252+
| RealSrcSpan l _ <- locA src,
253253
L _ mn <- ideclName imp,
254254
-- (almost) no one wants to see an refine import list for Prelude
255255
mn /= moduleName pRELUDE,

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

-3
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ renameModRefs newNameText refs = everywhere $ mkT replace
134134
_ -> Unqual newOccName
135135

136136
newOccName = mkTcOcc $ T.unpack newNameText
137-
138-
newRdrName :: RdrName -> RdrName
139-
newRdrName = error "not implemented"
140137
-------------------------------------------------------------------------------
141138
-- Reference finding
142139

stack-9.2.1.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ flags:
101101
hlint: false
102102
importLens: false
103103
ormolu: false
104-
refineImports: false
105104
retrie: false
106105
splice: false
107106
stylishhaskell: false

0 commit comments

Comments
 (0)