packages feed

hls-explicit-record-fields-plugin 1.0.0.0 → 1.0.1.0

raw patch · 20 files changed

+256/−6 lines, 20 filesdep ~ghcidePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: ghcide

API changes (from Hackage documentation)

Files

hls-explicit-record-fields-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               hls-explicit-record-fields-plugin-version:            1.0.0.0+version:            1.0.1.0 synopsis:           Explicit record fields plugin for Haskell Language Server description:   Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>@@ -12,7 +12,8 @@ category:           Development build-type:         Simple extra-doc-files:    CHANGELOG.md--- extra-source-files:+extra-source-files:+  test/testdata/**/*.hs  source-repository head   type:     git@@ -28,7 +29,7 @@     -- other-extensions:     build-depends:       , base                  >=4.12 && <5-      , ghcide                ^>=1.9+      , ghcide                ^>=1.10       , hls-plugin-api        ^>=1.6       , lsp       , lens
src/Ide/Plugin/ExplicitFields.hs view
@@ -23,7 +23,7 @@                                                   mkQ) import qualified Data.HashMap.Strict             as HashMap import           Data.Maybe                      (isJust, listToMaybe,-                                                  maybeToList)+                                                  maybeToList, fromMaybe) import           Data.Text                       (Text) import           Development.IDE                 (IdeState, NormalizedFilePath,                                                   Pretty (..), Recorder (..),@@ -36,7 +36,8 @@ import qualified Development.IDE.Core.Shake      as Shake import           Development.IDE.GHC.Compat      (HsConDetails (RecCon),                                                   HsRecFields (..), LPat,-                                                  Outputable, getLoc, unLoc)+                                                  Outputable, getLoc, unLoc,+                                                  recDotDot) import           Development.IDE.GHC.Compat.Core (Extension (NamedFieldPuns),                                                   GhcPass,                                                   HsExpr (RecordCon, rcon_flds),@@ -304,7 +305,7 @@   -> HsRecFields p arg preprocessRecord getName names flds = flds { rec_dotdot = Nothing , rec_flds = rec_flds' }   where-    no_pun_count = maybe (length (rec_flds flds)) unLoc (rec_dotdot flds)+    no_pun_count = fromMaybe (length (rec_flds flds)) (recDotDot flds)     -- Field binds of the explicit form (e.g. `{ a = a' }`) should be     -- left as is, hence the split.     (no_puns, puns) = splitAt no_pun_count (rec_flds flds)
+ test/testdata/Construction.expected.hs view
@@ -0,0 +1,18 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE NamedFieldPuns #-}++module Construction where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: () -> MyRec+convertMe _ =+  let foo = 3+      bar = 5+      baz = 'a'+  in MyRec {foo, bar, baz}
+ test/testdata/Construction.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}++module Construction where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: () -> MyRec+convertMe _ =+  let foo = 3+      bar = 5+      baz = 'a'+  in MyRec {..}
+ test/testdata/Mixed.expected.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE NamedFieldPuns #-}++module Mixed where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  , quux :: Double+  }++convertMe :: MyRec -> String+convertMe MyRec {foo, bar = bar', baz} = show foo ++ show bar' ++ show baz
+ test/testdata/Mixed.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE NamedFieldPuns #-}++module Mixed where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  , quux :: Double+  }++convertMe :: MyRec -> String+convertMe MyRec {foo, bar = bar', ..} = show foo ++ show bar' ++ show baz
+ test/testdata/Unused.expected.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE NamedFieldPuns #-}++module Unused where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: MyRec -> String+convertMe MyRec {foo, bar} = show foo ++ show bar
+ test/testdata/Unused.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}++module Unused where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: MyRec -> String+convertMe MyRec {..} = show foo ++ show bar
+ test/testdata/Unused2.expected.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE NamedFieldPuns #-}++module Unused2 where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: MyRec -> String+convertMe MyRec {foo, bar} = let baz = "baz" in show foo ++ show bar ++ baz
+ test/testdata/Unused2.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}++module Unused2 where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: MyRec -> String+convertMe MyRec {..} = let baz = "baz" in show foo ++ show bar ++ baz
+ test/testdata/WildcardOnly.expected.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE NamedFieldPuns #-}++module WildcardOnly where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: MyRec -> String+convertMe MyRec {foo, bar, baz} = show foo ++ show bar ++ show baz
+ test/testdata/WildcardOnly.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}++module WildcardOnly where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: MyRec -> String+convertMe MyRec {..} = show foo ++ show bar ++ show baz
+ test/testdata/WithExplicitBind.expected.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE NamedFieldPuns #-}++module WithExplicitBind where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: MyRec -> String+convertMe MyRec {foo = foo', bar, baz} = show foo' ++ show bar ++ show baz
+ test/testdata/WithExplicitBind.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}++module WithExplicitBind where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: MyRec -> String+convertMe MyRec {foo = foo', ..} = show foo' ++ show bar ++ show baz
+ test/testdata/WithPun.expected.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE NamedFieldPuns #-}++module WithPun where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: MyRec -> String+convertMe MyRec {foo, bar, baz} = show foo ++ show bar ++ show baz
+ test/testdata/WithPun.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE NamedFieldPuns #-}++module WithPun where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: MyRec -> String+convertMe MyRec {foo, ..} = show foo ++ show bar ++ show baz
+ test/testdata/noop/ExplicitBinds.hs view
@@ -0,0 +1,12 @@+{-# LANGUAGE Haskell2010 #-}++module ExplicitBinds where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: MyRec -> String+convertMe MyRec {foo = foo', bar = bar', baz = baz'} = show foo' ++ show bar' ++ show baz'
+ test/testdata/noop/Infix.hs view
@@ -0,0 +1,11 @@+{-# LANGUAGE Haskell2010 #-}++module Infix where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  }++convertMe :: MyRec -> String+convertMe (foo' `MyRec` bar') = show foo' ++ show bar'
+ test/testdata/noop/Prefix.hs view
@@ -0,0 +1,11 @@+{-# LANGUAGE Haskell2010 #-}++module Prefix where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  }++convertMe :: MyRec -> String+convertMe (foo' `MyRec` bar') = show foo' ++ show bar'
+ test/testdata/noop/Puns.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE Haskell2010 #-}+{-# LANGUAGE NamedFieldPuns #-}++module Puns where++data MyRec = MyRec+  { foo :: Int+  , bar :: Int+  , baz :: Char+  }++convertMe :: MyRec -> String+convertMe MyRec {foo, bar, baz} = show foo ++ show bar ++ show baz