aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/display/short_label.rs7
-rw-r--r--crates/ra_ide_api/src/folding_ranges.rs2
-rw-r--r--crates/ra_ide_api/src/join_lines.rs2
-rw-r--r--crates/ra_ide_api/src/typing.rs2
4 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_ide_api/src/display/short_label.rs b/crates/ra_ide_api/src/display/short_label.rs
index f926f631f..be499e485 100644
--- a/crates/ra_ide_api/src/display/short_label.rs
+++ b/crates/ra_ide_api/src/display/short_label.rs
@@ -1,3 +1,5 @@
1use std::fmt::Write;
2
1use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner}; 3use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner};
2 4
3pub(crate) trait ShortLabel { 5pub(crate) trait ShortLabel {
@@ -71,8 +73,7 @@ where
71 let mut buf = short_label_from_node(node, prefix)?; 73 let mut buf = short_label_from_node(node, prefix)?;
72 74
73 if let Some(type_ref) = node.ascribed_type() { 75 if let Some(type_ref) = node.ascribed_type() {
74 buf.push_str(": "); 76 write!(buf, ": {}", type_ref.syntax()).unwrap();
75 type_ref.syntax().text().push_to(&mut buf);
76 } 77 }
77 78
78 Some(buf) 79 Some(buf)
@@ -82,7 +83,7 @@ fn short_label_from_node<T>(node: &T, label: &str) -> Option<String>
82where 83where
83 T: NameOwner + VisibilityOwner, 84 T: NameOwner + VisibilityOwner,
84{ 85{
85 let mut buf = node.visibility().map(|v| format!("{} ", v.syntax().text())).unwrap_or_default(); 86 let mut buf = node.visibility().map(|v| format!("{} ", v.syntax())).unwrap_or_default();
86 buf.push_str(label); 87 buf.push_str(label);
87 buf.push_str(node.name()?.text().as_str()); 88 buf.push_str(node.name()?.text().as_str());
88 Some(buf) 89 Some(buf)
diff --git a/crates/ra_ide_api/src/folding_ranges.rs b/crates/ra_ide_api/src/folding_ranges.rs
index 9699000db..571d1c595 100644
--- a/crates/ra_ide_api/src/folding_ranges.rs
+++ b/crates/ra_ide_api/src/folding_ranges.rs
@@ -31,7 +31,7 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
31 // Fold items that span multiple lines 31 // Fold items that span multiple lines
32 if let Some(kind) = fold_kind(element.kind()) { 32 if let Some(kind) = fold_kind(element.kind()) {
33 let is_multiline = match &element { 33 let is_multiline = match &element {
34 SyntaxElement::Node(node) => node.text().contains('\n'), 34 SyntaxElement::Node(node) => node.text().contains_char('\n'),
35 SyntaxElement::Token(token) => token.text().contains('\n'), 35 SyntaxElement::Token(token) => token.text().contains('\n'),
36 }; 36 };
37 if is_multiline { 37 if is_multiline {
diff --git a/crates/ra_ide_api/src/join_lines.rs b/crates/ra_ide_api/src/join_lines.rs
index fa998ebe1..7f25f2108 100644
--- a/crates/ra_ide_api/src/join_lines.rs
+++ b/crates/ra_ide_api/src/join_lines.rs
@@ -13,7 +13,7 @@ pub fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit {
13 let range = if range.is_empty() { 13 let range = if range.is_empty() {
14 let syntax = file.syntax(); 14 let syntax = file.syntax();
15 let text = syntax.text().slice(range.start()..); 15 let text = syntax.text().slice(range.start()..);
16 let pos = match text.find('\n') { 16 let pos = match text.find_char('\n') {
17 None => return TextEditBuilder::default().finish(), 17 None => return TextEditBuilder::default().finish(),
18 Some(pos) => pos, 18 Some(pos) => pos,
19 }; 19 };
diff --git a/crates/ra_ide_api/src/typing.rs b/crates/ra_ide_api/src/typing.rs
index 1747a529e..5a1cbcc49 100644
--- a/crates/ra_ide_api/src/typing.rs
+++ b/crates/ra_ide_api/src/typing.rs
@@ -75,7 +75,7 @@ pub fn on_eq_typed(file: &SourceFile, eq_offset: TextUnit) -> Option<TextEdit> {
75 if expr_range.contains(eq_offset) && eq_offset != expr_range.start() { 75 if expr_range.contains(eq_offset) && eq_offset != expr_range.start() {
76 return None; 76 return None;
77 } 77 }
78 if file.syntax().text().slice(eq_offset..expr_range.start()).contains('\n') { 78 if file.syntax().text().slice(eq_offset..expr_range.start()).contains_char('\n') {
79 return None; 79 return None;
80 } 80 }
81 } else { 81 } else {