Skip to content

Commit

Permalink
fix: don't include definition in template refs
Browse files Browse the repository at this point in the history
  • Loading branch information
Desdaemon committed Dec 4, 2023
1 parent 4ed16ba commit 4e20ba3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,14 @@ impl Backend {
.take(limit);
Ok(Some(locations.collect()))
}
pub fn template_references(&self, name: &str) -> miette::Result<Option<Vec<Location>>> {
pub fn template_references(&self, name: &str, include_definition: bool) -> miette::Result<Option<Vec<Location>>> {
let name = some!(interner().get(name));
let entry = some!(self.index.templates.get(&name.into()));
let definition_location = entry.value().location.clone().map(Location::from);
let definition_location = if include_definition {
entry.value().location.clone().map(Location::from)
} else {
None
};
let descendant_locations = (entry.value().descendants)
.iter()
.flat_map(|tpl| tpl.location.clone().map(Location::from));
Expand Down
5 changes: 2 additions & 3 deletions src/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,8 @@ impl Backend {
self.model_references(&model.into())
}
Some(RefKind::Ref(_)) | Some(RefKind::Id) => self.record_references(&cursor_value, current_module),
Some(RefKind::TName) | Some(RefKind::TInherit) | Some(RefKind::TCall) => {
self.template_references(&cursor_value)
}
Some(RefKind::TInherit) | Some(RefKind::TCall) => self.template_references(&cursor_value, true),
Some(RefKind::TName) => self.template_references(&cursor_value, false),
Some(RefKind::FieldName) | None => Ok(None),
}
}
Expand Down

0 comments on commit 4e20ba3

Please sign in to comment.