File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ use hir_def::{
9
9
builtin_type:: BuiltinType ,
10
10
docs:: Documentation ,
11
11
expr:: { BindingAnnotation , Pat , PatId } ,
12
+ import_map,
12
13
per_ns:: PerNs ,
13
14
resolver:: { HasResolver , Resolver } ,
14
15
type_ref:: { Mutability , TypeRef } ,
@@ -98,6 +99,19 @@ impl Crate {
98
99
db. crate_graph ( ) [ self . id ] . display_name . as_ref ( ) . cloned ( )
99
100
}
100
101
102
+ pub fn query_external_importables (
103
+ self ,
104
+ db : & dyn DefDatabase ,
105
+ query : & str ,
106
+ ) -> impl Iterator < Item = Either < ModuleDef , MacroDef > > {
107
+ import_map:: search_dependencies ( db, self . into ( ) , import_map:: Query :: new ( query) . anchor_end ( ) )
108
+ . into_iter ( )
109
+ . map ( |item| match item {
110
+ ItemInNs :: Types ( mod_id) | ItemInNs :: Values ( mod_id) => Either :: Left ( mod_id. into ( ) ) ,
111
+ ItemInNs :: Macros ( mac_id) => Either :: Right ( mac_id. into ( ) ) ,
112
+ } )
113
+ }
114
+
101
115
pub fn all ( db : & dyn HirDatabase ) -> Vec < Crate > {
102
116
db. crate_graph ( ) . iter ( ) . map ( |id| Crate { id } ) . collect ( )
103
117
}
You can’t perform that action at this time.
0 commit comments