aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/assists.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_editor/src/assists.rs')
-rw-r--r--crates/ra_editor/src/assists.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_editor/src/assists.rs b/crates/ra_editor/src/assists.rs
index 57b78342a..a320caabf 100644
--- a/crates/ra_editor/src/assists.rs
+++ b/crates/ra_editor/src/assists.rs
@@ -12,7 +12,7 @@ mod split_import;
12 12
13use ra_text_edit::{TextEdit, TextEditBuilder}; 13use ra_text_edit::{TextEdit, TextEditBuilder};
14use ra_syntax::{ 14use ra_syntax::{
15 Direction, SyntaxNodeRef, TextUnit, TextRange,SourceFileNode, AstNode, 15 Direction, SyntaxNode, TextUnit, TextRange, SourceFile, AstNode,
16 algo::{find_leaf_at_offset, find_covering_node, LeafAtOffset}, 16 algo::{find_leaf_at_offset, find_covering_node, LeafAtOffset},
17}; 17};
18 18
@@ -28,7 +28,7 @@ pub use self::{
28}; 28};
29 29
30/// Return all the assists applicable at the given position. 30/// Return all the assists applicable at the given position.
31pub fn assists(file: &SourceFileNode, range: TextRange) -> Vec<LocalEdit> { 31pub fn assists(file: &SourceFile, range: TextRange) -> Vec<LocalEdit> {
32 let ctx = AssistCtx::new(file, range); 32 let ctx = AssistCtx::new(file, range);
33 [ 33 [
34 flip_comma, 34 flip_comma,
@@ -50,7 +50,7 @@ pub struct LocalEdit {
50 pub cursor_position: Option<TextUnit>, 50 pub cursor_position: Option<TextUnit>,
51} 51}
52 52
53fn non_trivia_sibling(node: SyntaxNodeRef, direction: Direction) -> Option<SyntaxNodeRef> { 53fn non_trivia_sibling(node: &SyntaxNode, direction: Direction) -> Option<&SyntaxNode> {
54 node.siblings(direction) 54 node.siblings(direction)
55 .skip(1) 55 .skip(1)
56 .find(|node| !node.kind().is_trivia()) 56 .find(|node| !node.kind().is_trivia())
@@ -88,7 +88,7 @@ fn non_trivia_sibling(node: SyntaxNodeRef, direction: Direction) -> Option<Synta
88/// easier to just compute the edit eagarly :-) 88/// easier to just compute the edit eagarly :-)
89#[derive(Debug, Clone)] 89#[derive(Debug, Clone)]
90pub struct AssistCtx<'a> { 90pub struct AssistCtx<'a> {
91 source_file: &'a SourceFileNode, 91 source_file: &'a SourceFile,
92 range: TextRange, 92 range: TextRange,
93 should_compute_edit: bool, 93 should_compute_edit: bool,
94} 94}
@@ -106,7 +106,7 @@ struct AssistBuilder {
106} 106}
107 107
108impl<'a> AssistCtx<'a> { 108impl<'a> AssistCtx<'a> {
109 pub fn new(source_file: &'a SourceFileNode, range: TextRange) -> AssistCtx { 109 pub fn new(source_file: &'a SourceFile, range: TextRange) -> AssistCtx {
110 AssistCtx { 110 AssistCtx {
111 source_file, 111 source_file,
112 range, 112 range,
@@ -145,13 +145,13 @@ impl<'a> AssistCtx<'a> {
145 })) 145 }))
146 } 146 }
147 147
148 pub(crate) fn leaf_at_offset(&self) -> LeafAtOffset<SyntaxNodeRef<'a>> { 148 pub(crate) fn leaf_at_offset(&self) -> LeafAtOffset<&'a SyntaxNode> {
149 find_leaf_at_offset(self.source_file.syntax(), self.range.start()) 149 find_leaf_at_offset(self.source_file.syntax(), self.range.start())
150 } 150 }
151 pub(crate) fn node_at_offset<N: AstNode<'a>>(&self) -> Option<N> { 151 pub(crate) fn node_at_offset<N: AstNode>(&self) -> Option<&'a N> {
152 find_node_at_offset(self.source_file.syntax(), self.range.start()) 152 find_node_at_offset(self.source_file.syntax(), self.range.start())
153 } 153 }
154 pub(crate) fn covering_node(&self) -> SyntaxNodeRef<'a> { 154 pub(crate) fn covering_node(&self) -> &'a SyntaxNode {
155 find_covering_node(self.source_file.syntax(), self.range) 155 find_covering_node(self.source_file.syntax(), self.range)
156 } 156 }
157} 157}