From 36e0304a61f2d13f0a26e2186fb6c20cca2755f0 Mon Sep 17 00:00:00 2001 From: Nick Suchecki Date: Sun, 4 Sep 2022 22:22:26 -0400 Subject: [PATCH 01/12] Change Type Signature Plugin buildable with 9.4 --- .github/workflows/test.yml | 2 +- haskell-language-server.cabal | 2 +- .../hls-change-type-signature-plugin.cabal | 12 +++--------- .../hls-change-type-signature-plugin/test/Main.hs | 5 +++-- .../test/testdata/TRigidType2.expected.hs | 4 ++++ .../test/testdata/TRigidType2.hs | 4 ++++ 6 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 plugins/hls-change-type-signature-plugin/test/testdata/TRigidType2.expected.hs create mode 100644 plugins/hls-change-type-signature-plugin/test/testdata/TRigidType2.hs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f811cd50bd..7d6c87b752 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -252,7 +252,7 @@ jobs: name: Test hls-code-range-plugin test suite run: cabal test hls-code-range-plugin --test-options="$TEST_OPTS" || cabal test hls-code-range-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-code-range-plugin --test-options="$TEST_OPTS" - - if: matrix.test && matrix.ghc != '9.4.2' + - if: matrix.test name: Test hls-change-type-signature test suite run: cabal test hls-change-type-signature-plugin --test-options="$TEST_OPTS" || cabal test hls-change-type-signature-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-change-type-signature-plugin --test-options="$TEST_OPTS" diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 26387f85b0..38a08c9332 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -324,7 +324,7 @@ common codeRange cpp-options: -Dhls_codeRange common changeTypeSignature - if flag(changeTypeSignature) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(changeTypeSignature) build-depends: hls-change-type-signature-plugin ^>= 1.0 cpp-options: -Dhls_changeTypeSignature diff --git a/plugins/hls-change-type-signature-plugin/hls-change-type-signature-plugin.cabal b/plugins/hls-change-type-signature-plugin/hls-change-type-signature-plugin.cabal index f93f303788..36449f006e 100644 --- a/plugins/hls-change-type-signature-plugin/hls-change-type-signature-plugin.cabal +++ b/plugins/hls-change-type-signature-plugin/hls-change-type-signature-plugin.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: hls-change-type-signature-plugin -version: 1.0.1.0 +version: 1.0.1.1 synopsis: Change a declarations type signature with a Code Action description: Please see the README on GitHub at @@ -19,10 +19,7 @@ extra-source-files: test/testdata/*.yaml library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True exposed-modules: Ide.Plugin.ChangeTypeSignature hs-source-dirs: src build-depends: @@ -50,10 +47,7 @@ library test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test diff --git a/plugins/hls-change-type-signature-plugin/test/Main.hs b/plugins/hls-change-type-signature-plugin/test/Main.hs index ba5d917754..3aba829522 100644 --- a/plugins/hls-change-type-signature-plugin/test/Main.hs +++ b/plugins/hls-change-type-signature-plugin/test/Main.hs @@ -9,7 +9,7 @@ import Ide.Plugin.ChangeTypeSignature (errorMessageRegexes) import qualified Ide.Plugin.ChangeTypeSignature as ChangeTypeSignature import System.FilePath ((<.>), ()) import Test.Hls (CodeAction (..), Command, - GhcVersion (GHC92), IdeState, + GhcVersion (..), IdeState, PluginDescriptor, Position (Position), Range (Range), Session, @@ -38,7 +38,8 @@ test :: TestTree test = testGroup "changeTypeSignature" [ testRegexes , codeActionTest "TExpectedActual" 4 11 - , knownBrokenForGhcVersions [GHC92] "Error Message in 9.2 does not provide enough info" $ codeActionTest "TRigidType" 4 14 + , knownBrokenForGhcVersions [GHC92, GHC94] "Error Message in 9.2/9.4 does not provide enough info" $ codeActionTest "TRigidType" 4 14 + , codeActionTest "TRigidType2" 4 6 , codeActionTest "TLocalBinding" 7 22 , codeActionTest "TLocalBindingShadow1" 11 8 , codeActionTest "TLocalBindingShadow2" 7 22 diff --git a/plugins/hls-change-type-signature-plugin/test/testdata/TRigidType2.expected.hs b/plugins/hls-change-type-signature-plugin/test/testdata/TRigidType2.expected.hs new file mode 100644 index 0000000000..bbfb96cb81 --- /dev/null +++ b/plugins/hls-change-type-signature-plugin/test/testdata/TRigidType2.expected.hs @@ -0,0 +1,4 @@ +module TRigidType2 where + +test :: [Int] -> Int +test = head diff --git a/plugins/hls-change-type-signature-plugin/test/testdata/TRigidType2.hs b/plugins/hls-change-type-signature-plugin/test/testdata/TRigidType2.hs new file mode 100644 index 0000000000..9a6c25807c --- /dev/null +++ b/plugins/hls-change-type-signature-plugin/test/testdata/TRigidType2.hs @@ -0,0 +1,4 @@ +module TRigidType2 where + +test :: a -> Int +test = head From e4c5eda71ddb7cc2d6e8553ee203b61685a68610 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Fri, 2 Sep 2022 21:11:43 +0200 Subject: [PATCH 02/12] enable a bunch of plugins that build with ghc 9.4 --- .github/workflows/test.yml | 14 +++++++------- haskell-language-server.cabal | 14 +++++++------- .../hls-call-hierarchy-plugin.cabal | 10 ++-------- .../hls-explicit-fixity-plugin.cabal | 10 ++-------- .../hls-explicit-imports-plugin.cabal | 10 ++-------- .../hls-module-name-plugin.cabal | 10 ++-------- .../hls-pragmas-plugin/hls-pragmas-plugin.cabal | 10 ++-------- .../hls-qualify-imported-names-plugin.cabal | 10 ++-------- .../hls-refine-imports-plugin.cabal | 10 ++-------- 9 files changed, 28 insertions(+), 70 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7d6c87b752..8199477be7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -180,7 +180,7 @@ jobs: name: Test hls-class-plugin run: cabal test hls-class-plugin --test-options="$TEST_OPTS" || cabal test hls-class-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-class-plugin --test-options="$TEST_OPTS" - - if: matrix.test && matrix.ghc != '9.4.2' + - if: matrix.test name: Test hls-pragmas-plugin run: cabal test hls-pragmas-plugin --test-options="$TEST_OPTS" || cabal test hls-pragmas-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-pragmas-plugin --test-options="$TEST_OPTS" @@ -212,15 +212,15 @@ 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.4.2' + - 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" - - if: matrix.test && matrix.ghc != '9.4.2' + - if: matrix.test name: Test hls-explicit-imports-plugin test suite run: cabal test hls-explicit-imports-plugin --test-options="$TEST_OPTS" || cabal test hls-explicit-imports-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-explicit-imports-plugin --test-options="$TEST_OPTS" - - if: matrix.test && matrix.ghc != '9.4.2' + - if: matrix.test name: Test hls-call-hierarchy-plugin test suite run: cabal test hls-call-hierarchy-plugin --test-options="$TEST_OPTS" || 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" @@ -236,7 +236,7 @@ jobs: name: Test hls-stan-plugin test suite run: cabal test hls-stan-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-stan-plugin --test-options="$TEST_OPTS" - - if: matrix.test && matrix.ghc != '9.4.2' + - 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" @@ -244,7 +244,7 @@ jobs: name: Test hls-alternate-number-format-plugin test suite run: cabal test hls-alternate-number-format-plugin --test-options="$TEST_OPTS" || cabal test hls-alternate-number-format-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-alternate-number-format-plugin --test-options="$TEST_OPTS" - - if: matrix.test && matrix.ghc != '9.4.2' + - if: matrix.test name: Test hls-qualify-imported-names-plugin test suite run: cabal test hls-qualify-imported-names-plugin --test-options="$TEST_OPTS" || cabal test hls-qualify-imported-names-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-qualify-imported-names-plugin --test-options="$TEST_OPTS" @@ -260,7 +260,7 @@ jobs: name: Test hls-gadt-plugin test suit run: cabal test hls-gadt-plugin --test-options="$TEST_OPTS" || cabal test hls-gadt-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-gadt-plugin --test-options="$TEST_OPTS" - - if: matrix.test && matrix.ghc != '9.4.2' + - if: matrix.test name: Test hls-explicit-fixity-plugin test suite run: cabal test hls-explicit-fixity-plugin --test-options="$TEST_OPTS" || cabal test hls-explicit-fixity-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-explicit-fixity-plugin --test-options="$TEST_OPTS" diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 38a08c9332..1040496490 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -244,7 +244,7 @@ common class cpp-options: -Dhls_class common callHierarchy - if flag(callHierarchy) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(callHierarchy) build-depends: hls-call-hierarchy-plugin ^>= 1.0 cpp-options: -Dhls_callHierarchy @@ -259,12 +259,12 @@ common eval cpp-options: -Dhls_eval common importLens - if flag(importLens) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(importLens) build-depends: hls-explicit-imports-plugin ^>= 1.1 cpp-options: -Dhls_importLens common refineImports - if flag(refineImports) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(refineImports) build-depends: hls-refine-imports-plugin ^>=1.0 cpp-options: -Dhls_refineImports @@ -294,12 +294,12 @@ common stan cpp-options: -Dhls_stan common moduleName - if flag(moduleName) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(moduleName) build-depends: hls-module-name-plugin ^>= 1.0 cpp-options: -Dhls_moduleName common pragmas - if flag(pragmas) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(pragmas) build-depends: hls-pragmas-plugin ^>= 1.0 cpp-options: -Dhls_pragmas @@ -314,7 +314,7 @@ common alternateNumberFormat cpp-options: -Dhls_alternateNumberFormat common qualifyImportedNames - if flag(qualifyImportedNames) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(qualifyImportedNames) build-depends: hls-qualify-imported-names-plugin ^>=1.0 cpp-options: -Dhls_qualifyImportedNames @@ -334,7 +334,7 @@ common gadt cpp-options: -Dhls_gadt common explicitFixity - if flag(explicitFixity) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(explicitFixity) build-depends: hls-explicit-fixity-plugin ^>= 1.0 cpp-options: -DexplicitFixity diff --git a/plugins/hls-call-hierarchy-plugin/hls-call-hierarchy-plugin.cabal b/plugins/hls-call-hierarchy-plugin/hls-call-hierarchy-plugin.cabal index dc5cd8e398..ce2fb87f72 100644 --- a/plugins/hls-call-hierarchy-plugin/hls-call-hierarchy-plugin.cabal +++ b/plugins/hls-call-hierarchy-plugin/hls-call-hierarchy-plugin.cabal @@ -16,10 +16,7 @@ extra-source-files: test/testdata/*.hs library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True exposed-modules: Ide.Plugin.CallHierarchy other-modules: Ide.Plugin.CallHierarchy.Internal @@ -47,10 +44,7 @@ library default-extensions: DataKinds test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test diff --git a/plugins/hls-explicit-fixity-plugin/hls-explicit-fixity-plugin.cabal b/plugins/hls-explicit-fixity-plugin/hls-explicit-fixity-plugin.cabal index dc865f2c12..1b185c28e8 100644 --- a/plugins/hls-explicit-fixity-plugin/hls-explicit-fixity-plugin.cabal +++ b/plugins/hls-explicit-fixity-plugin/hls-explicit-fixity-plugin.cabal @@ -16,10 +16,7 @@ extra-source-files: test/testdata/*.hs library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True exposed-modules: Ide.Plugin.ExplicitFixity hs-source-dirs: src @@ -43,10 +40,7 @@ library default-extensions: DataKinds test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test diff --git a/plugins/hls-explicit-imports-plugin/hls-explicit-imports-plugin.cabal b/plugins/hls-explicit-imports-plugin/hls-explicit-imports-plugin.cabal index fb73ff894f..3918ee5ac0 100644 --- a/plugins/hls-explicit-imports-plugin/hls-explicit-imports-plugin.cabal +++ b/plugins/hls-explicit-imports-plugin/hls-explicit-imports-plugin.cabal @@ -16,10 +16,7 @@ extra-source-files: test/testdata/*.yaml library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True exposed-modules: Ide.Plugin.ExplicitImports hs-source-dirs: src build-depends: @@ -41,10 +38,7 @@ library TypeOperators test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test 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 08c17e2349..e9dc57f577 100644 --- a/plugins/hls-module-name-plugin/hls-module-name-plugin.cabal +++ b/plugins/hls-module-name-plugin/hls-module-name-plugin.cabal @@ -20,10 +20,7 @@ extra-source-files: test/testdata/**/*.project library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True exposed-modules: Ide.Plugin.ModuleName hs-source-dirs: src build-depends: @@ -41,10 +38,7 @@ library default-language: Haskell2010 test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test diff --git a/plugins/hls-pragmas-plugin/hls-pragmas-plugin.cabal b/plugins/hls-pragmas-plugin/hls-pragmas-plugin.cabal index 76f64083bd..02f256a4db 100644 --- a/plugins/hls-pragmas-plugin/hls-pragmas-plugin.cabal +++ b/plugins/hls-pragmas-plugin/hls-pragmas-plugin.cabal @@ -18,10 +18,7 @@ extra-source-files: test/testdata/*.yaml library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True exposed-modules: Ide.Plugin.Pragmas hs-source-dirs: src build-depends: @@ -41,10 +38,7 @@ library default-language: Haskell2010 test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test diff --git a/plugins/hls-qualify-imported-names-plugin/hls-qualify-imported-names-plugin.cabal b/plugins/hls-qualify-imported-names-plugin/hls-qualify-imported-names-plugin.cabal index 8990e05f09..0425eff7df 100644 --- a/plugins/hls-qualify-imported-names-plugin/hls-qualify-imported-names-plugin.cabal +++ b/plugins/hls-qualify-imported-names-plugin/hls-qualify-imported-names-plugin.cabal @@ -18,10 +18,7 @@ extra-source-files: test/data/*.yaml library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True exposed-modules: Ide.Plugin.QualifyImportedNames hs-source-dirs: src build-depends: @@ -45,10 +42,7 @@ library TypeOperators test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test diff --git a/plugins/hls-refine-imports-plugin/hls-refine-imports-plugin.cabal b/plugins/hls-refine-imports-plugin/hls-refine-imports-plugin.cabal index ebbe0b271c..7d9a656e69 100644 --- a/plugins/hls-refine-imports-plugin/hls-refine-imports-plugin.cabal +++ b/plugins/hls-refine-imports-plugin/hls-refine-imports-plugin.cabal @@ -16,10 +16,7 @@ extra-source-files: test/testdata/*.yaml library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True exposed-modules: Ide.Plugin.RefineImports hs-source-dirs: src build-depends: @@ -42,10 +39,7 @@ library TypeOperators test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True + buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test From d3ac0f44d15242da18354a89cee6524de3c56315 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sat, 3 Sep 2022 11:12:07 +0200 Subject: [PATCH 03/12] refactor onlyWorkForGhcVersions --- hls-test-utils/src/Test/Hls/Util.hs | 6 +++--- plugins/hls-gadt-plugin/test/Main.hs | 8 ++++---- plugins/hls-pragmas-plugin/test/Main.hs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hls-test-utils/src/Test/Hls/Util.hs b/hls-test-utils/src/Test/Hls/Util.hs index 322a2bf867..7a608e6392 100644 --- a/hls-test-utils/src/Test/Hls/Util.hs +++ b/hls-test-utils/src/Test/Hls/Util.hs @@ -153,9 +153,9 @@ ignoreForGhcVersions :: [GhcVersion] -> String -> TestTree -> TestTree ignoreForGhcVersions vers = ignoreInEnv (map GhcVer vers) -- | Mark as broken if GHC does not match only work versions. -onlyWorkForGhcVersions :: [GhcVersion] -> String -> TestTree -> TestTree -onlyWorkForGhcVersions vers reason = - if ghcVersion `elem` vers +onlyWorkForGhcVersions :: (GhcVersion -> Bool) -> String -> TestTree -> TestTree +onlyWorkForGhcVersions pred reason = + if pred ghcVersion then id else expectFailBecause reason diff --git a/plugins/hls-gadt-plugin/test/Main.hs b/plugins/hls-gadt-plugin/test/Main.hs index 58c23422a8..5d266cd54d 100644 --- a/plugins/hls-gadt-plugin/test/Main.hs +++ b/plugins/hls-gadt-plugin/test/Main.hs @@ -35,13 +35,13 @@ tests = testGroup "GADT" , runTest "ConstuctorContext" "ConstructorContext" 2 0 2 38 , runTest "Context" "Context" 2 0 4 41 , runTest "Pragma" "Pragma" 2 0 3 29 - , onlyWorkForGhcVersions [GHC92] "Single deriving has different output on ghc9.2" $ + , onlyWorkForGhcVersions (==GHC92) "Single deriving has different output on ghc9.2" $ runTest "SingleDerivingGHC92" "SingleDerivingGHC92" 2 0 3 14 - , knownBrokenForGhcVersions [GHC92] "Single deriving has different output on ghc9.2" $ + , knownBrokenForGhcVersions (==GHC92) "Single deriving has different output on ghc9.2" $ runTest "SingleDeriving" "SingleDeriving" 2 0 3 14 - , onlyWorkForGhcVersions [GHC92] "only ghc-9.2 enabled GADTs pragma implicitly" $ + , onlyWorkForGhcVersions (==GHC92) "only ghc-9.2 enabled GADTs pragma implicitly" $ gadtPragmaTest "ghc-9.2 don't need to insert GADTs pragma" False - , knownBrokenForGhcVersions [GHC92] "ghc-9.2 has enabled GADTs pragma implicitly" $ + , knownBrokenForGhcVersions (==GHC92) "ghc-9.2 has enabled GADTs pragma implicitly" $ gadtPragmaTest "insert pragma" True ] diff --git a/plugins/hls-pragmas-plugin/test/Main.hs b/plugins/hls-pragmas-plugin/test/Main.hs index ec146ef2ef..47cbc0b25c 100644 --- a/plugins/hls-pragmas-plugin/test/Main.hs +++ b/plugins/hls-pragmas-plugin/test/Main.hs @@ -116,7 +116,7 @@ completionTests = , completionTest "completes language extensions case insensitive" "Completion.hs" "lAnGuaGe Overloaded" "OverloadedStrings" Nothing Nothing Nothing [0, 4, 0, 34, 0, 24] , completionTest "completes the Strict language extension" "Completion.hs" "Str" "Strict" Nothing Nothing Nothing [0, 13, 0, 31, 0, 16] , completionTest "completes No- language extensions" "Completion.hs" "NoOverload" "NoOverloadedStrings" Nothing Nothing Nothing [0, 13, 0, 31, 0, 23] - , onlyWorkForGhcVersions [GHC92] "GHC2021 flag introduced since ghc9.2" $ + , onlyWorkForGhcVersions (==GHC92) "GHC2021 flag introduced since ghc9.2" $ completionTest "completes GHC2021 extensions" "Completion.hs" "ghc" "GHC2021" Nothing Nothing Nothing [0, 13, 0, 31, 0, 16] ] From 1686b29708ec5c4d9df1509602f8e91ef7468323 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sat, 3 Sep 2022 22:02:16 +0200 Subject: [PATCH 04/12] Tag 9.4 regressions in HLS pragmas test suite --- plugins/hls-pragmas-plugin/test/Main.hs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/plugins/hls-pragmas-plugin/test/Main.hs b/plugins/hls-pragmas-plugin/test/Main.hs index 47cbc0b25c..eb3f4e7da4 100644 --- a/plugins/hls-pragmas-plugin/test/Main.hs +++ b/plugins/hls-pragmas-plugin/test/Main.hs @@ -47,14 +47,14 @@ codeActionTests = , codeActionTest "Pragma then line haddock then newline line comment splits line" "PragmaThenLineHaddockNewlineLineComment" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "does not add pragma after OPTIONS_GHC pragma located after a declaration" "OptionsGhcAfterDecl" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "adds LANGUAGE with no other pragmas at start ignoring later INLINE pragma" "AddPragmaIgnoreInline" [("Add \"TupleSections\"", "Contains TupleSections code action")] - , codeActionTest "adds LANGUAGE before Doc comments after interchanging pragmas" "BeforeDocInterchanging" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] + , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "adds LANGUAGE before Doc comments after interchanging pragmas" "BeforeDocInterchanging" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] , codeActionTest "Add language after altering OPTIONS_GHC and Language" "AddLanguagePragmaAfterInterchaningOptsGhcAndLangs" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "Add language after pragmas with non standard space between prefix and name" "AddPragmaWithNonStandardSpacingInPrecedingPragmas" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "adds LANGUAGE after OptGHC at start ignoring later INLINE pragma" "AddPragmaAfterOptsGhcIgnoreInline" [("Add \"TupleSections\"", "Contains TupleSections code action")] - , codeActionTest "adds LANGUAGE ignore later Ann pragma" "AddPragmaIgnoreLaterAnnPragma" [("Add \"BangPatterns\"", "Contains BangPatterns code action")] - , codeActionTest "adds LANGUAGE after interchanging pragmas ignoring later Ann pragma" "AddLanguageAfterInterchaningIgnoringLaterAnn" [("Add \"BangPatterns\"", "Contains BangPatterns code action")] - , codeActionTest "adds LANGUAGE after OptGHC preceded by another language pragma" "AddLanguageAfterLanguageThenOptsGhc" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] - , codeActionTest "adds LANGUAGE pragma after shebang and last language pragma" "AfterShebangAndPragma" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] + , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "adds LANGUAGE ignore later Ann pragma" "AddPragmaIgnoreLaterAnnPragma" [("Add \"BangPatterns\"", "Contains BangPatterns code action")] + , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "adds LANGUAGE after interchanging pragmas ignoring later Ann pragma" "AddLanguageAfterInterchaningIgnoringLaterAnn" [("Add \"BangPatterns\"", "Contains BangPatterns code action")] + , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "adds LANGUAGE after OptGHC preceded by another language pragma" "AddLanguageAfterLanguageThenOptsGhc" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] + , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "adds LANGUAGE pragma after shebang and last language pragma" "AfterShebangAndPragma" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] , codeActionTest "adds above module keyword on first line" "ModuleOnFirstLine" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "adds LANGUAGE pragma after GHC_OPTIONS" "AfterGhcOptions" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "adds LANGUAGE pragma after shebang and GHC_OPTIONS" "AfterShebangAndOpts" [("Add \"TupleSections\"", "Contains TupleSections code action")] @@ -63,14 +63,17 @@ codeActionTests = , codeActionTest "adds LANGUAGE pragma after all others ignoring multiple later INLINE pragma" "AfterAllWithMultipleInlines" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "adds LANGUAGE pragma correctly ignoring later INLINE pragma" "AddLanguagePragma" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "adds TypeApplications pragma" "TypeApplications" [("Add \"TypeApplications\"", "Contains TypeApplications code action")] - , codeActionTest "after shebang" "AfterShebang" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] - , codeActionTest "append to existing pragmas" "AppendToExisting" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] - , codeActionTest "before doc comments" "BeforeDocComment" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] + , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "after shebang" "AfterShebang" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] + , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "append to existing pragmas" "AppendToExisting" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] + , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "before doc comments" "BeforeDocComment" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] , codeActionTest "before doc comments" "MissingSignatures" [("Disable \"missing-signatures\" warnings", "Contains missing-signatures code action")] , codeActionTest "before doc comments" "UnusedImports" [("Disable \"unused-imports\" warnings", "Contains unused-imports code action")] , codeActionTest "adds TypeSynonymInstances pragma" "NeedsPragmas" [("Add \"TypeSynonymInstances\"", "Contains TypeSynonymInstances code action"), ("Add \"FlexibleInstances\"", "Contains FlexibleInstances code action")] ] +ghc94regression :: String +ghc94regression = "to be reported" + codeActionTest :: String -> FilePath -> [(T.Text, String)] -> TestTree codeActionTest testComment fp actions = goldenWithPragmas testComment fp $ \doc -> do @@ -88,7 +91,7 @@ codeActionTests' :: TestTree codeActionTests' = testGroup "additional code actions" [ - goldenWithPragmas "no duplication" "NamedFieldPuns" $ \doc -> do + onlyWorkForGhcVersions (>GHC94) ghc94regression $ goldenWithPragmas "no duplication" "NamedFieldPuns" $ \doc -> do _ <- waitForDiagnosticsFrom doc cas <- map fromAction <$> getCodeActions doc (Range (Position 8 9) (Position 8 9)) ca <- liftIO $ case cas of @@ -116,7 +119,7 @@ completionTests = , completionTest "completes language extensions case insensitive" "Completion.hs" "lAnGuaGe Overloaded" "OverloadedStrings" Nothing Nothing Nothing [0, 4, 0, 34, 0, 24] , completionTest "completes the Strict language extension" "Completion.hs" "Str" "Strict" Nothing Nothing Nothing [0, 13, 0, 31, 0, 16] , completionTest "completes No- language extensions" "Completion.hs" "NoOverload" "NoOverloadedStrings" Nothing Nothing Nothing [0, 13, 0, 31, 0, 23] - , onlyWorkForGhcVersions (==GHC92) "GHC2021 flag introduced since ghc9.2" $ + , onlyWorkForGhcVersions (>=GHC92) "GHC2021 flag introduced since ghc9.2" $ completionTest "completes GHC2021 extensions" "Completion.hs" "ghc" "GHC2021" Nothing Nothing Nothing [0, 13, 0, 31, 0, 16] ] From 69d71ff28233853035b5e5f1788b3aa182cb4ca6 Mon Sep 17 00:00:00 2001 From: Zubin Duggal Date: Sun, 4 Sep 2022 01:39:11 +0530 Subject: [PATCH 05/12] Restore hints in diagnostic messages --- ghcide/src/Development/IDE/GHC/Compat.hs | 11 ++++++++--- ghcide/src/Development/IDE/GHC/Error.hs | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat.hs b/ghcide/src/Development/IDE/GHC/Compat.hs index 157ddcde4c..8b322f6c3b 100644 --- a/ghcide/src/Development/IDE/GHC/Compat.hs +++ b/ghcide/src/Development/IDE/GHC/Compat.hs @@ -17,7 +17,7 @@ module Development.IDE.GHC.Compat( NameCacheUpdater(..), #if MIN_VERSION_ghc(9,3,0) getMessages, - diagnosticMessage, + renderDiagnosticMessageWithHints, nameEnvElts, #else upNameCache, @@ -402,7 +402,7 @@ type WarnMsg = MsgEnvelope DecoratedSDoc getMessages' :: PState -> DynFlags -> (Bag WarnMsg, Bag ErrMsg) getMessages' pst dflags = #if MIN_VERSION_ghc(9,3,0) - bimap (fmap (fmap diagnosticMessage) . getMessages) (fmap (fmap diagnosticMessage) . getMessages) $ getPsMessages pst + bimap (fmap (fmap renderDiagnosticMessageWithHints) . getMessages) (fmap (fmap renderDiagnosticMessageWithHints) . getMessages) $ getPsMessages pst #else #if MIN_VERSION_ghc(9,2,0) bimap (fmap pprWarning) (fmap pprError) $ @@ -413,11 +413,16 @@ getMessages' pst dflags = #endif #endif +#if MIN_VERSION_ghc(9,3,0) +renderDiagnosticMessageWithHints :: Diagnostic a => a -> DecoratedSDoc +renderDiagnosticMessageWithHints a = unionDecoratedSDoc (diagnosticMessage a) (mkDecorated $ map ppr $ diagnosticHints a) +#endif + #if MIN_VERSION_ghc(9,2,0) pattern PFailedWithErrorMessages :: forall a b. (b -> Bag (MsgEnvelope DecoratedSDoc)) -> ParseResult a pattern PFailedWithErrorMessages msgs #if MIN_VERSION_ghc(9,3,0) - <- PFailed (const . fmap (fmap diagnosticMessage) . getMessages . getPsErrorMessages -> msgs) + <- PFailed (const . fmap (fmap renderDiagnosticMessageWithHints) . getMessages . getPsErrorMessages -> msgs) #else <- PFailed (const . fmap pprError . getErrorMessages -> msgs) #endif diff --git a/ghcide/src/Development/IDE/GHC/Error.hs b/ghcide/src/Development/IDE/GHC/Error.hs index 89c527e404..b16d908c58 100644 --- a/ghcide/src/Development/IDE/GHC/Error.hs +++ b/ghcide/src/Development/IDE/GHC/Error.hs @@ -174,7 +174,7 @@ catchSrcErrors dflags fromWhere ghcM = do ghcExceptionToDiagnostics dflags = return . Left . diagFromGhcException fromWhere dflags sourceErrorToDiagnostics dflags = return . Left . diagFromErrMsgs fromWhere dflags #if MIN_VERSION_ghc(9,3,0) - . fmap (fmap Compat.diagnosticMessage) . Compat.getMessages + . fmap (fmap Compat.renderDiagnosticMessageWithHints) . Compat.getMessages #endif . srcErrorMessages From 3d2549925107623f66a16459eb5fb612a2ca08c4 Mon Sep 17 00:00:00 2001 From: Zubin Duggal Date: Sun, 4 Sep 2022 01:47:31 +0530 Subject: [PATCH 06/12] Restore more hints in diagnostic messages --- ghcide/src/Development/IDE/GHC/Compat.hs | 5 ----- ghcide/src/Development/IDE/GHC/Compat/Outputable.hs | 8 +++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat.hs b/ghcide/src/Development/IDE/GHC/Compat.hs index 8b322f6c3b..ae4d57e715 100644 --- a/ghcide/src/Development/IDE/GHC/Compat.hs +++ b/ghcide/src/Development/IDE/GHC/Compat.hs @@ -413,11 +413,6 @@ getMessages' pst dflags = #endif #endif -#if MIN_VERSION_ghc(9,3,0) -renderDiagnosticMessageWithHints :: Diagnostic a => a -> DecoratedSDoc -renderDiagnosticMessageWithHints a = unionDecoratedSDoc (diagnosticMessage a) (mkDecorated $ map ppr $ diagnosticHints a) -#endif - #if MIN_VERSION_ghc(9,2,0) pattern PFailedWithErrorMessages :: forall a b. (b -> Bag (MsgEnvelope DecoratedSDoc)) -> ParseResult a pattern PFailedWithErrorMessages msgs diff --git a/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs b/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs index 084a48a04b..7fb9264422 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs @@ -19,6 +19,7 @@ module Development.IDE.GHC.Compat.Outputable ( PsError, #if MIN_VERSION_ghc(9,3,0) DiagnosticReason(..), + renderDiagnosticMessageWithHints, #else pprWarning, pprError, @@ -201,9 +202,14 @@ mkPrintUnqualifiedDefault env = HscTypes.mkPrintUnqualified (hsc_dflags env) #endif +#if MIN_VERSION_ghc(9,3,0) +renderDiagnosticMessageWithHints :: Diagnostic a => a -> DecoratedSDoc +renderDiagnosticMessageWithHints a = Error.unionDecoratedSDoc (diagnosticMessage a) (mkDecorated $ map ppr $ diagnosticHints a) +#endif + #if MIN_VERSION_ghc(9,3,0) mkWarnMsg :: DynFlags -> Maybe DiagnosticReason -> b -> SrcSpan -> PrintUnqualified -> SDoc -> MsgEnvelope DecoratedSDoc -mkWarnMsg df reason _logFlags l st doc = fmap diagnosticMessage $ mkMsgEnvelope (initDiagOpts df) l st (mkPlainDiagnostic (fromMaybe WarningWithoutFlag reason) [] doc) +mkWarnMsg df reason _logFlags l st doc = fmap renderDiagnosticMessageWithHints $ mkMsgEnvelope (initDiagOpts df) l st (mkPlainDiagnostic (fromMaybe WarningWithoutFlag reason) [] doc) #else mkWarnMsg :: a -> b -> DynFlags -> SrcSpan -> PrintUnqualified -> SDoc -> MsgEnvelope DecoratedSDoc mkWarnMsg _ _ = From 488a33b0b87ed8147496ded0e6dca822749f7b49 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sat, 3 Sep 2022 23:12:17 +0200 Subject: [PATCH 07/12] pragmas tests no longer regressing --- plugins/hls-pragmas-plugin/test/Main.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/hls-pragmas-plugin/test/Main.hs b/plugins/hls-pragmas-plugin/test/Main.hs index eb3f4e7da4..0b5941a88a 100644 --- a/plugins/hls-pragmas-plugin/test/Main.hs +++ b/plugins/hls-pragmas-plugin/test/Main.hs @@ -47,14 +47,14 @@ codeActionTests = , codeActionTest "Pragma then line haddock then newline line comment splits line" "PragmaThenLineHaddockNewlineLineComment" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "does not add pragma after OPTIONS_GHC pragma located after a declaration" "OptionsGhcAfterDecl" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "adds LANGUAGE with no other pragmas at start ignoring later INLINE pragma" "AddPragmaIgnoreInline" [("Add \"TupleSections\"", "Contains TupleSections code action")] - , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "adds LANGUAGE before Doc comments after interchanging pragmas" "BeforeDocInterchanging" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] + , codeActionTest "adds LANGUAGE before Doc comments after interchanging pragmas" "BeforeDocInterchanging" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] , codeActionTest "Add language after altering OPTIONS_GHC and Language" "AddLanguagePragmaAfterInterchaningOptsGhcAndLangs" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "Add language after pragmas with non standard space between prefix and name" "AddPragmaWithNonStandardSpacingInPrecedingPragmas" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "adds LANGUAGE after OptGHC at start ignoring later INLINE pragma" "AddPragmaAfterOptsGhcIgnoreInline" [("Add \"TupleSections\"", "Contains TupleSections code action")] - , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "adds LANGUAGE ignore later Ann pragma" "AddPragmaIgnoreLaterAnnPragma" [("Add \"BangPatterns\"", "Contains BangPatterns code action")] - , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "adds LANGUAGE after interchanging pragmas ignoring later Ann pragma" "AddLanguageAfterInterchaningIgnoringLaterAnn" [("Add \"BangPatterns\"", "Contains BangPatterns code action")] - , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "adds LANGUAGE after OptGHC preceded by another language pragma" "AddLanguageAfterLanguageThenOptsGhc" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] - , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "adds LANGUAGE pragma after shebang and last language pragma" "AfterShebangAndPragma" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] + , codeActionTest "adds LANGUAGE ignore later Ann pragma" "AddPragmaIgnoreLaterAnnPragma" [("Add \"BangPatterns\"", "Contains BangPatterns code action")] + , codeActionTest "adds LANGUAGE after interchanging pragmas ignoring later Ann pragma" "AddLanguageAfterInterchaningIgnoringLaterAnn" [("Add \"BangPatterns\"", "Contains BangPatterns code action")] + , codeActionTest "adds LANGUAGE after OptGHC preceded by another language pragma" "AddLanguageAfterLanguageThenOptsGhc" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] + , codeActionTest "adds LANGUAGE pragma after shebang and last language pragma" "AfterShebangAndPragma" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] , codeActionTest "adds above module keyword on first line" "ModuleOnFirstLine" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "adds LANGUAGE pragma after GHC_OPTIONS" "AfterGhcOptions" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "adds LANGUAGE pragma after shebang and GHC_OPTIONS" "AfterShebangAndOpts" [("Add \"TupleSections\"", "Contains TupleSections code action")] @@ -63,9 +63,9 @@ codeActionTests = , codeActionTest "adds LANGUAGE pragma after all others ignoring multiple later INLINE pragma" "AfterAllWithMultipleInlines" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "adds LANGUAGE pragma correctly ignoring later INLINE pragma" "AddLanguagePragma" [("Add \"TupleSections\"", "Contains TupleSections code action")] , codeActionTest "adds TypeApplications pragma" "TypeApplications" [("Add \"TypeApplications\"", "Contains TypeApplications code action")] - , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "after shebang" "AfterShebang" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] - , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "append to existing pragmas" "AppendToExisting" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] - , onlyWorkForGhcVersions (>GHC94) ghc94regression $ codeActionTest "before doc comments" "BeforeDocComment" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] + , codeActionTest "after shebang" "AfterShebang" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] + , codeActionTest "append to existing pragmas" "AppendToExisting" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] + , codeActionTest "before doc comments" "BeforeDocComment" [("Add \"NamedFieldPuns\"", "Contains NamedFieldPuns code action")] , codeActionTest "before doc comments" "MissingSignatures" [("Disable \"missing-signatures\" warnings", "Contains missing-signatures code action")] , codeActionTest "before doc comments" "UnusedImports" [("Disable \"unused-imports\" warnings", "Contains unused-imports code action")] , codeActionTest "adds TypeSynonymInstances pragma" "NeedsPragmas" [("Add \"TypeSynonymInstances\"", "Contains TypeSynonymInstances code action"), ("Add \"FlexibleInstances\"", "Contains FlexibleInstances code action")] @@ -91,7 +91,7 @@ codeActionTests' :: TestTree codeActionTests' = testGroup "additional code actions" [ - onlyWorkForGhcVersions (>GHC94) ghc94regression $ goldenWithPragmas "no duplication" "NamedFieldPuns" $ \doc -> do + goldenWithPragmas "no duplication" "NamedFieldPuns" $ \doc -> do _ <- waitForDiagnosticsFrom doc cas <- map fromAction <$> getCodeActions doc (Range (Position 8 9) (Position 8 9)) ca <- liftIO $ case cas of From 095f1706bb415c9dd3b12c324f7b82d91bed82d1 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Mon, 5 Sep 2022 08:29:35 +0200 Subject: [PATCH 08/12] fixup refactor onlyWorkForGhcVersions --- plugins/hls-gadt-plugin/test/Main.hs | 4 ++-- plugins/hls-refactor-plugin/test/Main.hs | 26 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/hls-gadt-plugin/test/Main.hs b/plugins/hls-gadt-plugin/test/Main.hs index 5d266cd54d..1f99e5f8cc 100644 --- a/plugins/hls-gadt-plugin/test/Main.hs +++ b/plugins/hls-gadt-plugin/test/Main.hs @@ -37,11 +37,11 @@ tests = testGroup "GADT" , runTest "Pragma" "Pragma" 2 0 3 29 , onlyWorkForGhcVersions (==GHC92) "Single deriving has different output on ghc9.2" $ runTest "SingleDerivingGHC92" "SingleDerivingGHC92" 2 0 3 14 - , knownBrokenForGhcVersions (==GHC92) "Single deriving has different output on ghc9.2" $ + , knownBrokenForGhcVersions [GHC92] "Single deriving has different output on ghc9.2" $ runTest "SingleDeriving" "SingleDeriving" 2 0 3 14 , onlyWorkForGhcVersions (==GHC92) "only ghc-9.2 enabled GADTs pragma implicitly" $ gadtPragmaTest "ghc-9.2 don't need to insert GADTs pragma" False - , knownBrokenForGhcVersions (==GHC92) "ghc-9.2 has enabled GADTs pragma implicitly" $ + , knownBrokenForGhcVersions [GHC92] "ghc-9.2 has enabled GADTs pragma implicitly" $ gadtPragmaTest "insert pragma" True ] diff --git a/plugins/hls-refactor-plugin/test/Main.hs b/plugins/hls-refactor-plugin/test/Main.hs index dafbd1e843..2a81b9085e 100644 --- a/plugins/hls-refactor-plugin/test/Main.hs +++ b/plugins/hls-refactor-plugin/test/Main.hs @@ -1,17 +1,17 @@ -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE ImplicitParams #-} +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE PolyKinds #-} -{-# LANGUAGE TypeOperators #-} -{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -Wno-deprecations -Wno-unticked-promoted-constructors #-} module Main @@ -19,34 +19,34 @@ module Main ) where import Control.Applicative.Combinators +import Control.Lens ((^.)) import Control.Monad import Data.Default import Data.Foldable import Data.List.Extra import Data.Maybe import qualified Data.Text as T -import Development.IDE.Test +import Data.Tuple.Extra import Development.IDE.GHC.Util import Development.IDE.Plugin.Completions.Types (extendImportCommandId) +import Development.IDE.Test import Development.IDE.Types.Location import Development.Shake (getDirectoryFilesIO) +import Ide.Types import Language.LSP.Test import Language.LSP.Types hiding (SemanticTokenAbsolute (length, line), SemanticTokenRelative (length), SemanticTokensEdit (_start), mkRange) -import qualified Language.LSP.Types.Lens as L +import qualified Language.LSP.Types as LSP import Language.LSP.Types.Capabilities +import qualified Language.LSP.Types.Lens as L import System.Directory import System.FilePath import System.Info.Extra (isMac, isWindows) import qualified System.IO.Extra import System.IO.Extra hiding (withTempDir) -import Control.Lens ((^.)) -import Data.Tuple.Extra -import Ide.Types -import qualified Language.LSP.Types as LSP import System.Time.Extra import Test.Tasty import Test.Tasty.ExpectedFailure @@ -54,11 +54,11 @@ import Test.Tasty.HUnit import Text.Regex.TDFA ((=~)) -import Test.Hls import Development.IDE.Plugin.CodeAction (matchRegExMultipleImports) +import Test.Hls -import qualified Development.IDE.Plugin.CodeAction as Refactor -import qualified Development.IDE.Plugin.HLS.GhcIde as GhcIde +import qualified Development.IDE.Plugin.CodeAction as Refactor +import qualified Development.IDE.Plugin.HLS.GhcIde as GhcIde main :: IO () main = defaultTestRunner tests From 1f6ff681d494287d37c163f124abfa98cf8418c4 Mon Sep 17 00:00:00 2001 From: Zubin Duggal Date: Tue, 6 Sep 2022 14:17:53 +0530 Subject: [PATCH 09/12] warnings --- hls-test-utils/src/Test/Hls/Util.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hls-test-utils/src/Test/Hls/Util.hs b/hls-test-utils/src/Test/Hls/Util.hs index 7a608e6392..5ab1e093dd 100644 --- a/hls-test-utils/src/Test/Hls/Util.hs +++ b/hls-test-utils/src/Test/Hls/Util.hs @@ -154,8 +154,8 @@ ignoreForGhcVersions vers = ignoreInEnv (map GhcVer vers) -- | Mark as broken if GHC does not match only work versions. onlyWorkForGhcVersions :: (GhcVersion -> Bool) -> String -> TestTree -> TestTree -onlyWorkForGhcVersions pred reason = - if pred ghcVersion +onlyWorkForGhcVersions p reason = + if p ghcVersion then id else expectFailBecause reason From 59eb5104475304247d2702290247a5f3a88c770c Mon Sep 17 00:00:00 2001 From: Zubin Duggal Date: Tue, 6 Sep 2022 14:45:05 +0530 Subject: [PATCH 10/12] Accept broken call-hierarchy tests --- plugins/hls-call-hierarchy-plugin/test/Main.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/hls-call-hierarchy-plugin/test/Main.hs b/plugins/hls-call-hierarchy-plugin/test/Main.hs index bbd8c44b93..ca9550a9f3 100644 --- a/plugins/hls-call-hierarchy-plugin/test/Main.hs +++ b/plugins/hls-call-hierarchy-plugin/test/Main.hs @@ -166,13 +166,13 @@ prepareCallHierarchyTests = expected = mkCallHierarchyItemC "A" SkConstructor range selRange oneCaseWithCreate contents 1 13 expected , testGroup "type signature" - [ testCase "next line" $ do + [ knownBrokenForGhcVersions [GHC94] "type signature broken" $ testCase "next line" $ do let contents = T.unlines ["a::Int", "a=3"] range = mkRange 1 0 1 3 selRange = mkRange 1 0 1 1 expected = mkCallHierarchyItemV "a" SkFunction range selRange oneCaseWithCreate contents 0 0 expected - , testCase "multi functions" $ do + , knownBrokenForGhcVersions [GHC94] "type signature broken" $ testCase "multi functions" $ do let contents = T.unlines [ "a,b::Int", "a=3", "b=4"] range = mkRange 2 0 2 3 selRange = mkRange 2 0 2 1 From 6780de754b37efd2ba00505e876049817d55f138 Mon Sep 17 00:00:00 2001 From: Zubin Duggal Date: Tue, 6 Sep 2022 14:53:29 +0530 Subject: [PATCH 11/12] Make hls-code-range-plugin buildable on 9.4 by removing usused exactprint dependencies --- haskell-language-server.cabal | 2 +- .../hls-code-range-plugin.cabal | 9 --------- .../src/Ide/Plugin/CodeRange.hs | 6 +----- .../src/Ide/Plugin/CodeRange/Rules.hs | 12 ++++-------- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 1040496490..24a9fcdfe5 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -319,7 +319,7 @@ common qualifyImportedNames cpp-options: -Dhls_qualifyImportedNames common codeRange - if flag(codeRange) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(codeRange) build-depends: hls-code-range-plugin ^>= 1.0 cpp-options: -Dhls_codeRange diff --git a/plugins/hls-code-range-plugin/hls-code-range-plugin.cabal b/plugins/hls-code-range-plugin/hls-code-range-plugin.cabal index 3d50d0c764..e51ad55268 100644 --- a/plugins/hls-code-range-plugin/hls-code-range-plugin.cabal +++ b/plugins/hls-code-range-plugin/hls-code-range-plugin.cabal @@ -21,10 +21,6 @@ extra-source-files: test/testdata/selection-range/*.txt library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True exposed-modules: Ide.Plugin.CodeRange Ide.Plugin.CodeRange.Rules @@ -42,7 +38,6 @@ library , ghcide ^>=1.6 || ^>=1.7 , hashable , hls-plugin-api ^>=1.3 || ^>=1.4 - , hls-refactor-plugin , lens , lsp , mtl @@ -52,10 +47,6 @@ library , vector test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test diff --git a/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs b/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs index 23a02cfb60..0a48a3467b 100644 --- a/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs +++ b/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs @@ -31,8 +31,6 @@ import Development.IDE.Core.PositionMapping (PositionMapping, fromCurrentPosition, toCurrentRange) import Development.IDE.Types.Logger (Pretty (..)) -import qualified Development.IDE.GHC.ExactPrint as E -import Development.IDE.Plugin.CodeAction import Ide.Plugin.CodeRange.Rules (CodeRange (..), GetCodeRange (..), codeRangeRule) @@ -57,7 +55,7 @@ import Language.LSP.Types (List (List), import Prelude hiding (log, span) descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState -descriptor recorder plId = mkExactprintPluginDescriptor (cmapWithPrio LogExactPrint recorder) $ (defaultPluginDescriptor plId) +descriptor recorder plId = (defaultPluginDescriptor plId) { pluginHandlers = mkPluginHandler STextDocumentSelectionRange selectionRangeHandler -- TODO @sloorush add folding range -- <> mkPluginHandler STextDocumentFoldingRange foldingRangeHandler @@ -65,12 +63,10 @@ descriptor recorder plId = mkExactprintPluginDescriptor (cmapWithPrio LogExactPr } data Log = LogRules Rules.Log - | LogExactPrint E.Log instance Pretty Log where pretty log = case log of LogRules codeRangeLog -> pretty codeRangeLog - LogExactPrint exactPrintLog -> pretty exactPrintLog selectionRangeHandler :: IdeState -> PluginId -> SelectionRangeParams -> LspM c (Either ResponseError (List SelectionRange)) selectionRangeHandler ide _ SelectionRangeParams{..} = do diff --git a/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange/Rules.hs b/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange/Rules.hs index fcd96ffea1..992bf6ca28 100644 --- a/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange/Rules.hs +++ b/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange/Rules.hs @@ -44,12 +44,10 @@ import qualified Data.Vector as V import Development.IDE import Development.IDE.Core.Rules (toIdeResult) import qualified Development.IDE.Core.Shake as Shake -import Development.IDE.GHC.Compat.ExactPrint (Annotated) import Development.IDE.GHC.Compat (HieAST (..), HieASTs (getAsts), - ParsedSource, RefMap) + RefMap) import Development.IDE.GHC.Compat.Util -import Development.IDE.GHC.ExactPrint (GetAnnotatedParsedSource (GetAnnotatedParsedSource)) import GHC.Generics (Generic) import Ide.Plugin.CodeRange.ASTPreProcess (CustomNodeType (..), PreProcessEnv (..), @@ -105,8 +103,8 @@ instance Ord CodeRange where -- | Construct a 'CodeRange'. A valid CodeRange will be returned in any case. If anything go wrong, -- a list of warnings will be returned as 'Log' -buildCodeRange :: HieAST a -> RefMap a -> Annotated ParsedSource -> Writer [Log] CodeRange -buildCodeRange ast refMap _ = do +buildCodeRange :: HieAST a -> RefMap a -> Writer [Log] CodeRange +buildCodeRange ast refMap = do -- We work on 'HieAST', then convert it to 'CodeRange', so that applications such as selection range and folding -- range don't need to care about 'HieAST' -- TODO @sloorush actually use 'Annotated ParsedSource' to handle structures not in 'HieAST' properly (for example comments) @@ -178,9 +176,7 @@ codeRangeRule recorder = HAR{hieAst, refMap} <- lift $ use_ GetHieAst file ast <- maybeToExceptT LogNoAST . MaybeT . pure $ getAsts hieAst Map.!? (coerce . mkFastString . fromNormalizedFilePath) file - annPS <- lift $ use_ GetAnnotatedParsedSource file - - let (codeRange, warnings) = runWriter (buildCodeRange ast refMap annPS) + let (codeRange, warnings) = runWriter (buildCodeRange ast refMap) traverse_ (logWith recorder Warning) warnings pure codeRange From a410fb24550ca9d62846c8c495dcee60f99c23eb Mon Sep 17 00:00:00 2001 From: Zubin Duggal Date: Tue, 6 Sep 2022 16:13:37 +0530 Subject: [PATCH 12/12] Fix hlint --- .hlint.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.hlint.yaml b/.hlint.yaml index 8caaebd8f6..324dbb2d55 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -108,6 +108,7 @@ - Ide.Plugin.Class.ExactPrint - TExpectedActual - TRigidType + - TRigidType2 - RightToLeftFixities - Typeclass - Wingman.Judgements