aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor/src/symbols.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libeditor/src/symbols.rs')
-rw-r--r--crates/libeditor/src/symbols.rs26
1 files changed, 11 insertions, 15 deletions
diff --git a/crates/libeditor/src/symbols.rs b/crates/libeditor/src/symbols.rs
index 43f4164da..8419f08e6 100644
--- a/crates/libeditor/src/symbols.rs
+++ b/crates/libeditor/src/symbols.rs
@@ -6,7 +6,6 @@ use libsyntax2::{
6 visit::{visitor, Visitor}, 6 visit::{visitor, Visitor},
7 walk::{walk, WalkEvent, preorder}, 7 walk::{walk, WalkEvent, preorder},
8 }, 8 },
9 SyntaxKind::*,
10}; 9};
11use TextRange; 10use TextRange;
12 11
@@ -104,24 +103,21 @@ fn structure_node(node: SyntaxNodeRef) -> Option<StructureNode> {
104 .visit(decl::<ast::ConstDef<_>>) 103 .visit(decl::<ast::ConstDef<_>>)
105 .visit(decl::<ast::StaticDef<_>>) 104 .visit(decl::<ast::StaticDef<_>>)
106 .visit(|im: ast::ImplItem<_>| { 105 .visit(|im: ast::ImplItem<_>| {
107 let mut label = String::new(); 106 let target_type = im.target_type()?;
108 let brace = im.syntax().children() 107 let target_trait = im.target_trait();
109 .find(|it| { 108 let label = match target_trait {
110 let stop = it.kind() == L_CURLY; 109 None => format!("impl {}", target_type.syntax().text()),
111 if !stop { 110 Some(t) => format!(
112 label.push_str(&it.text()); 111 "impl {} for {}",
113 } 112 t.syntax().text(),
114 stop 113 target_type.syntax().text(),
115 })?; 114 ),
116 let navigation_range = TextRange::from_to( 115 };
117 im.syntax().range().start(),
118 brace.range().start(),
119 );
120 116
121 let node = StructureNode { 117 let node = StructureNode {
122 parent: None, 118 parent: None,
123 label, 119 label,
124 navigation_range, 120 navigation_range: target_type.syntax().range(),
125 node_range: im.syntax().range(), 121 node_range: im.syntax().range(),
126 kind: im.syntax().kind(), 122 kind: im.syntax().kind(),
127 }; 123 };