Show aliases when searching by type

This commit is contained in:
Mitchell Rosen 2020-01-04 21:16:15 -05:00
parent 7b98c3455c
commit 09afe1e1f0
2 changed files with 9 additions and 18 deletions

View File

@ -1567,8 +1567,14 @@ _searchBranchPrefix b n = case Path.unsnoc (Path.fromName n) of
searchResultsFor :: Names0 -> [Referent] -> [Reference] -> [SearchResult]
searchResultsFor ns terms types =
[ SR.termSearchResult ns (Names.termName ns ref) ref | ref <- terms ] <>
[ SR.typeSearchResult ns (Names.typeName ns ref) ref | ref <- types ]
[ SR.termSearchResult ns name ref
| ref <- terms
, name <- toList (Names.namesForReferent ns ref)
] <>
[ SR.typeSearchResult ns name ref
| ref <- types
, name <- toList (Names.namesForReference ns ref)
]
searchBranchScored :: forall score. (Ord score)
=> Names0

View File

@ -27,8 +27,6 @@ module Unison.Names2
, prefix0
, restrictReferences
, refTermsNamed
, termName
, typeName
, terms
, types
, termReferences
@ -39,6 +37,7 @@ module Unison.Names2
, unionLeft
, unionLeftName
, namesForReference
, namesForReferent
)
where
@ -175,20 +174,6 @@ numHashChars b = lenFor hashes
g s r = Set.insert r s
f s r = Set.insert (Referent.toReference r) s
typeName :: Ord n => Names' n -> Reference -> n
typeName names r =
case toList $ R.lookupRan r (types names) of
hq : _ -> hq
_ -> error
("Names construction should have included something for " <> show r)
termName :: Ord n => Names' n -> Referent -> n
termName names r =
case toList $ R.lookupRan r (terms names) of
hq : _ -> hq
_ -> error
("Names construction should have included something for " <> show r)
termsNamed :: Ord n => Names' n -> n -> Set Referent
termsNamed = flip R.lookupDom . terms