scip: Populate SymbolInformation::enclosing_symbol

For local variables, this gets the moniker from the enclosing
definition and stores it into the TokenStaticData.
Then it builds the scip symbol for that moniker when building the
SymbolInformation.
This commit is contained in:
Nicolas Guichard 2023-12-05 18:29:48 +01:00
parent 62663e6d4b
commit 495a55689b
3 changed files with 40 additions and 5 deletions

View file

@ -47,6 +47,7 @@ pub struct TokenStaticData {
pub references: Vec<ReferenceData>,
pub moniker: Option<MonikerResult>,
pub display_name: Option<String>,
pub enclosing_moniker: Option<MonikerResult>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@ -174,6 +175,9 @@ impl StaticIndex<'_> {
references: vec![],
moniker: current_crate.and_then(|cc| def_to_moniker(self.db, def, cc)),
display_name: def.name(self.db).map(|name| name.display(self.db).to_string()),
enclosing_moniker: current_crate
.zip(def.enclosing_definition(self.db))
.and_then(|(cc, enclosing_def)| def_to_moniker(self.db, enclosing_def, cc)),
});
self.def_map.insert(def, it);
it