mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Fix runnables not seeing test and bench attributes
This commit is contained in:
parent
351cec0cb4
commit
7342dcf0b0
3 changed files with 42 additions and 18 deletions
|
@ -562,6 +562,28 @@ impl<N: AstNode> InFile<N> {
|
|||
pub fn syntax(&self) -> InFile<&SyntaxNode> {
|
||||
self.with_value(self.value.syntax())
|
||||
}
|
||||
|
||||
pub fn nodes_with_attributes<'db>(
|
||||
self,
|
||||
db: &'db dyn db::AstDatabase,
|
||||
) -> impl Iterator<Item = InFile<N>> + 'db
|
||||
where
|
||||
N: 'db,
|
||||
{
|
||||
std::iter::successors(Some(self), move |node| {
|
||||
let InFile { file_id, value } = node.file_id.call_node(db)?;
|
||||
N::cast(value).map(|n| InFile::new(file_id, n))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn node_with_attributes(self, db: &dyn db::AstDatabase) -> InFile<N> {
|
||||
std::iter::successors(Some(self), move |node| {
|
||||
let InFile { file_id, value } = node.file_id.call_node(db)?;
|
||||
N::cast(value).map(|n| InFile::new(file_id, n))
|
||||
})
|
||||
.last()
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
/// Given a `MacroCallId`, return what `FragmentKind` it belongs to.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue