This commit is contained in:
runarorama 2021-02-17 22:36:20 -05:00
parent 92cbf1ceb8
commit fbf4bade3e

View File

@ -161,12 +161,19 @@ findShallow
-> Backend m [ShallowListEntry v Ann] -> Backend m [ShallowListEntry v Ann]
findShallow codebase path' = do findShallow codebase path' = do
let path = Path.unabsolute path' let path = Path.unabsolute path'
hashLength <- lift $ Codebase.hashLength codebase
root <- getRootBranch codebase root <- getRootBranch codebase
let mayb0 = Branch.head <$> Branch.getAt path root let mayb = Branch.getAt path root
case mayb0 of case mayb of
Nothing -> pure [] Nothing -> pure []
Just b0 -> do Just b -> findShallowInBranch codebase b
findShallowInBranch
:: (Monad m, Var v)
=> Codebase m v Ann
-> Branch m
-> Backend m [ShallowListEntry v Ann]
findShallowInBranch codebase b = do
hashLength <- lift $ Codebase.hashLength codebase
let hqTerm b0 ns r = let hqTerm b0 ns r =
let refs = Star3.lookupD1 ns . Branch._terms $ b0 let refs = Star3.lookupD1 ns . Branch._terms $ b0
in case length refs of in case length refs of
@ -180,8 +187,8 @@ findShallow codebase path' = do
defnCount b = defnCount b =
(R.size . Branch.deepTerms $ Branch.head b) (R.size . Branch.deepTerms $ Branch.head b)
+ (R.size . Branch.deepTypes $ Branch.head b) + (R.size . Branch.deepTypes $ Branch.head b)
termEntries <- for (R.toList . Star3.d1 $ Branch._terms b0) $ \(r, ns) -> b0 = Branch.head b
do termEntries <- for (R.toList . Star3.d1 $ Branch._terms b0) $ \(r, ns) -> do
ot <- lift $ loadReferentType codebase r ot <- lift $ loadReferentType codebase r
pure $ ShallowTermEntry r (hqTerm b0 ns r) ot pure $ ShallowTermEntry r (hqTerm b0 ns r) ot
let let
@ -206,6 +213,7 @@ findShallow codebase path' = do
++ branchEntries ++ branchEntries
++ patchEntries ++ patchEntries
termReferencesByShortHash termReferencesByShortHash
:: Monad m => Codebase m v a -> ShortHash -> m (Set Reference) :: Monad m => Codebase m v a -> ShortHash -> m (Set Reference)
typeReferencesByShortHash codebase sh = do typeReferencesByShortHash codebase sh = do