From 06fbd6905014b90aa2efc1f67b92f31845011d76 Mon Sep 17 00:00:00 2001 From: vsrs Date: Wed, 2 Sep 2020 16:03:05 +0300 Subject: Make method references CodeLens lazy. --- crates/ide/src/lib.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'crates/ide/src/lib.rs') diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index 4763c0aac..286a6a110 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs @@ -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> { + 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, -- cgit v1.2.3