From 4194e5c88c61879bd63db488167b1460437f3e76 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 14 Jan 2020 17:45:52 +0100 Subject: Optimize inlay hints --- crates/ra_ide/src/inlay_hints.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 8cb0c70dd..e2da96129 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -1,6 +1,6 @@ //! FIXME: write short doc here -use hir::{HirDisplay, SourceAnalyzer}; +use hir::{HirDisplay, SourceAnalyzer, SourceBinder}; use once_cell::unsync::Lazy; use ra_prof::profile; use ra_syntax::{ @@ -29,22 +29,23 @@ pub(crate) fn inlay_hints( file: &SourceFile, max_inlay_hint_length: Option, ) -> Vec { + let mut sb = SourceBinder::new(db); file.syntax() .descendants() - .flat_map(|node| get_inlay_hints(db, file_id, &node, max_inlay_hint_length)) + .flat_map(|node| get_inlay_hints(&mut sb, file_id, &node, max_inlay_hint_length)) .flatten() .collect() } fn get_inlay_hints( - db: &RootDatabase, + sb: &mut SourceBinder, file_id: FileId, node: &SyntaxNode, max_inlay_hint_length: Option, ) -> Option> { let _p = profile("get_inlay_hints"); - let analyzer = - Lazy::new(|| SourceAnalyzer::new(db, hir::InFile::new(file_id.into(), node), None)); + let db = sb.db; + let analyzer = Lazy::new(move || sb.analyze(hir::InFile::new(file_id.into(), node), None)); match_ast! { match node { ast::LetStmt(it) => { -- cgit v1.2.3