diff options
author | Aleksey Kladov <[email protected]> | 2018-10-25 14:25:24 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-25 14:25:40 +0100 |
commit | 772acb53f2d7568ff1cc2ba4ca84a47110f13b3a (patch) | |
tree | d9d30baaee8b6cd13cb30c38b7c854264c15f2b2 /crates | |
parent | 171acad15b1eacdfb12612a7615f4f6b21e5bf99 (diff) |
use correct file when resolving callables
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 5 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/path_map.rs | 13 |
2 files changed, 14 insertions, 4 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 6c1a4749a..b24b5cfdc 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -438,9 +438,10 @@ impl AnalysisImpl { | |||
438 | 438 | ||
439 | // Resolve the function's NameRef (NOTE: this isn't entirely accurate). | 439 | // Resolve the function's NameRef (NOTE: this isn't entirely accurate). |
440 | let file_symbols = self.index_resolve(name_ref)?; | 440 | let file_symbols = self.index_resolve(name_ref)?; |
441 | for (_, fs) in file_symbols { | 441 | for (fn_fiel_id, fs) in file_symbols { |
442 | if fs.kind == FN_DEF { | 442 | if fs.kind == FN_DEF { |
443 | if let Some(fn_def) = find_node_at_offset(syntax, fs.node_range.start()) { | 443 | let fn_file = self.db.file_syntax(fn_fiel_id); |
444 | if let Some(fn_def) = find_node_at_offset(fn_file.syntax(), fs.node_range.start()) { | ||
444 | if let Some(descriptor) = FnDescriptor::new(fn_def) { | 445 | if let Some(descriptor) = FnDescriptor::new(fn_def) { |
445 | // If we have a calling expression let's find which argument we are on | 446 | // If we have a calling expression let's find which argument we are on |
446 | let mut current_parameter = None; | 447 | let mut current_parameter = None; |
diff --git a/crates/ra_lsp_server/src/path_map.rs b/crates/ra_lsp_server/src/path_map.rs index b3d1dc3db..d5957d673 100644 --- a/crates/ra_lsp_server/src/path_map.rs +++ b/crates/ra_lsp_server/src/path_map.rs | |||
@@ -1,4 +1,7 @@ | |||
1 | use std::path::{Component, Path, PathBuf}; | 1 | use std::{ |
2 | fmt, | ||
3 | path::{Component, Path, PathBuf}, | ||
4 | }; | ||
2 | 5 | ||
3 | use im; | 6 | use im; |
4 | use ra_analysis::{FileId, FileResolver}; | 7 | use ra_analysis::{FileId, FileResolver}; |
@@ -10,7 +13,7 @@ pub enum Root { | |||
10 | Lib, | 13 | Lib, |
11 | } | 14 | } |
12 | 15 | ||
13 | #[derive(Debug, Default, Clone)] | 16 | #[derive(Default, Clone)] |
14 | pub struct PathMap { | 17 | pub struct PathMap { |
15 | next_id: u32, | 18 | next_id: u32, |
16 | path2id: im::HashMap<PathBuf, FileId>, | 19 | path2id: im::HashMap<PathBuf, FileId>, |
@@ -18,6 +21,12 @@ pub struct PathMap { | |||
18 | id2root: im::HashMap<FileId, Root>, | 21 | id2root: im::HashMap<FileId, Root>, |
19 | } | 22 | } |
20 | 23 | ||
24 | impl fmt::Debug for PathMap { | ||
25 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
26 | f.write_str("PathMap { ... }") | ||
27 | } | ||
28 | } | ||
29 | |||
21 | impl PathMap { | 30 | impl PathMap { |
22 | pub fn new() -> PathMap { | 31 | pub fn new() -> PathMap { |
23 | Default::default() | 32 | Default::default() |