ghc-tags-plugin 0.2.4.0 → 0.2.4.1
raw patch · 2 files changed
+89/−25 lines, 2 filesdep ~basedep ~bytestringdep ~ghc
Dependency ranges changed: base, bytestring, ghc, optparse-applicative
Files
- ghc-tags-plugin.cabal +8/−8
- lib/Plugin/GhcTags.hs +81/−17
ghc-tags-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: ghc-tags-plugin-version: 0.2.4.0+version: 0.2.4.1 synopsis: A compiler plugin which generates tags file from GHC parsed syntax tree. description: A [GHC compiler plugin](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/extending_ghc.html?highlight=compiler%20plugin#compiler-plugins)@@ -10,15 +10,15 @@ license: MPL-2.0 license-file: LICENSE author: Marcin Szamotulski-maintainer: profunctor@pm.me-copyright: (c) 2020, Marcin Szamotulski+maintainer: coot@coot.me+copyright: (c) 2020-2021, Marcin Szamotulski category: Development stability: alpha extra-source-files: CHANGELOG.md README.md homepage: https://github.com/coot/ghc-tags-plugin#readme bug-reports: https://github.com/coot/ghc-tags-plugin/issues-tested-with: GHC==8.6.5, GHC==8.8.3, GHC==8.10.1+tested-with: GHC==8.6.5, GHC==8.8.4, GHC==8.10.4 -- Don't build gtp-check command by default; it's a development tool. flag gtp-check@@ -37,17 +37,17 @@ other-modules: Plugin.GhcTags.CTag Paths_ghc_tags_plugin autogen-modules: Paths_ghc_tags_plugin- build-depends: base >=4.12.0.0 && <4.15,- bytestring ^>=0.10,+ build-depends: base >=4.12.0.0 && <4.16,+ bytestring >=0.10 && < 0.12, directory ^>=1.3, filepath ^>=1.4, filepath-bytestring ^>=1.4,- ghc >=8.4 && <8.11,+ ghc >=8.4 && <10, lukko ^>=0.1, mtl ^>=2.2, optparse-applicative- ^>=0.15.1,+ >=0.15.1 && < 0.17, pipes ^>=4.3, pipes-attoparsec ^>=0.5, pipes-bytestring ^>=2.1,
lib/Plugin/GhcTags.hs view
@@ -50,24 +50,66 @@ import qualified Pipes.Safe as Pipes.Safe import qualified Pipes.ByteString as Pipes.BS -import GhcPlugins ( CommandLineOption- , DynFlags (..)- , Hsc+#if __GLASGOW_HASKELL__ >= 900+import GHC.Driver.Plugins+#else+import GhcPlugins+#endif+ ( CommandLineOption+ , Plugin (..)+ )+#if __GLASGOW_HASKELL__ >= 900+import qualified GHC.Driver.Plugins as GhcPlugins+import GHC.Driver.Types ( Hsc+ , HsParsedModule (..)+ , ModSummary (..)+ , MetaHook+ , MetaRequest (..)+ , MetaResult+ , metaRequestAW+ , metaRequestD+ , metaRequestE+ , metaRequestP+ , metaRequestT+ )+import GHC.Driver.Hooks (Hooks (..))+import GHC.Unit.Types (Module)+import GHC.Unit.Module.Location (ModLocation (..))+import GHC.Tc.Types (TcM)+import GHC.Tc.Gen.Splice (defaultRunMeta)+import GHC.Types.SrcLoc (Located)+#else+import qualified GhcPlugins+import GhcPlugins ( Hsc , HsParsedModule (..) , Located , Module- , ModSummary (..) , ModLocation (..)- , Plugin (..)+ , ModSummary (..) #if __GLASGOW_HASKELL__ >= 810 , MetaHook , MetaRequest (..) , MetaResult+ , metaRequestAW+ , metaRequestD+ , metaRequestE+ , metaRequestP+ , metaRequestT #endif )-import qualified GhcPlugins-#if __GLASGOW_HASKELL__ >= 810+#endif+#if __GLASGOW_HASKELL__ >= 900+import GHC.Driver.Session (DynFlags (hooks))+#elif __GLASGOW_HASKELL__ >= 810+import DynFlags (DynFlags (hooks))+#else+import DynFlags (DynFlags)+#endif++#if __GLASGOW_HASKELL__ >= 900 import GHC.Hs (GhcPs, GhcTc, HsModule (..), LHsDecl, LHsExpr)+#elif __GLASGOW_HASKELL__ >= 810+import GHC.Hs (GhcPs, GhcTc, HsModule (..), LHsDecl, LHsExpr) import TcSplice import TcRnMonad import Hooks@@ -75,9 +117,15 @@ import HsExtension (GhcPs) import HsSyn (HsModule (..)) #endif+#if __GLASGOW_HASKELL__ >= 900+import GHC.Utils.Outputable (($+$), ($$))+import qualified GHC.Utils.Outputable as Out+import qualified GHC.Utils.Ppr.Colour as PprColour+#else import Outputable (($+$), ($$)) import qualified Outputable as Out import qualified PprColour+#endif import GhcTags.Ghc import GhcTags.Tag@@ -90,6 +138,13 @@ import qualified Plugin.GhcTags.CTag as CTag +#if __GLASGOW_HASKELL__ >= 900+type GhcPsModule = HsModule+#else+type GhcPsModule = HsModule GhcPs+#endif++ -- | The GhcTags plugin. It will run for every compiled module and have access -- to parsed syntax tree. It will inspect it and: --@@ -151,7 +206,7 @@ , debug } -> - GhcPlugins.liftIO $ do+ liftIO $ do let sourceFile = case splitFileName tagsFile of (dir, name) -> dir </> "." ++ name lockFile = sourceFile ++ ".lock"@@ -188,7 +243,7 @@ ]) Failure (ParserFailure f) ->- GhcPlugins.liftIO $+ liftIO $ putDocLn dynFlags (messageDoc OptionParserFailure@@ -221,7 +276,7 @@ -- updateTags :: Options Identity -> ModSummary- -> Located (HsModule GhcPs)+ -> Located GhcPsModule -> FilePath -> IO () updateTags Options { etags, filePath = Identity tagsFile, debug }@@ -397,7 +452,7 @@ lockFile = sourceFile ++ ".lock" withMetaD defaultRunMeta request expr $ \decls ->- GhcPlugins.liftIO $+ liftIO $ handle (\ioerr -> do putDocLn dynFlags (messageDoc UnhandledException Nothing@@ -446,7 +501,7 @@ Failure (ParserFailure f) -> withMetaD defaultRunMeta request expr $ \_ ->- GhcPlugins.liftIO $+ liftIO $ putDocLn dynFlags (messageDoc OptionParserFailure@@ -461,13 +516,13 @@ -> ([LHsDecl GhcPs] -> TcM a) -> TcM (MetaResult) withMetaD h req e f = case req of- MetaE k -> k <$> GhcPlugins.metaRequestE h e- MetaP k -> k <$> GhcPlugins.metaRequestP h e- MetaT k -> k <$> GhcPlugins.metaRequestT h e+ MetaE k -> k <$> metaRequestE h e+ MetaP k -> k <$> metaRequestP h e+ MetaT k -> k <$> metaRequestT h e MetaD k -> do- res <- GhcPlugins.metaRequestD h e+ res <- metaRequestD h e k res <$ f res- MetaAW k -> k <$> GhcPlugins.metaRequestAW h e+ MetaAW k -> k <$> metaRequestAW h e #endif @@ -552,10 +607,19 @@ putDocLn :: DynFlags -> Out.SDoc -> IO () putDocLn dynFlags sdoc = putStrLn $+#if __GLASGOW_HASKELL__ >= 900 Out.renderWithStyle+ (Out.initSDocContext+ dynFlags+ (Out.setStyleColoured False+ $ Out.mkErrStyle Out.neverQualify))+ sdoc+#else+ Out.renderWithStyle dynFlags sdoc (Out.setStyleColoured True $ Out.defaultErrStyle dynFlags)+#endif printMessageDoc :: DynFlags -> MessageType -> Maybe Module -> String -> IO ()