diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_analysis/src/hir/function/mod.rs | 20 | ||||
-rw-r--r-- | crates/ra_analysis/src/hir/mod.rs | 2 | ||||
-rw-r--r-- | crates/ra_analysis/src/hir/module/nameres.rs | 4 | ||||
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 13 |
4 files changed, 19 insertions, 20 deletions
diff --git a/crates/ra_analysis/src/hir/function/mod.rs b/crates/ra_analysis/src/hir/function/mod.rs index d171b6a8d..9ca8f4e7c 100644 --- a/crates/ra_analysis/src/hir/function/mod.rs +++ b/crates/ra_analysis/src/hir/function/mod.rs | |||
@@ -25,43 +25,43 @@ impl FnId { | |||
25 | } | 25 | } |
26 | } | 26 | } |
27 | 27 | ||
28 | pub(crate) struct FunctionDescriptor { | 28 | pub(crate) struct Function { |
29 | fn_id: FnId, | 29 | fn_id: FnId, |
30 | } | 30 | } |
31 | 31 | ||
32 | impl FunctionDescriptor { | 32 | impl Function { |
33 | pub(crate) fn guess_from_source( | 33 | pub(crate) fn guess_from_source( |
34 | db: &impl HirDatabase, | 34 | db: &impl HirDatabase, |
35 | file_id: FileId, | 35 | file_id: FileId, |
36 | fn_def: ast::FnDef, | 36 | fn_def: ast::FnDef, |
37 | ) -> FunctionDescriptor { | 37 | ) -> Function { |
38 | let fn_id = FnId::get(db, file_id, fn_def); | 38 | let fn_id = FnId::get(db, file_id, fn_def); |
39 | FunctionDescriptor { fn_id } | 39 | Function { fn_id } |
40 | } | 40 | } |
41 | 41 | ||
42 | pub(crate) fn guess_for_name_ref( | 42 | pub(crate) fn guess_for_name_ref( |
43 | db: &impl HirDatabase, | 43 | db: &impl HirDatabase, |
44 | file_id: FileId, | 44 | file_id: FileId, |
45 | name_ref: ast::NameRef, | 45 | name_ref: ast::NameRef, |
46 | ) -> Option<FunctionDescriptor> { | 46 | ) -> Option<Function> { |
47 | FunctionDescriptor::guess_for_node(db, file_id, name_ref.syntax()) | 47 | Function::guess_for_node(db, file_id, name_ref.syntax()) |
48 | } | 48 | } |
49 | 49 | ||
50 | pub(crate) fn guess_for_bind_pat( | 50 | pub(crate) fn guess_for_bind_pat( |
51 | db: &impl HirDatabase, | 51 | db: &impl HirDatabase, |
52 | file_id: FileId, | 52 | file_id: FileId, |
53 | bind_pat: ast::BindPat, | 53 | bind_pat: ast::BindPat, |
54 | ) -> Option<FunctionDescriptor> { | 54 | ) -> Option<Function> { |
55 | FunctionDescriptor::guess_for_node(db, file_id, bind_pat.syntax()) | 55 | Function::guess_for_node(db, file_id, bind_pat.syntax()) |
56 | } | 56 | } |
57 | 57 | ||
58 | fn guess_for_node( | 58 | fn guess_for_node( |
59 | db: &impl HirDatabase, | 59 | db: &impl HirDatabase, |
60 | file_id: FileId, | 60 | file_id: FileId, |
61 | node: SyntaxNodeRef, | 61 | node: SyntaxNodeRef, |
62 | ) -> Option<FunctionDescriptor> { | 62 | ) -> Option<Function> { |
63 | let fn_def = node.ancestors().find_map(ast::FnDef::cast)?; | 63 | let fn_def = node.ancestors().find_map(ast::FnDef::cast)?; |
64 | let res = FunctionDescriptor::guess_from_source(db, file_id, fn_def); | 64 | let res = Function::guess_from_source(db, file_id, fn_def); |
65 | Some(res) | 65 | Some(res) |
66 | } | 66 | } |
67 | 67 | ||
diff --git a/crates/ra_analysis/src/hir/mod.rs b/crates/ra_analysis/src/hir/mod.rs index 1de8fadcf..863ffd919 100644 --- a/crates/ra_analysis/src/hir/mod.rs +++ b/crates/ra_analysis/src/hir/mod.rs | |||
@@ -20,7 +20,7 @@ use crate::{ | |||
20 | pub(crate) use self::{ | 20 | pub(crate) use self::{ |
21 | path::{Path, PathKind}, | 21 | path::{Path, PathKind}, |
22 | module::{Module, ModuleId, Problem, nameres::FileItemId}, | 22 | module::{Module, ModuleId, Problem, nameres::FileItemId}, |
23 | function::{FunctionDescriptor, FnScopes}, | 23 | function::{Function, FnScopes}, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | pub use self::function::FnSignatureInfo; | 26 | pub use self::function::FnSignatureInfo; |
diff --git a/crates/ra_analysis/src/hir/module/nameres.rs b/crates/ra_analysis/src/hir/module/nameres.rs index db5d6d9c0..2ff5e0537 100644 --- a/crates/ra_analysis/src/hir/module/nameres.rs +++ b/crates/ra_analysis/src/hir/module/nameres.rs | |||
@@ -371,7 +371,7 @@ mod tests { | |||
371 | use crate::{ | 371 | use crate::{ |
372 | AnalysisChange, | 372 | AnalysisChange, |
373 | mock_analysis::{MockAnalysis, analysis_and_position}, | 373 | mock_analysis::{MockAnalysis, analysis_and_position}, |
374 | hir::{HirDatabase, module::ModuleDescriptor}, | 374 | hir::{self, HirDatabase}, |
375 | input::FilesDatabase, | 375 | input::FilesDatabase, |
376 | }; | 376 | }; |
377 | use super::*; | 377 | use super::*; |
@@ -380,7 +380,7 @@ mod tests { | |||
380 | let (analysis, pos) = analysis_and_position(fixture); | 380 | let (analysis, pos) = analysis_and_position(fixture); |
381 | let db = analysis.imp.db; | 381 | let db = analysis.imp.db; |
382 | let source_root = db.file_source_root(pos.file_id); | 382 | let source_root = db.file_source_root(pos.file_id); |
383 | let descr = ModuleDescriptor::guess_from_position(&*db, pos) | 383 | let descr = hir::Module::guess_from_position(&*db, pos) |
384 | .unwrap() | 384 | .unwrap() |
385 | .unwrap(); | 385 | .unwrap(); |
386 | let module_id = descr.module_id; | 386 | let module_id = descr.module_id; |
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 9118ed7d4..2e5853949 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -21,7 +21,7 @@ use crate::{ | |||
21 | db::{self, FileSyntaxQuery, SyntaxDatabase}, | 21 | db::{self, FileSyntaxQuery, SyntaxDatabase}, |
22 | hir::{ | 22 | hir::{ |
23 | self, | 23 | self, |
24 | FunctionDescriptor, FnSignatureInfo, | 24 | FnSignatureInfo, |
25 | Problem, | 25 | Problem, |
26 | }, | 26 | }, |
27 | input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, | 27 | input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, |
@@ -274,7 +274,7 @@ impl AnalysisImpl { | |||
274 | let syntax = file.syntax(); | 274 | let syntax = file.syntax(); |
275 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { | 275 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { |
276 | if let Some(fn_descr) = | 276 | if let Some(fn_descr) = |
277 | FunctionDescriptor::guess_for_name_ref(&*self.db, position.file_id, name_ref) | 277 | hir::Function::guess_for_name_ref(&*self.db, position.file_id, name_ref) |
278 | { | 278 | { |
279 | let scope = fn_descr.scope(&*self.db); | 279 | let scope = fn_descr.scope(&*self.db); |
280 | // First try to resolve the symbol locally | 280 | // First try to resolve the symbol locally |
@@ -344,14 +344,14 @@ impl AnalysisImpl { | |||
344 | db: &db::RootDatabase, | 344 | db: &db::RootDatabase, |
345 | source_file: &'a SourceFileNode, | 345 | source_file: &'a SourceFileNode, |
346 | position: FilePosition, | 346 | position: FilePosition, |
347 | ) -> Option<(ast::BindPat<'a>, FunctionDescriptor)> { | 347 | ) -> Option<(ast::BindPat<'a>, hir::Function)> { |
348 | let syntax = source_file.syntax(); | 348 | let syntax = source_file.syntax(); |
349 | if let Some(binding) = find_node_at_offset::<ast::BindPat>(syntax, position.offset) { | 349 | if let Some(binding) = find_node_at_offset::<ast::BindPat>(syntax, position.offset) { |
350 | let descr = FunctionDescriptor::guess_for_bind_pat(db, position.file_id, binding)?; | 350 | let descr = hir::Function::guess_for_bind_pat(db, position.file_id, binding)?; |
351 | return Some((binding, descr)); | 351 | return Some((binding, descr)); |
352 | }; | 352 | }; |
353 | let name_ref = find_node_at_offset::<ast::NameRef>(syntax, position.offset)?; | 353 | let name_ref = find_node_at_offset::<ast::NameRef>(syntax, position.offset)?; |
354 | let descr = FunctionDescriptor::guess_for_name_ref(db, position.file_id, name_ref)?; | 354 | let descr = hir::Function::guess_for_name_ref(db, position.file_id, name_ref)?; |
355 | let scope = descr.scope(db); | 355 | let scope = descr.scope(db); |
356 | let resolved = scope.resolve_local_name(name_ref)?; | 356 | let resolved = scope.resolve_local_name(name_ref)?; |
357 | let resolved = resolved.ptr().resolve(source_file); | 357 | let resolved = resolved.ptr().resolve(source_file); |
@@ -472,8 +472,7 @@ impl AnalysisImpl { | |||
472 | if fs.kind == FN_DEF { | 472 | if fs.kind == FN_DEF { |
473 | let fn_file = self.db.file_syntax(fn_file_id); | 473 | let fn_file = self.db.file_syntax(fn_file_id); |
474 | if let Some(fn_def) = find_node_at_offset(fn_file.syntax(), fs.node_range.start()) { | 474 | if let Some(fn_def) = find_node_at_offset(fn_file.syntax(), fs.node_range.start()) { |
475 | let descr = | 475 | let descr = hir::Function::guess_from_source(&*self.db, fn_file_id, fn_def); |
476 | FunctionDescriptor::guess_from_source(&*self.db, fn_file_id, fn_def); | ||
477 | if let Some(descriptor) = descr.signature_info(&*self.db) { | 476 | if let Some(descriptor) = descr.signature_info(&*self.db) { |
478 | // If we have a calling expression let's find which argument we are on | 477 | // If we have a calling expression let's find which argument we are on |
479 | let mut current_parameter = None; | 478 | let mut current_parameter = None; |