diff options
author | Jeremy A. Kolb <[email protected]> | 2018-10-05 20:21:40 +0100 |
---|---|---|
committer | Jeremy A. Kolb <[email protected]> | 2018-10-05 20:21:40 +0100 |
commit | 1d4c767879913271bf01912f12c7f8f176c7755d (patch) | |
tree | cfdc910fc9fc4437c52d79fc4cada661a30fd187 /crates/ra_editor/src | |
parent | 91312a9ff98d1f82313c42a2387df49fbdf09ac6 (diff) |
WIP: This doesn't currently work but I also don't think it's the right abstraction
Diffstat (limited to 'crates/ra_editor/src')
-rw-r--r-- | crates/ra_editor/src/lib.rs | 8 | ||||
-rw-r--r-- | crates/ra_editor/src/scope/mod.rs | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs index a93924e00..fcb3e12e6 100644 --- a/crates/ra_editor/src/lib.rs +++ b/crates/ra_editor/src/lib.rs | |||
@@ -164,6 +164,14 @@ pub fn find_node_at_offset<'a, N: AstNode<'a>>( | |||
164 | .next() | 164 | .next() |
165 | } | 165 | } |
166 | 166 | ||
167 | pub fn resolve_local_name<'a>(file: &'a File, offset: TextUnit, name_ref: ast::NameRef) -> Option<ast::Name<'a>> { | ||
168 | let fn_def = find_node_at_offset::<ast::FnDef>(file.syntax(), offset)?; | ||
169 | let scopes = scope::FnScopes::new(fn_def); | ||
170 | |||
171 | // TODO: This doesn't work because of scopes lifetime | ||
172 | scope::resolve_local_name(name_ref, &scopes) | ||
173 | } | ||
174 | |||
167 | #[cfg(test)] | 175 | #[cfg(test)] |
168 | mod tests { | 176 | mod tests { |
169 | use super::*; | 177 | use super::*; |
diff --git a/crates/ra_editor/src/scope/mod.rs b/crates/ra_editor/src/scope/mod.rs index 2f25230f8..7d6d530f7 100644 --- a/crates/ra_editor/src/scope/mod.rs +++ b/crates/ra_editor/src/scope/mod.rs | |||
@@ -2,7 +2,7 @@ mod fn_scope; | |||
2 | mod mod_scope; | 2 | mod mod_scope; |
3 | 3 | ||
4 | pub use self::{ | 4 | pub use self::{ |
5 | fn_scope::FnScopes, | 5 | fn_scope::{FnScopes, resolve_local_name}, |
6 | mod_scope::ModuleScope, | 6 | mod_scope::ModuleScope, |
7 | }; | 7 | }; |
8 | 8 | ||