aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/inlay_hints.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-01-15 19:38:10 +0000
committerGitHub <[email protected]>2020-01-15 19:38:10 +0000
commitc78d269b66dd7e02321bf447eef1375c81f66a1e (patch)
tree8ec28f0ecd713783aa4d7032bdf324ace7bc8911 /crates/ra_ide/src/inlay_hints.rs
parentaa2e13b37f4508168fb064a79d0190fa705d8a47 (diff)
parentaaef88db0e2602e010f78e26a80d974be12c1f71 (diff)
Merge #2837
2837: Accidentally quadratic r=matklad a=matklad Our syntax highlighting is accdentally quadratic. Current state of the PR fixes it in a pretty crude way, looks like for the proper fix we need to redo how source-analyzer works. **NB:** don't be scared by diff stats, that's mostly a test-data file Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/inlay_hints.rs')
-rw-r--r--crates/ra_ide/src/inlay_hints.rs11
1 files changed, 6 insertions, 5 deletions
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 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir::{HirDisplay, SourceAnalyzer}; 3use hir::{HirDisplay, SourceAnalyzer, SourceBinder};
4use once_cell::unsync::Lazy; 4use once_cell::unsync::Lazy;
5use ra_prof::profile; 5use ra_prof::profile;
6use ra_syntax::{ 6use ra_syntax::{
@@ -29,22 +29,23 @@ pub(crate) fn inlay_hints(
29 file: &SourceFile, 29 file: &SourceFile,
30 max_inlay_hint_length: Option<usize>, 30 max_inlay_hint_length: Option<usize>,
31) -> Vec<InlayHint> { 31) -> Vec<InlayHint> {
32 let mut sb = SourceBinder::new(db);
32 file.syntax() 33 file.syntax()
33 .descendants() 34 .descendants()
34 .flat_map(|node| get_inlay_hints(db, file_id, &node, max_inlay_hint_length)) 35 .flat_map(|node| get_inlay_hints(&mut sb, file_id, &node, max_inlay_hint_length))
35 .flatten() 36 .flatten()
36 .collect() 37 .collect()
37} 38}
38 39
39fn get_inlay_hints( 40fn get_inlay_hints(
40 db: &RootDatabase, 41 sb: &mut SourceBinder<RootDatabase>,
41 file_id: FileId, 42 file_id: FileId,
42 node: &SyntaxNode, 43 node: &SyntaxNode,
43 max_inlay_hint_length: Option<usize>, 44 max_inlay_hint_length: Option<usize>,
44) -> Option<Vec<InlayHint>> { 45) -> Option<Vec<InlayHint>> {
45 let _p = profile("get_inlay_hints"); 46 let _p = profile("get_inlay_hints");
46 let analyzer = 47 let db = sb.db;
47 Lazy::new(|| SourceAnalyzer::new(db, hir::InFile::new(file_id.into(), node), None)); 48 let analyzer = Lazy::new(move || sb.analyze(hir::InFile::new(file_id.into(), node), None));
48 match_ast! { 49 match_ast! {
49 match node { 50 match node {
50 ast::LetStmt(it) => { 51 ast::LetStmt(it) => {