Skip to content

[ghc-9.2] Fix refine-imports plugin #2601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all 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 .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ jobs:
name: Test hls-tactics-plugin test suite
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"

- if: matrix.test && matrix.ghc != '9.2.1'
- if: matrix.test
name: Test hls-refine-imports-plugin test suite
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"

Expand Down
1 change: 0 additions & 1 deletion cabal-ghc921.project
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ constraints:
-eval
-haddockComments
-hlint
-refineImports
-retrie
-splice
-stylishhaskell
Expand Down
8 changes: 8 additions & 0 deletions ghcide/src/Development/IDE/GHC/Compat/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ module Development.IDE.GHC.Compat.Core (
getLoc,
getLocA,
locA,
noLocA,
LocatedAn,
#if MIN_VERSION_ghc(9,2,0)
GHC.AnnListItem(..),
Expand Down Expand Up @@ -1021,6 +1022,13 @@ getLocA = GHC.getLocA
getLocA x = GHC.getLoc x
#endif

noLocA :: a -> LocatedAn an a
#if MIN_VERSION_ghc(9,2,0)
noLocA = GHC.noLocA
#else
noLocA = GHC.noLoc
#endif

#if !MIN_VERSION_ghc(9,2,0)
type AnnListItem = SrcLoc.SrcSpan
#endif
Expand Down
2 changes: 1 addition & 1 deletion haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ common importLens
cpp-options: -DimportLens

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: hls-refine-imports-plugin
version: 1.0.0.2
version: 1.0.0.3
synopsis: Refine imports plugin for Haskell Language Server
description:
Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ refineImportsRule = define $ \RefineImports nfp -> do
i@(L lim id@ImportDecl
{ideclName = L _ mn, ideclHiding = Just (hiding, L _ names)})
(newModuleName, avails) = L lim id
{ ideclName = noLoc newModuleName
, ideclHiding = Just (hiding, noLoc newNames)
{ ideclName = noLocA newModuleName
, ideclHiding = Just (hiding, noLocA newNames)
}
where newNames = filter (\n -> any (n `containsAvail`) avails) names
constructImport lim _ = lim
Expand Down Expand Up @@ -247,9 +247,9 @@ refineImportsRule = define $ \RefineImports nfp -> do

--------------------------------------------------------------------------------

mkExplicitEdit :: PositionMapping -> LImportDecl pass -> T.Text -> Maybe TextEdit
mkExplicitEdit :: PositionMapping -> LImportDecl GhcRn -> T.Text -> Maybe TextEdit
mkExplicitEdit posMapping (L src imp) explicit
| RealSrcSpan l _ <- src,
| RealSrcSpan l _ <- locA src,
L _ mn <- ideclName imp,
-- (almost) no one wants to see an refine import list for Prelude
mn /= moduleName pRELUDE,
Expand Down
3 changes: 0 additions & 3 deletions plugins/hls-rename-plugin/src/Ide/Plugin/Rename.hs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ renameModRefs newNameText refs = everywhere $ mkT replace
_ -> Unqual newOccName

newOccName = mkTcOcc $ T.unpack newNameText

newRdrName :: RdrName -> RdrName
newRdrName = error "not implemented"
-------------------------------------------------------------------------------
-- Reference finding

Expand Down
1 change: 0 additions & 1 deletion stack-9.2.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ flags:
hlint: false
importLens: false
ormolu: false
refineImports: false
retrie: false
splice: false
stylishhaskell: false
Expand Down