From ccb5943b26ffa443bd2fb3c8b559071aa9642fcc Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Sun, 31 Aug 2025 13:05:20 +0800 Subject: [PATCH] Replace neat-interpolation with string-interpolate https://github.com/haskell/haskell-language-server/pull/4626#discussion_r2311826643 --- hls-test-utils/hls-test-utils.cabal | 2 +- hls-test-utils/src/Test/Hls.hs | 4 +- hls-test-utils/src/Test/Hls/Util.hs | 4 +- plugins/hls-cabal-plugin/test/Completer.hs | 60 +++++----- plugins/hls-cabal-plugin/test/Context.hs | 128 ++++++++++----------- plugins/hls-cabal-plugin/test/Main.hs | 2 +- 6 files changed, 100 insertions(+), 100 deletions(-) diff --git a/hls-test-utils/hls-test-utils.cabal b/hls-test-utils/hls-test-utils.cabal index 084de98534..a7d904e0d0 100644 --- a/hls-test-utils/hls-test-utils.cabal +++ b/hls-test-utils/hls-test-utils.cabal @@ -49,8 +49,8 @@ library , lsp , lsp-test ^>=0.17 , lsp-types ^>=2.3 - , neat-interpolation , safe-exceptions + , string-interpolate , tasty , tasty-expected-failure , tasty-golden diff --git a/hls-test-utils/src/Test/Hls.hs b/hls-test-utils/src/Test/Hls.hs index 1193b2dd19..0ab203fe36 100644 --- a/hls-test-utils/src/Test/Hls.hs +++ b/hls-test-utils/src/Test/Hls.hs @@ -357,7 +357,7 @@ goldenWithDocInTmpDir languageKind config plugin title tree path desc ext act = -- For example: -- -- @ --- parameterisedCursorTest "Cursor Test" [trimming| +-- parameterisedCursorTest "Cursor Test" [__i| -- foo = 2 -- ^ -- bar = 3 @@ -380,7 +380,7 @@ goldenWithDocInTmpDir languageKind config plugin title tree path desc ext act = -- TODO: Many Haskell and Cabal source may contain '^' characters for good reasons. -- We likely need a way to change the character for certain test cases in the future. -- --- The quasi quoter 'trimming' is very helpful to define such tests, as it additionally +-- The quasi quoter '__i' is very helpful to define such tests, as it additionally -- allows to interpolate haskell values and functions. We reexport this quasi quoter -- for easier usage. parameterisedCursorTest :: (Show a, Eq a) => String -> T.Text -> [a] -> (T.Text -> PosPrefixInfo -> IO a) -> TestTree diff --git a/hls-test-utils/src/Test/Hls/Util.hs b/hls-test-utils/src/Test/Hls/Util.hs index 98c795f8e0..cdb3c4de94 100644 --- a/hls-test-utils/src/Test/Hls/Util.hs +++ b/hls-test-utils/src/Test/Hls/Util.hs @@ -47,7 +47,7 @@ module Test.Hls.Util -- * Extract positions from input file. , extractCursorPositions , mkParameterisedLabel - , trimming + , __i ) where @@ -81,11 +81,11 @@ import Test.Tasty.ExpectedFailure (expectFailBecause, import Test.Tasty.HUnit (assertFailure) import qualified Data.List as List +import Data.String.Interpolate (__i) import qualified Data.Text.Internal.Search as T import qualified Data.Text.Utf16.Rope.Mixed as Rope import Development.IDE.Plugin.Completions.Logic (getCompletionPrefixFromRope) import Development.IDE.Plugin.Completions.Types (PosPrefixInfo (..)) -import NeatInterpolation (trimming) noLiteralCaps :: ClientCapabilities noLiteralCaps = def & L.textDocument ?~ textDocumentCaps diff --git a/plugins/hls-cabal-plugin/test/Completer.hs b/plugins/hls-cabal-plugin/test/Completer.hs index ab7165b1ac..1abaacaacf 100644 --- a/plugins/hls-cabal-plugin/test/Completer.hs +++ b/plugins/hls-cabal-plugin/test/Completer.hs @@ -392,39 +392,39 @@ extract item = case item ^. L.textEdit of _ -> error "" importTestData :: T.Text -importTestData = [trimming| -cabal-version: 3.0 -name: hls-cabal-plugin -version: 0.1.0.0 -synopsis: -homepage: -license: MIT -license-file: LICENSE -author: Fendor -maintainer: fendor@posteo.de -category: Development -extra-source-files: CHANGELOG.md +importTestData = [__i| + cabal-version: 3.0 + name: hls-cabal-plugin + version: 0.1.0.0 + synopsis: + homepage: + license: MIT + license-file: LICENSE + author: Fendor + maintainer: fendor@posteo.de + category: Development + extra-source-files: CHANGELOG.md -common defaults - default-language: GHC2021 - -- Should have been in GHC2021, an oversight - default-extensions: ExplicitNamespaces + common defaults + default-language: GHC2021 + -- Should have been in GHC2021, an oversight + default-extensions: ExplicitNamespaces -common test-defaults - ghc-options: -threaded -rtsopts -with-rtsopts=-N + common test-defaults + ghc-options: -threaded -rtsopts -with-rtsopts=-N -library - import: - ^ - exposed-modules: IDE.Plugin.Cabal - build-depends: base ^>=4.14.3.0 - hs-source-dirs: src - default-language: Haskell2010 + library + import: + ^ + exposed-modules: IDE.Plugin.Cabal + build-depends: base ^>=4.14.3.0 + hs-source-dirs: src + default-language: Haskell2010 -common notForLib - default-language: GHC2021 + common notForLib + default-language: GHC2021 -test-suite tests - import: - ^ + test-suite tests + import: + ^ |] diff --git a/plugins/hls-cabal-plugin/test/Context.hs b/plugins/hls-cabal-plugin/test/Context.hs index 8e6176bc5b..00d13b08f8 100644 --- a/plugins/hls-cabal-plugin/test/Context.hs +++ b/plugins/hls-cabal-plugin/test/Context.hs @@ -217,93 +217,93 @@ getContextTests = -- ------------------------------------------------------------------------ libraryStanzaData :: T.Text -libraryStanzaData = [trimming| -cabal-version: 3.0 -name: simple-cabal -library - default-language: Haskell98 - build-depends: +libraryStanzaData = [__i| + cabal-version: 3.0 + name: simple-cabal + library + default-language: Haskell98 + build-depends: -ma + ma |] executableStanzaData :: T.Text -executableStanzaData = [trimming| -cabal-version: 3.0 -name: simple-cabal -executable exeName - default-language: Haskell2010 - hs-source-dirs: test/preprocessor +executableStanzaData = [__i| + cabal-version: 3.0 + name: simple-cabal + executable exeName + default-language: Haskell2010 + hs-source-dirs: test/preprocessor |] topLevelData :: T.Text -topLevelData = [trimming| -cabal-version: 3.0 -name: +topLevelData = [__i| + cabal-version: 3.0 + name: - eee + eee |] conditionalData :: T.Text -conditionalData = [trimming| -cabal-version: 3.0 -name: simple-cabal -library - if os(windows) - buildable: - elif os(linux) - buildable: - else - buildable: +conditionalData = [__i| + cabal-version: 3.0 + name: simple-cabal + library + if os(windows) + buildable: + elif os(linux) + buildable: + else + buildable: |] multiLineOptsData :: T.Text -multiLineOptsData = [trimming| -cabal-version: 3.0 -name: +multiLineOptsData = [__i| + cabal-version: 3.0 + name: -library - build-depends: - base, + library + build-depends: + base, - text , + text , |] multiPositionTestData :: T.Text -multiPositionTestData = [trimming| -cabal-version: 3.4 - ^ ^ -category: Development -^ -name: haskell-language-server -description: - Please see the README on GitHub at +multiPositionTestData = [__i| + cabal-version: 3.4 + ^ ^ + category: Development ^ -extra-source-files: - README.md - ChangeLog.md - test/testdata/**/*.project - test/testdata/**/*.cabal - test/testdata/**/*.yaml - test/testdata/**/*.hs - test/testdata/**/*.json - ^ - -- These globs should only match test/testdata - plugins/**/*.project + name: haskell-language-server + description: + Please see the README on GitHub at + ^ + extra-source-files: + README.md + ChangeLog.md + test/testdata/**/*.project + test/testdata/**/*.cabal + test/testdata/**/*.yaml + test/testdata/**/*.hs + test/testdata/**/*.json + ^ + -- These globs should only match test/testdata + plugins/**/*.project -source-repository head - ^ ^ ^ - type: git - ^ ^ ^ ^ - location: https://github.com/haskell/haskell-language-server + source-repository head + ^ ^ ^ + type: git + ^ ^ ^ ^ + location: https://github.com/haskell/haskell-language-server - ^ -common cabalfmt + ^ + common cabalfmt - ^ - build-depends: haskell-language-server:hls-cabal-fmt-plugin - ^ ^ - cpp-options: -Dhls_cabalfmt + ^ + build-depends: haskell-language-server:hls-cabal-fmt-plugin + ^ ^ + cpp-options: -Dhls_cabalfmt |] diff --git a/plugins/hls-cabal-plugin/test/Main.hs b/plugins/hls-cabal-plugin/test/Main.hs index 43794e753d..5570598a37 100644 --- a/plugins/hls-cabal-plugin/test/Main.hs +++ b/plugins/hls-cabal-plugin/test/Main.hs @@ -292,7 +292,7 @@ reloadOnCabalChangeTests = testGroup "Reload on .cabal changes" cabalDoc <- openDoc "simple-reload.cabal" "cabal" skipManyTill anyMessage cabalKickDone saveDoc cabalDoc - [trimming| + [__i| cabal-version: 3.4 name: simple-reload version: 0.1.0.0