aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/Cargo.toml12
-rw-r--r--crates/ra_syntax/src/algo.rs9
-rw-r--r--crates/ra_syntax/src/ast/expr_extensions.rs12
-rw-r--r--crates/ra_syntax/src/ast/make.rs2
-rw-r--r--crates/ra_syntax/src/parsing/text_token_source.rs2
5 files changed, 19 insertions, 18 deletions
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml
index cb72972c5..7891628dc 100644
--- a/crates/ra_syntax/Cargo.toml
+++ b/crates/ra_syntax/Cargo.toml
@@ -11,12 +11,12 @@ repository = "https://github.com/rust-analyzer/rust-analyzer"
11doctest = false 11doctest = false
12 12
13[dependencies] 13[dependencies]
14itertools = "0.8.0" 14itertools = "0.8.2"
15rowan = "0.9.0" 15rowan = "0.9.0"
16rustc_lexer = "0.1.0" 16rustc_lexer = "0.1.0"
17rustc-hash = "1.0.1" 17rustc-hash = "1.1.0"
18arrayvec = "0.5.1" 18arrayvec = "0.5.1"
19once_cell = "1.2.0" 19once_cell = "1.3.1"
20 20
21ra_text_edit = { path = "../ra_text_edit" } 21ra_text_edit = { path = "../ra_text_edit" }
22ra_parser = { path = "../ra_parser" } 22ra_parser = { path = "../ra_parser" }
@@ -24,9 +24,9 @@ ra_parser = { path = "../ra_parser" }
24# This crate transitively depends on `smol_str` via `rowan`. 24# This crate transitively depends on `smol_str` via `rowan`.
25# ideally, `serde` should be enabled by `rust-analyzer`, but we enable it here 25# ideally, `serde` should be enabled by `rust-analyzer`, but we enable it here
26# to reduce number of compilations 26# to reduce number of compilations
27smol_str = { version = "0.1.12", features = ["serde"] } 27smol_str = { version = "0.1.15", features = ["serde"] }
28serde = { version = "1", features = ["derive"] } 28serde = { version = "1.0.104", features = ["derive"] }
29 29
30[dev-dependencies] 30[dev-dependencies]
31test_utils = { path = "../test_utils" } 31test_utils = { path = "../test_utils" }
32walkdir = "2.2.0" 32walkdir = "2.3.1"
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs
index acf677e7d..21fca99a6 100644
--- a/crates/ra_syntax/src/algo.rs
+++ b/crates/ra_syntax/src/algo.rs
@@ -95,16 +95,17 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff {
95 lhs: SyntaxElement, 95 lhs: SyntaxElement,
96 rhs: SyntaxElement, 96 rhs: SyntaxElement,
97 ) { 97 ) {
98 if lhs.kind() == rhs.kind() && lhs.text_range().len() == rhs.text_range().len() { 98 if lhs.kind() == rhs.kind()
99 if match (&lhs, &rhs) { 99 && lhs.text_range().len() == rhs.text_range().len()
100 && match (&lhs, &rhs) {
100 (NodeOrToken::Node(lhs), NodeOrToken::Node(rhs)) => { 101 (NodeOrToken::Node(lhs), NodeOrToken::Node(rhs)) => {
101 lhs.green() == rhs.green() || lhs.text() == rhs.text() 102 lhs.green() == rhs.green() || lhs.text() == rhs.text()
102 } 103 }
103 (NodeOrToken::Token(lhs), NodeOrToken::Token(rhs)) => lhs.text() == rhs.text(), 104 (NodeOrToken::Token(lhs), NodeOrToken::Token(rhs)) => lhs.text() == rhs.text(),
104 _ => false, 105 _ => false,
105 } {
106 return;
107 } 106 }
107 {
108 return;
108 } 109 }
109 if let (Some(lhs), Some(rhs)) = (lhs.as_node(), rhs.as_node()) { 110 if let (Some(lhs), Some(rhs)) = (lhs.as_node(), rhs.as_node()) {
110 if lhs.children_with_tokens().count() == rhs.children_with_tokens().count() { 111 if lhs.children_with_tokens().count() == rhs.children_with_tokens().count() {
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs
index 2e50a095c..77cceb382 100644
--- a/crates/ra_syntax/src/ast/expr_extensions.rs
+++ b/crates/ra_syntax/src/ast/expr_extensions.rs
@@ -30,7 +30,7 @@ pub enum ElseBranch {
30 30
31impl ast::IfExpr { 31impl ast::IfExpr {
32 pub fn then_branch(&self) -> Option<ast::BlockExpr> { 32 pub fn then_branch(&self) -> Option<ast::BlockExpr> {
33 self.blocks().nth(0) 33 self.blocks().next()
34 } 34 }
35 pub fn else_branch(&self) -> Option<ElseBranch> { 35 pub fn else_branch(&self) -> Option<ElseBranch> {
36 let res = match self.blocks().nth(1) { 36 let res = match self.blocks().nth(1) {
@@ -208,7 +208,7 @@ impl ast::BinExpr {
208 } 208 }
209 209
210 pub fn lhs(&self) -> Option<ast::Expr> { 210 pub fn lhs(&self) -> Option<ast::Expr> {
211 children(self).nth(0) 211 children(self).next()
212 } 212 }
213 213
214 pub fn rhs(&self) -> Option<ast::Expr> { 214 pub fn rhs(&self) -> Option<ast::Expr> {
@@ -271,7 +271,7 @@ impl ast::RangeExpr {
271 271
272impl ast::IndexExpr { 272impl ast::IndexExpr {
273 pub fn base(&self) -> Option<ast::Expr> { 273 pub fn base(&self) -> Option<ast::Expr> {
274 children(self).nth(0) 274 children(self).next()
275 } 275 }
276 pub fn index(&self) -> Option<ast::Expr> { 276 pub fn index(&self) -> Option<ast::Expr> {
277 children(self).nth(1) 277 children(self).nth(1)
@@ -287,7 +287,7 @@ impl ast::ArrayExpr {
287 pub fn kind(&self) -> ArrayExprKind { 287 pub fn kind(&self) -> ArrayExprKind {
288 if self.is_repeat() { 288 if self.is_repeat() {
289 ArrayExprKind::Repeat { 289 ArrayExprKind::Repeat {
290 initializer: children(self).nth(0), 290 initializer: children(self).next(),
291 repeat: children(self).nth(1), 291 repeat: children(self).nth(1),
292 } 292 }
293 } else { 293 } else {
@@ -328,10 +328,10 @@ impl ast::Literal {
328 } 328 }
329 329
330 pub fn kind(&self) -> LiteralKind { 330 pub fn kind(&self) -> LiteralKind {
331 const INT_SUFFIXES: [&'static str; 12] = [ 331 const INT_SUFFIXES: [&str; 12] = [
332 "u64", "u32", "u16", "u8", "usize", "isize", "i64", "i32", "i16", "i8", "u128", "i128", 332 "u64", "u32", "u16", "u8", "usize", "isize", "i64", "i32", "i16", "i8", "u128", "i128",
333 ]; 333 ];
334 const FLOAT_SUFFIXES: [&'static str; 2] = ["f32", "f64"]; 334 const FLOAT_SUFFIXES: [&str; 2] = ["f32", "f64"];
335 335
336 let token = self.token(); 336 let token = self.token();
337 337
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 89d1403e7..7c20fcc10 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -152,7 +152,7 @@ pub fn match_arm_list(arms: impl IntoIterator<Item = ast::MatchArm>) -> ast::Mat
152 format!(" {}{}\n", arm.syntax(), comma) 152 format!(" {}{}\n", arm.syntax(), comma)
153 }) 153 })
154 .collect::<String>(); 154 .collect::<String>();
155 return from_text(&format!("{}", arms_str)); 155 return from_text(&arms_str);
156 156
157 fn from_text(text: &str) -> ast::MatchArmList { 157 fn from_text(text: &str) -> ast::MatchArmList {
158 ast_from_text(&format!("fn f() {{ match () {{\n{}}} }}", text)) 158 ast_from_text(&format!("fn f() {{ match () {{\n{}}} }}", text))
diff --git a/crates/ra_syntax/src/parsing/text_token_source.rs b/crates/ra_syntax/src/parsing/text_token_source.rs
index e793f93a4..e2433913c 100644
--- a/crates/ra_syntax/src/parsing/text_token_source.rs
+++ b/crates/ra_syntax/src/parsing/text_token_source.rs
@@ -48,7 +48,7 @@ impl<'t> TokenSource for TextTokenSource<'t> {
48 48
49 fn is_keyword(&self, kw: &str) -> bool { 49 fn is_keyword(&self, kw: &str) -> bool {
50 let pos = self.curr.1; 50 let pos = self.curr.1;
51 if !(pos < self.tokens.len()) { 51 if pos >= self.tokens.len() {
52 return false; 52 return false;
53 } 53 }
54 let range = TextRange::offset_len(self.start_offsets[pos], self.tokens[pos].len); 54 let range = TextRange::offset_len(self.start_offsets[pos], self.tokens[pos].len);