From 1d4c767879913271bf01912f12c7f8f176c7755d Mon Sep 17 00:00:00 2001 From: "Jeremy A. Kolb" Date: Fri, 5 Oct 2018 15:21:40 -0400 Subject: WIP: This doesn't currently work but I also don't think it's the right abstraction --- crates/ra_editor/src/lib.rs | 8 ++++++++ crates/ra_editor/src/scope/mod.rs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'crates/ra_editor/src') 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>>( .next() } +pub fn resolve_local_name<'a>(file: &'a File, offset: TextUnit, name_ref: ast::NameRef) -> Option> { + let fn_def = find_node_at_offset::(file.syntax(), offset)?; + let scopes = scope::FnScopes::new(fn_def); + + // TODO: This doesn't work because of scopes lifetime + scope::resolve_local_name(name_ref, &scopes) +} + #[cfg(test)] mod tests { 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; mod mod_scope; pub use self::{ - fn_scope::FnScopes, + fn_scope::{FnScopes, resolve_local_name}, mod_scope::ModuleScope, }; -- cgit v1.2.3