Skip to content

Commit c8d7d0d

Browse files
committed
Rust: extract ImplItem
1 parent e23120f commit c8d7d0d

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

rust/extractor/src/crate_graph.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ pub fn extract_crate_graph(trap_provider: &trap::TrapFileProvider, db: &RootData
112112
let items = &module.scope;
113113
let mut values = Vec::new();
114114
let mut types = Vec::new();
115-
116115
for (name, item) in items.entries() {
117116
let def = item.with_visibility(ra_ap_hir::Visibility::Public);
118117
if let Some((value, _, _import)) = def.values {
@@ -280,12 +279,43 @@ pub fn extract_crate_graph(trap_provider: &trap::TrapFileProvider, db: &RootData
280279
}
281280
}
282281
}
282+
let impls: Vec<_> = items
283+
.impls()
284+
.map(|imp| {
285+
let imp = db.impl_data(imp);
286+
let self_ty = emit_hir_typeref(trap, &imp.self_ty);
287+
let target_trait = match imp.target_trait.as_ref() {
288+
Some(t) => emit_hir_path(&t.path),
289+
None => vec![],
290+
};
291+
let mut method_names = Vec::new();
292+
let mut method_types = Vec::new();
293+
for item in &imp.items {
294+
if let AssocItemId::FunctionId(function) = item {
295+
let function = db.function_data(*function);
296+
let method_type = emit_hir_fn_data(trap, &function);
297+
method_names.push(function.name.as_str().to_owned());
298+
method_types.push(method_type);
299+
};
300+
}
301+
302+
trap.emit(generated::ImplItem {
303+
id: trap::TrapId::Star,
304+
target_trait,
305+
self_ty,
306+
method_names,
307+
method_types,
308+
})
309+
})
310+
.collect();
311+
283312
let label = trap.emit(generated::CrateModule {
284313
id: trap::TrapId::Star,
285314
name: name.to_owned(),
286315
parent,
287316
values,
288317
types,
318+
impls,
289319
});
290320
for (name, child) in module
291321
.children

0 commit comments

Comments
 (0)