mirror of
https://github.com/ocharles/weeder.git
synced 2024-11-22 22:42:10 +03:00
Remove analyseExport
This commit is contained in:
parent
aa2c18d013
commit
66eec6f196
@ -57,9 +57,6 @@ import Data.Generics.Labels ()
|
|||||||
|
|
||||||
-- ghc
|
-- ghc
|
||||||
import GHC.Data.FastString ( unpackFS )
|
import GHC.Data.FastString ( unpackFS )
|
||||||
import GHC.Types.Avail
|
|
||||||
( AvailInfo( Avail, AvailTC )
|
|
||||||
)
|
|
||||||
import GHC.Iface.Ext.Types
|
import GHC.Iface.Ext.Types
|
||||||
( BindType( RegularBind )
|
( BindType( RegularBind )
|
||||||
, ContextInfo( Decl, ValBind, PatternBind, Use, TyDecl, ClassTyDecl, EvidenceVarBind, RecField )
|
, ContextInfo( Decl, ValBind, PatternBind, Use, TyDecl, ClassTyDecl, EvidenceVarBind, RecField )
|
||||||
@ -67,7 +64,7 @@ import GHC.Iface.Ext.Types
|
|||||||
, EvVarSource ( EvInstBind, cls )
|
, EvVarSource ( EvInstBind, cls )
|
||||||
, HieAST( Node, nodeChildren, nodeSpan, sourcedNodeInfo )
|
, HieAST( Node, nodeChildren, nodeSpan, sourcedNodeInfo )
|
||||||
, HieASTs( HieASTs )
|
, HieASTs( HieASTs )
|
||||||
, HieFile( HieFile, hie_asts, hie_exports, hie_module, hie_hs_file, hie_types )
|
, HieFile( HieFile, hie_asts, hie_module, hie_hs_file, hie_types )
|
||||||
, HieType( HTyVarTy, HAppTy, HTyConApp, HForAllTy, HFunTy, HQualTy, HLitTy, HCastTy, HCoercionTy )
|
, HieType( HTyVarTy, HAppTy, HTyConApp, HForAllTy, HFunTy, HQualTy, HLitTy, HCastTy, HCoercionTy )
|
||||||
, HieArgs( HieArgs )
|
, HieArgs( HieArgs )
|
||||||
, HieTypeFix( Roll )
|
, HieTypeFix( Roll )
|
||||||
@ -273,7 +270,7 @@ analyseHieFile weederConfig hieFile =
|
|||||||
|
|
||||||
analyseHieFile' :: ( MonadState Analysis m, MonadReader AnalysisInfo m ) => m ()
|
analyseHieFile' :: ( MonadState Analysis m, MonadReader AnalysisInfo m ) => m ()
|
||||||
analyseHieFile' = do
|
analyseHieFile' = do
|
||||||
HieFile{ hie_asts = HieASTs hieASTs, hie_exports, hie_module, hie_hs_file } <- asks currentHieFile
|
HieFile{ hie_asts = HieASTs hieASTs, hie_module, hie_hs_file } <- asks currentHieFile
|
||||||
#modulePaths %= Map.insert hie_module hie_hs_file
|
#modulePaths %= Map.insert hie_module hie_hs_file
|
||||||
|
|
||||||
g <- asks initialGraph
|
g <- asks initialGraph
|
||||||
@ -281,8 +278,6 @@ analyseHieFile' = do
|
|||||||
|
|
||||||
for_ hieASTs topLevelAnalysis
|
for_ hieASTs topLevelAnalysis
|
||||||
|
|
||||||
for_ hie_exports ( analyseExport hie_module )
|
|
||||||
|
|
||||||
|
|
||||||
lookupType :: HieFile -> TypeIndex -> HieTypeFix
|
lookupType :: HieFile -> TypeIndex -> HieTypeFix
|
||||||
lookupType hf t = recoverFullType t $ hie_types hf
|
lookupType hf t = recoverFullType t $ hie_types hf
|
||||||
@ -329,23 +324,6 @@ typeToNames (Roll t) = case t of
|
|||||||
hieArgsTypes = foldMap (typeToNames . snd) . filter fst
|
hieArgsTypes = foldMap (typeToNames . snd) . filter fst
|
||||||
|
|
||||||
|
|
||||||
analyseExport :: MonadState Analysis m => Module -> AvailInfo -> m ()
|
|
||||||
analyseExport m = \case
|
|
||||||
Avail name ->
|
|
||||||
traverse_ addExport $ nameToDeclaration name
|
|
||||||
|
|
||||||
AvailTC name pieces -> do
|
|
||||||
for_ ( nameToDeclaration name ) addExport
|
|
||||||
|
|
||||||
for_ pieces $
|
|
||||||
traverse_ addExport . nameToDeclaration
|
|
||||||
|
|
||||||
where
|
|
||||||
|
|
||||||
addExport :: MonadState Analysis m => Declaration -> m ()
|
|
||||||
addExport d = #exports %= Map.insertWith (<>) m ( Set.singleton d )
|
|
||||||
|
|
||||||
|
|
||||||
-- | @addDependency x y@ adds the information that @x@ depends on @y@.
|
-- | @addDependency x y@ adds the information that @x@ depends on @y@.
|
||||||
addDependency :: MonadState Analysis m => Declaration -> Declaration -> m ()
|
addDependency :: MonadState Analysis m => Declaration -> Declaration -> m ()
|
||||||
addDependency x y =
|
addDependency x y =
|
||||||
|
Loading…
Reference in New Issue
Block a user