packages feed

auto-import 0.1.0.0 → 0.1.1.0

raw patch · 5 files changed

+77/−36 lines, 5 filesdep ~ghcPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: ghc

API changes (from Hackage documentation)

+ AutoImport.Config: DataNS :: Namespace
+ AutoImport.GhcFacade: pattern NotInScopeErr :: RdrName -> [ImportError] -> [GhcHint] -> TcRnMessage

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for auto-import +## 0.1.1.0 -- 2026-05-12+* Support GHC 9.14+* Drop support for 9.6+ ## 0.1.0.0 -- YYYY-mm-dd  * First version. Released on an unsuspecting world.
auto-import.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               auto-import-version:            0.1.0.0+version:            0.1.1.0 synopsis:           Automatically add import statements description:        Automatically add import statements based on configuration license:            BSD-3-Clause@@ -12,7 +12,7 @@ build-type:         Simple extra-doc-files:    CHANGELOG.md                     README.md-tested-with: GHC == 9.12.1, GHC == 9.10.1, GHC == 9.8.1, GHC == 9.6.1+tested-with: GHC == 9.14.1, GHC == 9.12.1, GHC == 9.10.1, GHC == 9.8.1  source-repository head   type: git@@ -29,7 +29,7 @@     -- other-modules:     default-extensions: LambdaCase, OverloadedStrings     build-depends:    base < 5,-                      ghc >= 9.6 && < 9.13,+                      ghc >= 9.8 && < 9.15,                       ghc-boot,                       ghc-exactprint,                       ghc-paths,@@ -57,3 +57,12 @@         process,         tasty,         tasty-hunit++-- executable play+--   hs-source-dirs: play+--   build-depends:+--     base,+--     auto-import+--   main-is: Main.hs+--   default-language: GHC2021+--   ghc-options: -fplugin AutoImport
src/AutoImport.hs view
@@ -85,19 +85,11 @@ missingThingFromMsg :: Config -> Ghc.MsgEnvelope Ghc.GhcMessage -> [MissingThing] missingThingFromMsg autoImportCfg msgEnv =   case Ghc.errMsgDiagnostic msgEnv of-    Ghc.GhcTcRnMessage-        (Ghc.TcRnMessageWithInfo _-          (Ghc.TcRnMessageDetailed _-            (Ghc.TcRnNotInScope Ghc.NotInScope _ [Ghc.MissingModule missingMod] _))-        )+    Ghc.GhcTcRnMessage (Ghc.NotInScopeErr _ [Ghc.MissingModule missingMod] _)       | let modTxt = moduleNameToText missingMod       , Just qualMods <- M.lookup modTxt (unMonoidMap $ qualModules autoImportCfg)       -> MissingModule <$> qualMods-    Ghc.GhcTcRnMessage-        (Ghc.TcRnMessageWithInfo _-          (Ghc.TcRnMessageDetailed _-            (Ghc.TcRnNotInScope Ghc.NotInScope rdrName [] hints))-        )+    Ghc.GhcTcRnMessage (Ghc.NotInScopeErr rdrName [] hints)       | Just unqualId <- M.lookup (T.pack $ EP.rdrName2String rdrName) (unqualIdentifiers autoImportCfg)       , let isDataKindExtHint = \case               Ghc.SuggestExtension (Ghc.SuggestSingleExtension _ LangExt.DataKinds) -> True@@ -287,6 +279,11 @@     ieCon = case idNamespace i of               Just PatternNS -> Ghc.IEPattern Ghc.epTokD0 . Ghc.L (Ghc.nameAnn (idIsOp i) True)               Just TypeNS -> Ghc.IEType Ghc.epTokD0 . Ghc.L (Ghc.nameAnn (idIsOp i) True)+#if MIN_VERSION_ghc(9,14,0)+              Just DataNS -> Ghc.IEData Ghc.epTokD0 . Ghc.L (Ghc.nameAnn (idIsOp i) True)+#elif MIN_VERSION_ghc(9,8,0)+              Just DataNS -> Ghc.IEName Ghc.noExtField . Ghc.L (Ghc.nameAnn (idIsOp i) False)+#endif               Nothing -> Ghc.IEName Ghc.noExtField . Ghc.L (Ghc.nameAnn (idIsOp i) False)  addCommas :: [Ghc.GenLocated Ghc.SrcSpanAnnA e] -> [Ghc.GenLocated Ghc.SrcSpanAnnA e]
src/AutoImport/Config.hs view
@@ -79,6 +79,7 @@ data Namespace   = PatternNS   | TypeNS+  | DataNS   deriving (Show, Eq, Ord)  data IdInfo = IdInfo@@ -206,7 +207,7 @@ parseIdentifier :: T.Text -> Parse.Parsec Void T.Text [UnqualIdentifier] parseIdentifier moName = do   mNamespace <- Parse.try . Parse.optional $-    (patternP <|> typeP) <* Parse.hspace1+    (patternP <|> typeP <|> dataP) <* Parse.hspace1   (parent, parentIsOp) <- identP <|> operatorP   let parentId =         UnqualIdentifier@@ -247,6 +248,7 @@                      (Parse.char ',' <* hspaceOrIndent)     patternP = PatternNS <$ Parse.string "pattern"     typeP = TypeNS <$ Parse.string "type"+    dataP = DataNS <$ Parse.string "data"  parseLineComment :: Parse.Parsec Void T.Text () parseLineComment = do
src/AutoImport/GhcFacade.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE ViewPatterns #-} module AutoImport.GhcFacade   ( module Ghc   , ann'@@ -16,9 +17,13 @@   , pattern IEVar'   , pattern TcRnSolverReport'   , pattern IEThingAbs'+  , pattern NotInScopeErr   ) where  import           GHC as Ghc+#if MIN_VERSION_ghc(9,14,0)+                            hiding (HoleError)+#endif import           GHC.Data.Bag as Ghc import           GHC.Data.FastString as Ghc import           GHC.Driver.Env as Ghc@@ -42,17 +47,17 @@ import           GHC.Utils.Misc as Ghc #if MIN_VERSION_ghc(9,8,0) import           GHC.Driver.DynFlags as Ghc-#else-import           GHC.Driver.Flags as Ghc-import           GHC.Driver.Session as Ghc #endif +#if MIN_VERSION_ghc(9,14,0)+import qualified Data.List.NonEmpty as NE+#endif import qualified Language.Haskell.GHC.ExactPrint as EP  #if MIN_VERSION_ghc(9,10,0) ann' :: Ghc.EpAnn ann -> Ghc.EpAnn ann ann' = id-#else+#elif MIN_VERSION_ghc(9,8,0) ann' :: Ghc.SrcSpanAnnA -> Ghc.EpAnn Ghc.AnnListItem ann' = Ghc.ann #endif@@ -61,7 +66,7 @@ #if MIN_VERSION_ghc(9,10,0)   :: Ghc.NoAnn ann   => Ghc.DeltaPos -> Ghc.EpAnn ann-#else+#elif MIN_VERSION_ghc(9,8,0)   :: Monoid ann   => Ghc.DeltaPos -> Ghc.SrcSpanAnn' (Ghc.EpAnn ann) #endif@@ -76,7 +81,7 @@ nameParensAdornment = #if MIN_VERSION_ghc(9,12,0)   Ghc.NameParens (Ghc.EpTok EP.d0) (Ghc.EpTok EP.d0)-#else+#elif MIN_VERSION_ghc(9,8,0)   Ghc.NameParens #endif @@ -92,17 +97,13 @@       [Ghc.AddEpAnn Ghc.AnnOpenP EP.d0, Ghc.AddEpAnn Ghc.AnnCloseP EP.d0]       Ghc.emptyComments   )-#else-  Ghc.EpAnn (Ghc.Anchor Ghc.placeholderRealSpan EP.m0)-    [Ghc.AddEpAnn Ghc.AnnOpenP EP.d0, Ghc.AddEpAnn Ghc.AnnCloseP EP.d0]-    Ghc.emptyComments #endif  #if MIN_VERSION_ghc(9,12,0) importListAnn :: Ghc.EpAnn (Ghc.AnnList (Ghc.EpToken "hiding", [Ghc.EpToken ","])) #elif MIN_VERSION_ghc(9,10,0) importListAnn :: Ghc.EpAnn Ghc.AnnList-#else+#elif MIN_VERSION_ghc(9,8,0) importListAnn :: Ghc.SrcSpanAnn' (Ghc.EpAnn Ghc.AnnList) #endif importListAnn =@@ -120,7 +121,7 @@       , Ghc.al_close = Just $ Ghc.AddEpAnn Ghc.AnnCloseP EP.d0       }     }-#else+#elif MIN_VERSION_ghc(9,8,0)   (noAnnSrcSpanDP' @Ghc.AnnList $ Ghc.SameLine 0)     { Ghc.ann = Ghc.EpAnn       { Ghc.anns = mempty@@ -138,7 +139,7 @@   -> Bool #if MIN_VERSION_ghc(9,10,0)   -> Ghc.EpAnn Ghc.NameAnn-#else+#elif MIN_VERSION_ghc(9,8,0)   -> Ghc.SrcSpanAnn' (Ghc.EpAnn Ghc.NameAnn) #endif nameAnn needsParens addLeftSpace =@@ -164,7 +165,7 @@       else Ghc.noAnn     , Ghc.entry = if addLeftSpace then EP.d1 else EP.d0     }-#else+#elif MIN_VERSION_ghc(9,8,0)   Ghc.SrcSpanAnn     { Ghc.ann = Ghc.EpAnn       { Ghc.anns = if needsParens@@ -192,7 +193,7 @@   } #elif MIN_VERSION_ghc(9,10,0) importEpAnn = Ghc.noAnn-#else+#elif MIN_VERSION_ghc(9,8,0) importEpAnn =   Ghc.EpAnn     { Ghc.entry = Ghc.Anchor Ghc.placeholderRealSpan EP.m0@@ -211,7 +212,7 @@ #if MIN_VERSION_ghc(9,12,0) epTokD0 :: Ghc.EpToken tok epTokD0 = Ghc.EpTok EP.d0-#else+#elif MIN_VERSION_ghc(9,8,0) epTokD0 :: Ghc.EpaLocation epTokD0 = EP.d0 #endif@@ -220,7 +221,7 @@ #if MIN_VERSION_ghc(9,10,0) hasTrailingComma = any (\case Ghc.AddCommaAnn{} -> True; _ -> False)   . Ghc.lann_trailing . Ghc.anns-#else+#elif MIN_VERSION_ghc(9,8,0) hasTrailingComma x  =   case Ghc.ann x of     Ghc.EpAnnNotUsed -> False@@ -231,14 +232,14 @@ pattern IEThingWith' :: XIEThingWith Ghc.GhcPs -> LIEWrappedName Ghc.GhcPs -> IEWildcard -> [LIEWrappedName Ghc.GhcPs] -> Ghc.IE Ghc.GhcPs #if MIN_VERSION_ghc(9,10,0) pattern IEThingWith' x name wc children = Ghc.IEThingWith x name wc children Nothing-#else+#elif MIN_VERSION_ghc(9,8,0) pattern IEThingWith' x name wc children = Ghc.IEThingWith x name wc children #endif  pattern IEThingAbs' :: LIEWrappedName Ghc.GhcPs -> Ghc.IE Ghc.GhcPs #if MIN_VERSION_ghc(9,10,0) pattern IEThingAbs' name <- Ghc.IEThingAbs _ name _-#else+#elif MIN_VERSION_ghc(9,8,0) pattern IEThingAbs' name <- Ghc.IEThingAbs _ name #endif @@ -247,13 +248,41 @@ pattern IEVar' name = Ghc.IEVar Nothing name Nothing #elif MIN_VERSION_ghc(9,8,0) pattern IEVar' name = Ghc.IEVar Nothing name-#else-pattern IEVar' name = Ghc.IEVar Ghc.NoExtField name #endif  pattern TcRnSolverReport' :: Ghc.SolverReportWithCtxt -> Ghc.TcRnMessage #if MIN_VERSION_ghc(9,10,0) pattern TcRnSolverReport' report <- Ghc.TcRnSolverReport report _-#else+#elif MIN_VERSION_ghc(9,8,0) pattern TcRnSolverReport' report <- Ghc.TcRnSolverReport report _ _+#endif++#if MIN_VERSION_ghc(9,14,0)+extractImportErrs :: Maybe (a, [Ghc.SupplementaryInfo]) -> [Ghc.ImportError]+extractImportErrs = foldMap (foldMap getImp . snd)+  where+  getImp (Ghc.SupplementaryImportErrors imps) = NE.toList imps+  getImp _ = []+#endif++pattern NotInScopeErr :: Ghc.RdrName -> [Ghc.ImportError] -> [Ghc.GhcHint] -> TcRnMessage+pattern NotInScopeErr rdrName impErrs hints <-+#if MIN_VERSION_ghc(9,14,0)+  Ghc.TcRnMessageWithInfo _+    (Ghc.TcRnMessageDetailed _+      (Ghc.TcRnMessageWithInfo _+        (Ghc.TcRnMessageDetailed+          (Ghc.ErrInfo+            _+            (extractImportErrs -> impErrs)+            hints+          )+          (Ghc.TcRnNotInScope Ghc.NotInScope rdrName)+        )+      )+    )+#elif MIN_VERSION_ghc(9,8,0)+  Ghc.TcRnMessageWithInfo _+    (Ghc.TcRnMessageDetailed _+      (Ghc.TcRnNotInScope Ghc.NotInScope rdrName impErrs hints)) #endif