aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_editor/src')
-rw-r--r--crates/ra_editor/src/extend_selection.rs2
-rw-r--r--crates/ra_editor/src/folding_ranges.rs4
-rw-r--r--crates/ra_editor/src/line_index.rs4
-rw-r--r--crates/ra_editor/src/scope/mod_scope.rs18
-rw-r--r--crates/ra_editor/src/symbols.rs6
-rw-r--r--crates/ra_editor/src/typing.rs2
6 files changed, 18 insertions, 18 deletions
diff --git a/crates/ra_editor/src/extend_selection.rs b/crates/ra_editor/src/extend_selection.rs
index 9ee1df281..9d8df25c3 100644
--- a/crates/ra_editor/src/extend_selection.rs
+++ b/crates/ra_editor/src/extend_selection.rs
@@ -63,7 +63,7 @@ fn extend_ws(root: SyntaxNodeRef, ws: SyntaxNodeRef, offset: TextUnit) -> TextRa
63 let prefix = TextRange::from_to(ws.range().start(), offset) - ws.range().start(); 63 let prefix = TextRange::from_to(ws.range().start(), offset) - ws.range().start();
64 let ws_suffix = &ws_text.as_str()[suffix]; 64 let ws_suffix = &ws_text.as_str()[suffix];
65 let ws_prefix = &ws_text.as_str()[prefix]; 65 let ws_prefix = &ws_text.as_str()[prefix];
66 if ws_text.contains("\n") && !ws_suffix.contains("\n") { 66 if ws_text.contains('\n') && !ws_suffix.contains('\n') {
67 if let Some(node) = ws.next_sibling() { 67 if let Some(node) = ws.next_sibling() {
68 let start = match ws_prefix.rfind('\n') { 68 let start = match ws_prefix.rfind('\n') {
69 Some(idx) => ws.range().start() + TextUnit::from((idx + 1) as u32), 69 Some(idx) => ws.range().start() + TextUnit::from((idx + 1) as u32),
diff --git a/crates/ra_editor/src/folding_ranges.rs b/crates/ra_editor/src/folding_ranges.rs
index e5bc0c4ee..d0d4ed3d3 100644
--- a/crates/ra_editor/src/folding_ranges.rs
+++ b/crates/ra_editor/src/folding_ranges.rs
@@ -38,12 +38,12 @@ pub fn folding_ranges(file: &File) -> Vec<Fold> {
38 continue; 38 continue;
39 } 39 }
40 if node.kind() == COMMENT { 40 if node.kind() == COMMENT {
41 contiguous_range_for_comment(node, &mut visited_comments).map(|range| { 41 if let Some(range) = contiguous_range_for_comment(node, &mut visited_comments) {
42 res.push(Fold { 42 res.push(Fold {
43 range, 43 range,
44 kind: FoldKind::Comment, 44 kind: FoldKind::Comment,
45 }) 45 })
46 }); 46 }
47 } 47 }
48 } 48 }
49 49
diff --git a/crates/ra_editor/src/line_index.rs b/crates/ra_editor/src/line_index.rs
index da0f2a7f7..9abbb0d09 100644
--- a/crates/ra_editor/src/line_index.rs
+++ b/crates/ra_editor/src/line_index.rs
@@ -29,10 +29,10 @@ impl LineIndex {
29 let line = self.newlines.upper_bound(&offset) - 1; 29 let line = self.newlines.upper_bound(&offset) - 1;
30 let line_start_offset = self.newlines[line]; 30 let line_start_offset = self.newlines[line];
31 let col = offset - line_start_offset; 31 let col = offset - line_start_offset;
32 return LineCol { 32 LineCol {
33 line: line as u32, 33 line: line as u32,
34 col, 34 col,
35 }; 35 }
36 } 36 }
37 37
38 pub fn offset(&self, line_col: LineCol) -> TextUnit { 38 pub fn offset(&self, line_col: LineCol) -> TextUnit {
diff --git a/crates/ra_editor/src/scope/mod_scope.rs b/crates/ra_editor/src/scope/mod_scope.rs
index 8d7e408f8..956ee0e2f 100644
--- a/crates/ra_editor/src/scope/mod_scope.rs
+++ b/crates/ra_editor/src/scope/mod_scope.rs
@@ -22,14 +22,14 @@ impl ModuleScope {
22 let mut entries = Vec::new(); 22 let mut entries = Vec::new();
23 for item in items { 23 for item in items {
24 let entry = match item { 24 let entry = match item {
25 ast::ModuleItem::StructDef(item) => Entry::new(item), 25 ast::ModuleItem::StructDef(item) => Entry::new_item(item),
26 ast::ModuleItem::EnumDef(item) => Entry::new(item), 26 ast::ModuleItem::EnumDef(item) => Entry::new_item(item),
27 ast::ModuleItem::FnDef(item) => Entry::new(item), 27 ast::ModuleItem::FnDef(item) => Entry::new_item(item),
28 ast::ModuleItem::ConstDef(item) => Entry::new(item), 28 ast::ModuleItem::ConstDef(item) => Entry::new_item(item),
29 ast::ModuleItem::StaticDef(item) => Entry::new(item), 29 ast::ModuleItem::StaticDef(item) => Entry::new_item(item),
30 ast::ModuleItem::TraitDef(item) => Entry::new(item), 30 ast::ModuleItem::TraitDef(item) => Entry::new_item(item),
31 ast::ModuleItem::TypeDef(item) => Entry::new(item), 31 ast::ModuleItem::TypeDef(item) => Entry::new_item(item),
32 ast::ModuleItem::Module(item) => Entry::new(item), 32 ast::ModuleItem::Module(item) => Entry::new_item(item),
33 ast::ModuleItem::UseItem(item) => { 33 ast::ModuleItem::UseItem(item) => {
34 if let Some(tree) = item.use_tree() { 34 if let Some(tree) = item.use_tree() {
35 collect_imports(tree, &mut entries); 35 collect_imports(tree, &mut entries);
@@ -50,7 +50,7 @@ impl ModuleScope {
50} 50}
51 51
52impl Entry { 52impl Entry {
53 fn new<'a>(item: impl ast::NameOwner<'a>) -> Option<Entry> { 53 fn new_item<'a>(item: impl ast::NameOwner<'a>) -> Option<Entry> {
54 let name = item.name()?; 54 let name = item.name()?;
55 Some(Entry { 55 Some(Entry {
56 node: name.syntax().owned(), 56 node: name.syntax().owned(),
diff --git a/crates/ra_editor/src/symbols.rs b/crates/ra_editor/src/symbols.rs
index c3c66680d..0bab9dd67 100644
--- a/crates/ra_editor/src/symbols.rs
+++ b/crates/ra_editor/src/symbols.rs
@@ -54,15 +54,15 @@ pub fn file_structure(file: &File) -> Vec<StructureNode> {
54 let mut res = Vec::new(); 54 let mut res = Vec::new();
55 let mut stack = Vec::new(); 55 let mut stack = Vec::new();
56 56
57
57 for event in file.syntax().preorder() { 58 for event in file.syntax().preorder() {
58 match event { 59 match event {
59 WalkEvent::Enter(node) => match structure_node(node) { 60 WalkEvent::Enter(node) => {
60 Some(mut symbol) => { 61 if let Some(mut symbol) = structure_node(node) {
61 symbol.parent = stack.last().map(|&n| n); 62 symbol.parent = stack.last().map(|&n| n);
62 stack.push(res.len()); 63 stack.push(res.len());
63 res.push(symbol); 64 res.push(symbol);
64 } 65 }
65 None => (),
66 }, 66 },
67 WalkEvent::Leave(node) => { 67 WalkEvent::Leave(node) => {
68 if structure_node(node).is_some() { 68 if structure_node(node).is_some() {
diff --git a/crates/ra_editor/src/typing.rs b/crates/ra_editor/src/typing.rs
index 50b52e7a1..5a457d148 100644
--- a/crates/ra_editor/src/typing.rs
+++ b/crates/ra_editor/src/typing.rs
@@ -58,7 +58,7 @@ pub fn join_lines(file: &File, range: TextRange) -> LocalEdit {
58pub fn on_enter(file: &File, offset: TextUnit) -> Option<LocalEdit> { 58pub fn on_enter(file: &File, offset: TextUnit) -> Option<LocalEdit> {
59 let comment = find_leaf_at_offset(file.syntax(), offset) 59 let comment = find_leaf_at_offset(file.syntax(), offset)
60 .left_biased() 60 .left_biased()
61 .and_then(|it| ast::Comment::cast(it))?; 61 .and_then(ast::Comment::cast)?;
62 62
63 if let ast::CommentFlavor::Multiline = comment.flavor() { 63 if let ast::CommentFlavor::Multiline = comment.flavor() {
64 return None; 64 return None;