aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/call_info.rs6
-rw-r--r--crates/ra_ide_api/src/completion/completion_context.rs7
-rw-r--r--crates/ra_ide_api/src/goto_type_definition.rs3
-rw-r--r--crates/ra_ide_api/src/hover.rs3
-rw-r--r--crates/ra_ide_api/src/inlay_hints.rs7
-rw-r--r--crates/ra_ide_api/src/references/classify.rs3
6 files changed, 17 insertions, 12 deletions
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs
index 3572825b5..41ee81511 100644
--- a/crates/ra_ide_api/src/call_info.rs
+++ b/crates/ra_ide_api/src/call_info.rs
@@ -19,7 +19,11 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
19 let calling_node = FnCallNode::with_node(&syntax, position.offset)?; 19 let calling_node = FnCallNode::with_node(&syntax, position.offset)?;
20 let name_ref = calling_node.name_ref()?; 20 let name_ref = calling_node.name_ref()?;
21 21
22 let analyzer = hir::SourceAnalyzer::new(db, position.file_id, name_ref.syntax(), None); 22 let analyzer = hir::SourceAnalyzer::new(
23 db,
24 hir::Source::new(position.file_id.into(), name_ref.syntax()),
25 None,
26 );
23 let (mut call_info, has_self) = match &calling_node { 27 let (mut call_info, has_self) = match &calling_node {
24 FnCallNode::CallExpr(expr) => { 28 FnCallNode::CallExpr(expr) => {
25 //FIXME: apply subst 29 //FIXME: apply subst
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs
index 64cbc0f98..0906a4e1b 100644
--- a/crates/ra_ide_api/src/completion/completion_context.rs
+++ b/crates/ra_ide_api/src/completion/completion_context.rs
@@ -58,8 +58,11 @@ impl<'a> CompletionContext<'a> {
58 ); 58 );
59 let token = 59 let token =
60 original_parse.tree().syntax().token_at_offset(position.offset).left_biased()?; 60 original_parse.tree().syntax().token_at_offset(position.offset).left_biased()?;
61 let analyzer = 61 let analyzer = hir::SourceAnalyzer::new(
62 hir::SourceAnalyzer::new(db, position.file_id, &token.parent(), Some(position.offset)); 62 db,
63 hir::Source::new(position.file_id.into(), &token.parent()),
64 Some(position.offset),
65 );
63 let mut ctx = CompletionContext { 66 let mut ctx = CompletionContext {
64 db, 67 db,
65 analyzer, 68 analyzer,
diff --git a/crates/ra_ide_api/src/goto_type_definition.rs b/crates/ra_ide_api/src/goto_type_definition.rs
index 71146591d..2327cb1e7 100644
--- a/crates/ra_ide_api/src/goto_type_definition.rs
+++ b/crates/ra_ide_api/src/goto_type_definition.rs
@@ -18,7 +18,8 @@ pub(crate) fn goto_type_definition(
18 .find(|n| ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some()) 18 .find(|n| ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some())
19 })?; 19 })?;
20 20
21 let analyzer = hir::SourceAnalyzer::new(db, position.file_id, &node, None); 21 let analyzer =
22 hir::SourceAnalyzer::new(db, hir::Source::new(position.file_id.into(), &node), None);
22 23
23 let ty: hir::Ty = if let Some(ty) = 24 let ty: hir::Ty = if let Some(ty) =
24 ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e)) 25 ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e))
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index 07d511fb3..92b4b1f79 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -230,7 +230,8 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> {
230 .ancestors() 230 .ancestors()
231 .take_while(|it| it.text_range() == leaf_node.text_range()) 231 .take_while(|it| it.text_range() == leaf_node.text_range())
232 .find(|it| ast::Expr::cast(it.clone()).is_some() || ast::Pat::cast(it.clone()).is_some())?; 232 .find(|it| ast::Expr::cast(it.clone()).is_some() || ast::Pat::cast(it.clone()).is_some())?;
233 let analyzer = hir::SourceAnalyzer::new(db, frange.file_id, &node, None); 233 let analyzer =
234 hir::SourceAnalyzer::new(db, hir::Source::new(frange.file_id.into(), &node), None);
234 let ty = if let Some(ty) = ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e)) 235 let ty = if let Some(ty) = ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e))
235 { 236 {
236 ty 237 ty
diff --git a/crates/ra_ide_api/src/inlay_hints.rs b/crates/ra_ide_api/src/inlay_hints.rs
index 2ff10b89a..0cd959848 100644
--- a/crates/ra_ide_api/src/inlay_hints.rs
+++ b/crates/ra_ide_api/src/inlay_hints.rs
@@ -32,6 +32,7 @@ fn get_inlay_hints(
32 file_id: FileId, 32 file_id: FileId,
33 node: &SyntaxNode, 33 node: &SyntaxNode,
34) -> Option<Vec<InlayHint>> { 34) -> Option<Vec<InlayHint>> {
35 let analyzer = SourceAnalyzer::new(db, hir::Source::new(file_id.into(), node), None);
35 match_ast! { 36 match_ast! {
36 match node { 37 match node {
37 ast::LetStmt(it) => { 38 ast::LetStmt(it) => {
@@ -39,11 +40,9 @@ fn get_inlay_hints(
39 return None; 40 return None;
40 } 41 }
41 let pat = it.pat()?; 42 let pat = it.pat()?;
42 let analyzer = SourceAnalyzer::new(db, file_id, it.syntax(), None);
43 Some(get_pat_type_hints(db, &analyzer, pat, false)) 43 Some(get_pat_type_hints(db, &analyzer, pat, false))
44 }, 44 },
45 ast::LambdaExpr(it) => { 45 ast::LambdaExpr(it) => {
46 let analyzer = SourceAnalyzer::new(db, file_id, it.syntax(), None);
47 it.param_list().map(|param_list| { 46 it.param_list().map(|param_list| {
48 param_list 47 param_list
49 .params() 48 .params()
@@ -56,21 +55,17 @@ fn get_inlay_hints(
56 }, 55 },
57 ast::ForExpr(it) => { 56 ast::ForExpr(it) => {
58 let pat = it.pat()?; 57 let pat = it.pat()?;
59 let analyzer = SourceAnalyzer::new(db, file_id, it.syntax(), None);
60 Some(get_pat_type_hints(db, &analyzer, pat, false)) 58 Some(get_pat_type_hints(db, &analyzer, pat, false))
61 }, 59 },
62 ast::IfExpr(it) => { 60 ast::IfExpr(it) => {
63 let pat = it.condition()?.pat()?; 61 let pat = it.condition()?.pat()?;
64 let analyzer = SourceAnalyzer::new(db, file_id, it.syntax(), None);
65 Some(get_pat_type_hints(db, &analyzer, pat, true)) 62 Some(get_pat_type_hints(db, &analyzer, pat, true))
66 }, 63 },
67 ast::WhileExpr(it) => { 64 ast::WhileExpr(it) => {
68 let pat = it.condition()?.pat()?; 65 let pat = it.condition()?.pat()?;
69 let analyzer = SourceAnalyzer::new(db, file_id, it.syntax(), None);
70 Some(get_pat_type_hints(db, &analyzer, pat, true)) 66 Some(get_pat_type_hints(db, &analyzer, pat, true))
71 }, 67 },
72 ast::MatchArmList(it) => { 68 ast::MatchArmList(it) => {
73 let analyzer = SourceAnalyzer::new(db, file_id, it.syntax(), None);
74 Some( 69 Some(
75 it 70 it
76 .arms() 71 .arms()
diff --git a/crates/ra_ide_api/src/references/classify.rs b/crates/ra_ide_api/src/references/classify.rs
index 0eeaa7f38..f12b58cb9 100644
--- a/crates/ra_ide_api/src/references/classify.rs
+++ b/crates/ra_ide_api/src/references/classify.rs
@@ -129,7 +129,8 @@ pub(crate) fn classify_name_ref(
129 let _p = profile("classify_name_ref"); 129 let _p = profile("classify_name_ref");
130 130
131 let parent = name_ref.syntax().parent()?; 131 let parent = name_ref.syntax().parent()?;
132 let analyzer = SourceAnalyzer::new(db, file_id, name_ref.syntax(), None); 132 let analyzer =
133 SourceAnalyzer::new(db, hir::Source::new(file_id.into(), name_ref.syntax()), None);
133 134
134 if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) { 135 if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) {
135 tested_by!(goto_definition_works_for_methods); 136 tested_by!(goto_definition_works_for_methods);