aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_editor/src/lib.rs')
-rw-r--r--crates/ra_editor/src/lib.rs15
1 files changed, 2 insertions, 13 deletions
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs
index b73eb4ac7..02a1b2d45 100644
--- a/crates/ra_editor/src/lib.rs
+++ b/crates/ra_editor/src/lib.rs
@@ -8,12 +8,10 @@ extern crate superslice;
8extern crate test_utils as _test_utils; 8extern crate test_utils as _test_utils;
9 9
10mod code_actions; 10mod code_actions;
11mod completion;
12mod edit; 11mod edit;
13mod extend_selection; 12mod extend_selection;
14mod folding_ranges; 13mod folding_ranges;
15mod line_index; 14mod line_index;
16mod scope;
17mod symbols; 15mod symbols;
18#[cfg(test)] 16#[cfg(test)]
19mod test_utils; 17mod test_utils;
@@ -21,7 +19,6 @@ mod typing;
21 19
22pub use self::{ 20pub use self::{
23 code_actions::{add_derive, add_impl, flip_comma, introduce_variable, LocalEdit}, 21 code_actions::{add_derive, add_impl, flip_comma, introduce_variable, LocalEdit},
24 completion::{scope_completion, complete_module_items, CompletionItem},
25 edit::{Edit, EditBuilder}, 22 edit::{Edit, EditBuilder},
26 extend_selection::extend_selection, 23 extend_selection::extend_selection,
27 folding_ranges::{folding_ranges, Fold, FoldKind}, 24 folding_ranges::{folding_ranges, Fold, FoldKind},
@@ -33,7 +30,7 @@ pub use ra_syntax::AtomEdit;
33use ra_syntax::{ 30use ra_syntax::{
34 algo::find_leaf_at_offset, 31 algo::find_leaf_at_offset,
35 ast::{self, AstNode, NameOwner}, 32 ast::{self, AstNode, NameOwner},
36 File, SmolStr, 33 File,
37 SyntaxKind::{self, *}, 34 SyntaxKind::{self, *},
38 SyntaxNodeRef, TextRange, TextUnit, 35 SyntaxNodeRef, TextRange, TextUnit,
39}; 36};
@@ -151,15 +148,7 @@ pub fn find_node_at_offset<'a, N: AstNode<'a>>(
151 leaf.ancestors().filter_map(N::cast).next() 148 leaf.ancestors().filter_map(N::cast).next()
152} 149}
153 150
154pub fn resolve_local_name( 151
155 name_ref: ast::NameRef,
156) -> Option<(SmolStr, TextRange)> {
157 let fn_def = name_ref.syntax().ancestors().find_map(ast::FnDef::cast)?;
158 let scopes = scope::FnScopes::new(fn_def);
159 let scope_entry = scope::resolve_local_name(name_ref, &scopes)?;
160 let name = scope_entry.ast().name()?;
161 Some((scope_entry.name(), name.syntax().range()))
162}
163 152
164#[cfg(test)] 153#[cfg(test)]
165mod tests { 154mod tests {