Merge #11793
11793: LSIF: consolidate references into a single edge where possible. r=Veykril a=khuey Co-authored-by: Kyle Huey <khuey@kylehuey.com>
This commit is contained in:
commit
e30747dfa8
@ -212,8 +212,17 @@ fn add_token(&mut self, id: TokenId, token: TokenStaticData) {
|
||||
in_v: result_id.into(),
|
||||
out_v: result_set_id.into(),
|
||||
}));
|
||||
let mut edges = token.references.iter().fold(
|
||||
HashMap::<_, Vec<lsp_types::NumberOrString>>::new(),
|
||||
|mut edges, x| {
|
||||
let entry =
|
||||
edges.entry((x.range.file_id, x.is_definition)).or_insert_with(Vec::new);
|
||||
entry.push((*self.range_map.get(&x.range).unwrap()).into());
|
||||
edges
|
||||
},
|
||||
);
|
||||
for x in token.references {
|
||||
let vertex = *self.range_map.get(&x.range).unwrap();
|
||||
if let Some(vertices) = edges.remove(&(x.range.file_id, x.is_definition)) {
|
||||
self.add_edge(lsif::Edge::Item(lsif::Item {
|
||||
document: (*self.file_map.get(&x.range.file_id).unwrap()).into(),
|
||||
property: Some(if x.is_definition {
|
||||
@ -222,13 +231,14 @@ fn add_token(&mut self, id: TokenId, token: TokenStaticData) {
|
||||
lsif::ItemKind::References
|
||||
}),
|
||||
edge_data: lsif::EdgeDataMultiIn {
|
||||
in_vs: vec![vertex.into()],
|
||||
in_vs: vertices,
|
||||
out_v: result_id.into(),
|
||||
},
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn add_file(&mut self, file: StaticIndexedFile) {
|
||||
let StaticIndexedFile { file_id, tokens, folds, .. } = file;
|
||||
|
Loading…
Reference in New Issue
Block a user