packages feed

hsinspect 0.0.11 → 0.0.12

raw patch · 4 files changed

+21/−15 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ HsInspect.Imports: instance GHC.Classes.Ord HsInspect.Imports.Qualified
+ HsInspect.Index: instance GHC.Classes.Eq HsInspect.Index.Entry
+ HsInspect.Index: instance GHC.Classes.Eq HsInspect.Index.Exported
+ HsInspect.Index: instance GHC.Classes.Eq HsInspect.Index.ModuleEntries
+ HsInspect.Index: instance GHC.Classes.Ord HsInspect.Index.Entry
+ HsInspect.Index: instance GHC.Classes.Ord HsInspect.Index.Exported
+ HsInspect.Index: instance GHC.Classes.Ord HsInspect.Index.ModuleEntries

Files

hsinspect.cabal view
@@ -1,14 +1,13 @@ cabal-version: 2.2 name:          hsinspect-version:       0.0.11+version:       0.0.12 synopsis:      Inspect Haskell source files. license:       GPL-3.0-or-later license-file:  LICENSE author:        Tseen She maintainer:    Tseen She copyright:     2019 Tseen She-bug-reports:   https://gitlab.com/tseenshe/hsinspect/merge_requests-tested-with:   GHC ^>=8.4.4 || ^>=8.6.5 || ^>=8.8.1+tested-with:   GHC ^>=8.4.4 || ^>=8.6.5 || ^>=8.8.3 || ^>=8.10.1 category:      Building description:   Inspect @.hs@ files using the ghc api. 
library/HsInspect/Imports.hs view
@@ -8,12 +8,13 @@   ) where +import Data.List (sort) import Data.Maybe (fromJust) import qualified GHC as GHC import HscTypes (TargetId(..)) import HsInspect.Sexp-import HsInspect.Workarounds import HsInspect.Util+import HsInspect.Workarounds import RdrName (GlobalRdrElt(..), ImpDeclSpec(..), ImportSpec(..),                 globalRdrEnvElts) @@ -31,7 +32,7 @@   _ <- GHC.load $ GHC.LoadUpTo m    rdr_env <- minf_rdr_env' m-  pure $ describe =<< globalRdrEnvElts rdr_env+  pure . sort $ describe =<< globalRdrEnvElts rdr_env  describe :: GlobalRdrElt -> [Qualified] describe GRE {gre_name, gre_imp} = describe' <$> gre_imp@@ -56,7 +57,7 @@       (Maybe String)       (Maybe String)       String-  deriving (Eq, Show)+  deriving (Eq, Ord, Show)  instance ToSexp Qualified where   toSexp (Qualified ln lqn fqn) =
library/HsInspect/Index.hs view
@@ -15,7 +15,7 @@ import Control.Monad import Control.Monad.IO.Class import Data.Coerce-import Data.List (isInfixOf)+import Data.List (isInfixOf, sort) import Data.Maybe (catMaybes, mapMaybe, maybeToList) import Data.Set (Set) import qualified Data.Set as Set@@ -25,7 +25,6 @@ import qualified GHC import GHC.PackageDb import qualified GHC.PackageDb as GHC-import HscTypes (ModIface(..)) import HsInspect.Json () import HsInspect.Sexp import HsInspect.Util@@ -81,7 +80,7 @@ getCompiledTargets dir = do   provided <- getTargetModules   his <- liftIO $ walkSuffix ".hi" dir-  modules <- catMaybes <$> traverse (flip withHi (pure . mi_module)) his+  modules <- catMaybes <$> traverse (flip withHi (pure . GHC.mi_module)) his   let toTarget m =         if Set.member m provided           then Just $ GHC.Target (GHC.TargetModule m) True Nothing@@ -114,8 +113,8 @@   dflags <- GHC.getSessionDynFlags   let srcid = sourcePackageId <$> lookupPackage dflags unitid   symbols <- catMaybes <$> traverse (hiToSymbols exposed) his-  let entries = uncurry mkEntries <$> symbols-      mkEntries m things = ModuleEntries (moduleName m) (renderThings things)+  let entries = sort $ uncurry mkEntries <$> symbols+      mkEntries m things = ModuleEntries (moduleName m) (sort $ renderThings things)       renderThings things = catMaybes $ (uncurry $ tyrender dflags unitid) <$> things   pure $ PackageEntries srcid inplace entries haddocks @@ -127,8 +126,8 @@   -> FilePath   -> m (Maybe (GHC.Module, [(Maybe GHC.Module, GHC.TcTyThing)])) hiToSymbols exposed hi = (join <$>) <$> withHi hi $ \iface -> do-  let m = mi_module iface-  -- FIXME we should include all modules from inplace packages, otherwise the+  let m = GHC.mi_module iface+  -- TODO we should include all modules from inplace packages, otherwise the   -- user is unable to jump-to-definition within the same multi-package project.   if not $ Set.member (GHC.moduleName m) exposed     then pure Nothing@@ -140,7 +139,7 @@             modl <- GHC.nameModule_maybe name             if m == modl then Nothing else Just modl           tcLookup' name = (reexport name,) <$> tcLookup name-      things <- join <$> traverse thing (mi_exports iface)+      things <- join <$> traverse thing (GHC.mi_exports iface)       pure . Just $ (m, things)  tyrender :: GHC.DynFlags -> UnitId -> Maybe GHC.Module -> GHC.TcTyThing -> Maybe Entry@@ -169,8 +168,10 @@            | ConEntry (Maybe Exported) String String -- ^ name type            | PatSynEntry (Maybe Exported) String String -- ^ name orig            | TyConEntry (Maybe Exported) String String -- ^ type flavour+  deriving (Eq, Ord)  data ModuleEntries = ModuleEntries GHC.ModuleName [Entry]+  deriving (Eq, Ord)  -- The haddocks serve a dual purpose: not only do they point to where haddocks -- might be, they give a hint to the text editor where the sources for this@@ -185,8 +186,9 @@  -- srcid is Nothing if it matches the re-export location data Exported = Exported (Maybe SourcePackageId) GHC.ModuleName+  deriving (Eq, Ord) --- FIXME Exported should follow re-exports until they reach the original symbol.+-- TODO Exported should follow re-exports until they reach the original symbol. -- Otherwise editors have to do this. mkExported :: GHC.DynFlags -> UnitId -> Module -> Exported mkExported dflags unitid m =
library/HsInspect/Workarounds.hs view
@@ -16,7 +16,11 @@ import qualified GHC as GHC import HeaderInfo (getOptions) import HscTypes (Target(..), TargetId(..))+#if MIN_VERSION_GLASGOW_HASKELL(8,10,1,0)+import GHC.Hs.ImpExp (ImportDecl(..))+#else import HsImpExp (ImportDecl(..))+#endif import Lexer import Outputable (showPpr) import Parser (parseHeader)