From b069d695f7d253c68fba28602d31630ed939f4a0 Mon Sep 17 00:00:00 2001 From: mrkun Date: Sun, 16 Jan 2022 17:24:32 +0300 Subject: [PATCH 1/2] Fix module-name plugin on ghc-9.2.1 --- .github/workflows/test.yml | 2 +- cabal-ghc921.project | 2 +- haskell-language-server.cabal | 2 +- plugins/hls-module-name-plugin/hls-module-name-plugin.cabal | 2 +- plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs | 5 +++-- stack-9.2.1.yaml | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59578a98a0..eaf1da11d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -210,7 +210,7 @@ jobs: name: Test hls-hlint-plugin test suite run: cabal test hls-hlint-plugin --test-options="$TEST_OPTS" || cabal test hls-hlint-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-hlint-plugin --test-options="$TEST_OPTS" - - if: matrix.test && matrix.ghc != '9.2.1' + - if: matrix.test name: Test hls-module-name-plugin test suite run: cabal test hls-module-name-plugin --test-options="$TEST_OPTS" || cabal test hls-module-name-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-module-name-plugin --test-options="$TEST_OPTS" diff --git a/cabal-ghc921.project b/cabal-ghc921.project index e51bc3a1f5..1225d4185f 100644 --- a/cabal-ghc921.project +++ b/cabal-ghc921.project @@ -59,7 +59,7 @@ constraints: -eval -haddockComments -hlint - -moduleName + +moduleName -qualifyImportedNames -refineImports -retrie diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 4dc41b4d09..9d7e342670 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -256,7 +256,7 @@ common hlint cpp-options: -Dhlint common moduleName - if flag(moduleName) && (impl(ghc < 9.2.1) || flag(ignore-plugins-ghc-bounds)) + if flag(moduleName) build-depends: hls-module-name-plugin ^>=1.0.0.0 cpp-options: -DmoduleName diff --git a/plugins/hls-module-name-plugin/hls-module-name-plugin.cabal b/plugins/hls-module-name-plugin/hls-module-name-plugin.cabal index a64474c7ea..c8f8e9152d 100644 --- a/plugins/hls-module-name-plugin/hls-module-name-plugin.cabal +++ b/plugins/hls-module-name-plugin/hls-module-name-plugin.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: hls-module-name-plugin -version: 1.0.0.3 +version: 1.0.0.4 synopsis: Module name plugin for Haskell Language Server description: Please see the README on GitHub at diff --git a/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs b/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs index 619bb2062b..c9d0d3aefb 100644 --- a/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs +++ b/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs @@ -2,6 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wall -Wwarn -fno-warn-type-defaults #-} {- | Keep the module name in sync with its file path. @@ -33,7 +34,7 @@ import Development.IDE (GetParsedModule (GetParsedModule), realSrcSpanToRange, runAction, uriToFilePath', use, use_) import Development.IDE.GHC.Compat (GenLocated (L), getSessionDynFlags, - hsmodName, importPaths, + hsmodName, importPaths, locA, pattern RealSrcSpan, pm_parsed_source, unLoc) import Ide.Types @@ -138,7 +139,7 @@ pathModuleNames state normFilePath filePath codeModuleName :: IdeState -> NormalizedFilePath -> IO (Maybe (Range, T.Text)) codeModuleName state nfp = runMaybeT $ do pm <- MaybeT . runAction "ModuleName.GetParsedModule" state $ use GetParsedModule nfp - L (RealSrcSpan l _) m <- MaybeT . pure . hsmodName . unLoc $ pm_parsed_source pm + L (locA -> (RealSrcSpan l _)) m <- MaybeT . pure . hsmodName . unLoc $ pm_parsed_source pm pure (realSrcSpanToRange l, T.pack $ show m) -- traceAs :: Show a => String -> a -> a diff --git a/stack-9.2.1.yaml b/stack-9.2.1.yaml index 690e8a1a03..b8d8ade80c 100644 --- a/stack-9.2.1.yaml +++ b/stack-9.2.1.yaml @@ -97,7 +97,7 @@ flags: haddockComments: false hlint: false importLens: false - moduleName: false + moduleName: true ormolu: false qualifyImportedNames: false refineImports: false From e3f4b663c20352339f5cf5b39e6ff79a7b21ab1a Mon Sep 17 00:00:00 2001 From: Javier Neira Date: Sun, 16 Jan 2022 20:13:10 +0100 Subject: [PATCH 2/2] Removing flag Also enables the plugin --- cabal-ghc921.project | 1 - 1 file changed, 1 deletion(-) diff --git a/cabal-ghc921.project b/cabal-ghc921.project index 1225d4185f..4c18f7ef9e 100644 --- a/cabal-ghc921.project +++ b/cabal-ghc921.project @@ -59,7 +59,6 @@ constraints: -eval -haddockComments -hlint - +moduleName -qualifyImportedNames -refineImports -retrie