mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Make method references CodeLens lazy.
This commit is contained in:
parent
b7fda5f936
commit
06fbd69050
2 changed files with 55 additions and 42 deletions
|
@ -56,7 +56,7 @@ use ide_db::{
|
|||
symbol_index::{self, FileSymbol},
|
||||
LineIndexDatabase,
|
||||
};
|
||||
use syntax::{SourceFile, TextRange, TextSize};
|
||||
use syntax::{SourceFile, SyntaxKind, TextRange, TextSize};
|
||||
|
||||
use crate::display::ToNav;
|
||||
|
||||
|
@ -369,6 +369,21 @@ impl Analysis {
|
|||
})
|
||||
}
|
||||
|
||||
/// Finds all methods and free functions for the file.
|
||||
pub fn find_all_methods(&self, file_id: FileId) -> Cancelable<Vec<FileRange>> {
|
||||
let res = self
|
||||
.file_structure(file_id)?
|
||||
.into_iter()
|
||||
.filter(|it| match it.kind {
|
||||
SyntaxKind::FN => true,
|
||||
_ => false,
|
||||
})
|
||||
.filter_map(|it| Some(FileRange { file_id, range: it.navigation_range }))
|
||||
.collect();
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
/// Returns a short text describing element at position.
|
||||
pub fn hover(
|
||||
&self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue