1
1
mirror of https://github.com/github/semantic.git synced 2025-01-06 23:46:21 +03:00

Origin stores ModuleInfo.

This commit is contained in:
Rob Rix 2018-03-30 19:44:31 -04:00
parent 11c584b6ff
commit 37535b1823
3 changed files with 6 additions and 6 deletions

View File

@ -147,7 +147,7 @@ instance ( Functor (Base term)
analyzeTerm eval term = pushOrigin (termOrigin term) (eval term)
analyzeModule eval m = pushOrigin (moduleOrigin (subterm <$> m)) (eval m)
analyzeModule eval m = pushOrigin (moduleOrigin (moduleInfo m)) (eval m)
pushOrigin :: Member (Reader (SomeOrigin term)) effects => SomeOrigin term -> Evaluating location term value effects a -> Evaluating location term value effects a
pushOrigin o = raise . local (<> o) . lower

View File

@ -62,7 +62,7 @@ insertVertexName :: forall m location term value effects
-> ImportGraphing m effects ()
insertVertexName name = do
o <- raise ask
let parent = maybe empty (vertex . moduleName . moduleInfo) (originModule @term o)
let parent = maybe empty (vertex . moduleName) (originModule @term o)
modifyImportGraph (parent >< vertex name <>)
(><) :: Graph a => a -> a -> a

View File

@ -9,19 +9,19 @@ import Prologue
data Origin term ty where
Unknown :: Origin term any
Package :: P.Package () -> Origin term 'P
Module :: Origin term 'P -> M.Module () -> Origin term 'M
Module :: Origin term 'P -> M.ModuleInfo -> Origin term 'M
Term :: Origin term 'M -> Base term () -> Origin term 'T
packageOrigin :: P.Package term -> SomeOrigin term
packageOrigin p = SomeOrigin (Package (() <$ p { P.packageModules = mempty, P.packageEntryPoints = mempty }))
moduleOrigin :: M.Module term -> SomeOrigin term
moduleOrigin = SomeOrigin . Module Unknown . (() <$)
moduleOrigin :: M.ModuleInfo -> SomeOrigin term
moduleOrigin = SomeOrigin . Module Unknown
termOrigin :: Functor (Base term) => Base term a -> SomeOrigin term
termOrigin = SomeOrigin . Term Unknown . (() <$)
originModule :: SomeOrigin term -> Maybe (M.Module ())
originModule :: SomeOrigin term -> Maybe M.ModuleInfo
originModule (SomeOrigin (Term (Module _ m) _)) = Just m
originModule (SomeOrigin (Module _ m)) = Just m
originModule _ = Nothing