diff options
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_context.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/display/short_label.rs | 5 | ||||
-rw-r--r-- | crates/ra_ide_api/src/extend_selection.rs | 16 | ||||
-rw-r--r-- | crates/ra_ide_api/src/folding_ranges.rs | 18 | ||||
-rw-r--r-- | crates/ra_ide_api/src/goto_type_definition.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/join_lines.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/matching_brace.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/syntax_tree.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/typing.rs | 15 |
10 files changed, 44 insertions, 37 deletions
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml index c49a05de1..78a3db14d 100644 --- a/crates/ra_ide_api/Cargo.toml +++ b/crates/ra_ide_api/Cargo.toml | |||
@@ -5,6 +5,7 @@ version = "0.1.0" | |||
5 | authors = ["rust-analyzer developers"] | 5 | authors = ["rust-analyzer developers"] |
6 | 6 | ||
7 | [dependencies] | 7 | [dependencies] |
8 | format-buf = "1.0.0" | ||
8 | itertools = "0.8.0" | 9 | itertools = "0.8.0" |
9 | join_to_string = "0.1.3" | 10 | join_to_string = "0.1.3" |
10 | log = "0.4.5" | 11 | log = "0.4.5" |
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index 6fee7b5be..dfaa9ce69 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use hir::source_binder; | 1 | use hir::source_binder; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | algo::{find_covering_element, find_node_at_offset, find_token_at_offset}, | 3 | algo::{find_covering_element, find_node_at_offset}, |
4 | ast, AstNode, Parse, SourceFile, | 4 | ast, AstNode, Parse, SourceFile, |
5 | SyntaxKind::*, | 5 | SyntaxKind::*, |
6 | SyntaxNode, SyntaxToken, TextRange, TextUnit, | 6 | SyntaxNode, SyntaxToken, TextRange, TextUnit, |
@@ -49,7 +49,7 @@ impl<'a> CompletionContext<'a> { | |||
49 | ) -> Option<CompletionContext<'a>> { | 49 | ) -> Option<CompletionContext<'a>> { |
50 | let module = source_binder::module_from_position(db, position); | 50 | let module = source_binder::module_from_position(db, position); |
51 | let token = | 51 | let token = |
52 | find_token_at_offset(original_parse.tree().syntax(), position.offset).left_biased()?; | 52 | original_parse.tree().syntax().token_at_offset(position.offset).left_biased()?; |
53 | let analyzer = | 53 | let analyzer = |
54 | hir::SourceAnalyzer::new(db, position.file_id, &token.parent(), Some(position.offset)); | 54 | hir::SourceAnalyzer::new(db, position.file_id, &token.parent(), Some(position.offset)); |
55 | let mut ctx = CompletionContext { | 55 | let mut ctx = CompletionContext { |
diff --git a/crates/ra_ide_api/src/display/short_label.rs b/crates/ra_ide_api/src/display/short_label.rs index be499e485..825a033ee 100644 --- a/crates/ra_ide_api/src/display/short_label.rs +++ b/crates/ra_ide_api/src/display/short_label.rs | |||
@@ -1,5 +1,4 @@ | |||
1 | use std::fmt::Write; | 1 | use format_buf::format; |
2 | |||
3 | use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner}; | 2 | use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner}; |
4 | 3 | ||
5 | pub(crate) trait ShortLabel { | 4 | pub(crate) trait ShortLabel { |
@@ -73,7 +72,7 @@ where | |||
73 | let mut buf = short_label_from_node(node, prefix)?; | 72 | let mut buf = short_label_from_node(node, prefix)?; |
74 | 73 | ||
75 | if let Some(type_ref) = node.ascribed_type() { | 74 | if let Some(type_ref) = node.ascribed_type() { |
76 | write!(buf, ": {}", type_ref.syntax()).unwrap(); | 75 | format!(buf, ": {}", type_ref.syntax()); |
77 | } | 76 | } |
78 | 77 | ||
79 | Some(buf) | 78 | Some(buf) |
diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs index 140820df6..edbf622c1 100644 --- a/crates/ra_ide_api/src/extend_selection.rs +++ b/crates/ra_ide_api/src/extend_selection.rs | |||
@@ -1,10 +1,10 @@ | |||
1 | use ra_db::SourceDatabase; | 1 | use ra_db::SourceDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | algo::{find_covering_element, find_token_at_offset, TokenAtOffset}, | 3 | algo::find_covering_element, |
4 | ast::{self, AstNode, AstToken}, | 4 | ast::{self, AstNode, AstToken}, |
5 | Direction, SyntaxElement, | 5 | Direction, NodeOrToken, |
6 | SyntaxKind::*, | 6 | SyntaxKind::*, |
7 | SyntaxNode, SyntaxToken, TextRange, TextUnit, T, | 7 | SyntaxNode, SyntaxToken, TextRange, TextUnit, TokenAtOffset, T, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | use crate::{db::RootDatabase, FileRange}; | 10 | use crate::{db::RootDatabase, FileRange}; |
@@ -34,7 +34,7 @@ fn try_extend_selection(root: &SyntaxNode, range: TextRange) -> Option<TextRange | |||
34 | 34 | ||
35 | if range.is_empty() { | 35 | if range.is_empty() { |
36 | let offset = range.start(); | 36 | let offset = range.start(); |
37 | let mut leaves = find_token_at_offset(root, offset); | 37 | let mut leaves = root.token_at_offset(offset); |
38 | if leaves.clone().all(|it| it.kind() == WHITESPACE) { | 38 | if leaves.clone().all(|it| it.kind() == WHITESPACE) { |
39 | return Some(extend_ws(root, leaves.next()?, offset)); | 39 | return Some(extend_ws(root, leaves.next()?, offset)); |
40 | } | 40 | } |
@@ -53,7 +53,7 @@ fn try_extend_selection(root: &SyntaxNode, range: TextRange) -> Option<TextRange | |||
53 | return Some(leaf_range); | 53 | return Some(leaf_range); |
54 | }; | 54 | }; |
55 | let node = match find_covering_element(root, range) { | 55 | let node = match find_covering_element(root, range) { |
56 | SyntaxElement::Token(token) => { | 56 | NodeOrToken::Token(token) => { |
57 | if token.text_range() != range { | 57 | if token.text_range() != range { |
58 | return Some(token.text_range()); | 58 | return Some(token.text_range()); |
59 | } | 59 | } |
@@ -64,7 +64,7 @@ fn try_extend_selection(root: &SyntaxNode, range: TextRange) -> Option<TextRange | |||
64 | } | 64 | } |
65 | token.parent() | 65 | token.parent() |
66 | } | 66 | } |
67 | SyntaxElement::Node(node) => node, | 67 | NodeOrToken::Node(node) => node, |
68 | }; | 68 | }; |
69 | if node.text_range() != range { | 69 | if node.text_range() != range { |
70 | return Some(node.text_range()); | 70 | return Some(node.text_range()); |
@@ -153,8 +153,8 @@ fn extend_list_item(node: &SyntaxNode) -> Option<TextRange> { | |||
153 | node.siblings_with_tokens(dir) | 153 | node.siblings_with_tokens(dir) |
154 | .skip(1) | 154 | .skip(1) |
155 | .skip_while(|node| match node { | 155 | .skip_while(|node| match node { |
156 | SyntaxElement::Node(_) => false, | 156 | NodeOrToken::Node(_) => false, |
157 | SyntaxElement::Token(it) => is_single_line_ws(it), | 157 | NodeOrToken::Token(it) => is_single_line_ws(it), |
158 | }) | 158 | }) |
159 | .next() | 159 | .next() |
160 | .and_then(|it| it.into_token()) | 160 | .and_then(|it| it.into_token()) |
diff --git a/crates/ra_ide_api/src/folding_ranges.rs b/crates/ra_ide_api/src/folding_ranges.rs index 571d1c595..e60ae8cf6 100644 --- a/crates/ra_ide_api/src/folding_ranges.rs +++ b/crates/ra_ide_api/src/folding_ranges.rs | |||
@@ -2,7 +2,7 @@ use rustc_hash::FxHashSet; | |||
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | ast::{self, AstNode, AstToken, VisibilityOwner}, | 4 | ast::{self, AstNode, AstToken, VisibilityOwner}, |
5 | Direction, SourceFile, SyntaxElement, | 5 | Direction, NodeOrToken, SourceFile, |
6 | SyntaxKind::{self, *}, | 6 | SyntaxKind::{self, *}, |
7 | SyntaxNode, TextRange, | 7 | SyntaxNode, TextRange, |
8 | }; | 8 | }; |
@@ -31,8 +31,8 @@ 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_char('\n'), | 34 | NodeOrToken::Node(node) => node.text().contains_char('\n'), |
35 | SyntaxElement::Token(token) => token.text().contains('\n'), | 35 | NodeOrToken::Token(token) => token.text().contains('\n'), |
36 | }; | 36 | }; |
37 | if is_multiline { | 37 | if is_multiline { |
38 | res.push(Fold { range: element.text_range(), kind }); | 38 | res.push(Fold { range: element.text_range(), kind }); |
@@ -41,7 +41,7 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> { | |||
41 | } | 41 | } |
42 | 42 | ||
43 | match element { | 43 | match element { |
44 | SyntaxElement::Token(token) => { | 44 | NodeOrToken::Token(token) => { |
45 | // Fold groups of comments | 45 | // Fold groups of comments |
46 | if let Some(comment) = ast::Comment::cast(token) { | 46 | if let Some(comment) = ast::Comment::cast(token) { |
47 | if !visited_comments.contains(&comment) { | 47 | if !visited_comments.contains(&comment) { |
@@ -53,7 +53,7 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> { | |||
53 | } | 53 | } |
54 | } | 54 | } |
55 | } | 55 | } |
56 | SyntaxElement::Node(node) => { | 56 | NodeOrToken::Node(node) => { |
57 | // Fold groups of imports | 57 | // Fold groups of imports |
58 | if node.kind() == USE_ITEM && !visited_imports.contains(&node) { | 58 | if node.kind() == USE_ITEM && !visited_imports.contains(&node) { |
59 | if let Some(range) = contiguous_range_for_group(&node, &mut visited_imports) { | 59 | if let Some(range) = contiguous_range_for_group(&node, &mut visited_imports) { |
@@ -108,7 +108,7 @@ fn contiguous_range_for_group_unless( | |||
108 | let mut last = first.clone(); | 108 | let mut last = first.clone(); |
109 | for element in first.siblings_with_tokens(Direction::Next) { | 109 | for element in first.siblings_with_tokens(Direction::Next) { |
110 | let node = match element { | 110 | let node = match element { |
111 | SyntaxElement::Token(token) => { | 111 | NodeOrToken::Token(token) => { |
112 | if let Some(ws) = ast::Whitespace::cast(token) { | 112 | if let Some(ws) = ast::Whitespace::cast(token) { |
113 | if !ws.spans_multiple_lines() { | 113 | if !ws.spans_multiple_lines() { |
114 | // Ignore whitespace without blank lines | 114 | // Ignore whitespace without blank lines |
@@ -119,7 +119,7 @@ fn contiguous_range_for_group_unless( | |||
119 | // group ends here | 119 | // group ends here |
120 | break; | 120 | break; |
121 | } | 121 | } |
122 | SyntaxElement::Node(node) => node, | 122 | NodeOrToken::Node(node) => node, |
123 | }; | 123 | }; |
124 | 124 | ||
125 | // Stop if we find a node that doesn't belong to the group | 125 | // Stop if we find a node that doesn't belong to the group |
@@ -154,7 +154,7 @@ fn contiguous_range_for_comment( | |||
154 | let mut last = first.clone(); | 154 | let mut last = first.clone(); |
155 | for element in first.syntax().siblings_with_tokens(Direction::Next) { | 155 | for element in first.syntax().siblings_with_tokens(Direction::Next) { |
156 | match element { | 156 | match element { |
157 | SyntaxElement::Token(token) => { | 157 | NodeOrToken::Token(token) => { |
158 | if let Some(ws) = ast::Whitespace::cast(token.clone()) { | 158 | if let Some(ws) = ast::Whitespace::cast(token.clone()) { |
159 | if !ws.spans_multiple_lines() { | 159 | if !ws.spans_multiple_lines() { |
160 | // Ignore whitespace without blank lines | 160 | // Ignore whitespace without blank lines |
@@ -173,7 +173,7 @@ fn contiguous_range_for_comment( | |||
173 | // * A comment of a different flavor was reached | 173 | // * A comment of a different flavor was reached |
174 | break; | 174 | break; |
175 | } | 175 | } |
176 | SyntaxElement::Node(_) => break, | 176 | NodeOrToken::Node(_) => break, |
177 | }; | 177 | }; |
178 | } | 178 | } |
179 | 179 | ||
diff --git a/crates/ra_ide_api/src/goto_type_definition.rs b/crates/ra_ide_api/src/goto_type_definition.rs index 007259d9e..72884e5ca 100644 --- a/crates/ra_ide_api/src/goto_type_definition.rs +++ b/crates/ra_ide_api/src/goto_type_definition.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use ra_db::SourceDatabase; | 1 | use ra_db::SourceDatabase; |
2 | use ra_syntax::{algo::find_token_at_offset, ast, AstNode}; | 2 | use ra_syntax::{ast, AstNode}; |
3 | 3 | ||
4 | use crate::{db::RootDatabase, FilePosition, NavigationTarget, RangeInfo}; | 4 | use crate::{db::RootDatabase, FilePosition, NavigationTarget, RangeInfo}; |
5 | 5 | ||
@@ -9,7 +9,7 @@ pub(crate) fn goto_type_definition( | |||
9 | ) -> Option<RangeInfo<Vec<NavigationTarget>>> { | 9 | ) -> Option<RangeInfo<Vec<NavigationTarget>>> { |
10 | let parse = db.parse(position.file_id); | 10 | let parse = db.parse(position.file_id); |
11 | 11 | ||
12 | let node = find_token_at_offset(parse.tree().syntax(), position.offset).find_map(|token| { | 12 | let node = parse.tree().syntax().token_at_offset(position.offset).find_map(|token| { |
13 | token | 13 | token |
14 | .parent() | 14 | .parent() |
15 | .ancestors() | 15 | .ancestors() |
diff --git a/crates/ra_ide_api/src/join_lines.rs b/crates/ra_ide_api/src/join_lines.rs index 7f25f2108..a2e4b6f3c 100644 --- a/crates/ra_ide_api/src/join_lines.rs +++ b/crates/ra_ide_api/src/join_lines.rs | |||
@@ -3,7 +3,7 @@ use ra_fmt::{compute_ws, extract_trivial_expression}; | |||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo::{find_covering_element, non_trivia_sibling}, | 4 | algo::{find_covering_element, non_trivia_sibling}, |
5 | ast::{self, AstNode, AstToken}, | 5 | ast::{self, AstNode, AstToken}, |
6 | Direction, SourceFile, SyntaxElement, | 6 | Direction, NodeOrToken, SourceFile, |
7 | SyntaxKind::{self, WHITESPACE}, | 7 | SyntaxKind::{self, WHITESPACE}, |
8 | SyntaxNode, SyntaxToken, TextRange, TextUnit, T, | 8 | SyntaxNode, SyntaxToken, TextRange, TextUnit, T, |
9 | }; | 9 | }; |
@@ -23,8 +23,8 @@ pub fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit { | |||
23 | }; | 23 | }; |
24 | 24 | ||
25 | let node = match find_covering_element(file.syntax(), range) { | 25 | let node = match find_covering_element(file.syntax(), range) { |
26 | SyntaxElement::Node(node) => node, | 26 | NodeOrToken::Node(node) => node, |
27 | SyntaxElement::Token(token) => token.parent(), | 27 | NodeOrToken::Token(token) => token.parent(), |
28 | }; | 28 | }; |
29 | let mut edit = TextEditBuilder::default(); | 29 | let mut edit = TextEditBuilder::default(); |
30 | for token in node.descendants_with_tokens().filter_map(|it| it.into_token()) { | 30 | for token in node.descendants_with_tokens().filter_map(|it| it.into_token()) { |
diff --git a/crates/ra_ide_api/src/matching_brace.rs b/crates/ra_ide_api/src/matching_brace.rs index 1e2fac848..e802d01e4 100644 --- a/crates/ra_ide_api/src/matching_brace.rs +++ b/crates/ra_ide_api/src/matching_brace.rs | |||
@@ -1,9 +1,11 @@ | |||
1 | use ra_syntax::{algo::find_token_at_offset, ast::AstNode, SourceFile, SyntaxKind, TextUnit, T}; | 1 | use ra_syntax::{ast::AstNode, SourceFile, SyntaxKind, TextUnit, T}; |
2 | 2 | ||
3 | pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> { | 3 | pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> { |
4 | const BRACES: &[SyntaxKind] = | 4 | const BRACES: &[SyntaxKind] = |
5 | &[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>]]; | 5 | &[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>]]; |
6 | let (brace_node, brace_idx) = find_token_at_offset(file.syntax(), offset) | 6 | let (brace_node, brace_idx) = file |
7 | .syntax() | ||
8 | .token_at_offset(offset) | ||
7 | .filter_map(|node| { | 9 | .filter_map(|node| { |
8 | let idx = BRACES.iter().position(|&brace| brace == node.kind())?; | 10 | let idx = BRACES.iter().position(|&brace| brace == node.kind())?; |
9 | Some((node, idx)) | 11 | Some((node, idx)) |
diff --git a/crates/ra_ide_api/src/syntax_tree.rs b/crates/ra_ide_api/src/syntax_tree.rs index 76c50f6d6..a07e670fa 100644 --- a/crates/ra_ide_api/src/syntax_tree.rs +++ b/crates/ra_ide_api/src/syntax_tree.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use crate::db::RootDatabase; | 1 | use crate::db::RootDatabase; |
2 | use ra_db::SourceDatabase; | 2 | use ra_db::SourceDatabase; |
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo, AstNode, SourceFile, SyntaxElement, | 4 | algo, AstNode, NodeOrToken, SourceFile, |
5 | SyntaxKind::{RAW_STRING, STRING}, | 5 | SyntaxKind::{RAW_STRING, STRING}, |
6 | SyntaxToken, TextRange, | 6 | SyntaxToken, TextRange, |
7 | }; | 7 | }; |
@@ -16,8 +16,8 @@ pub(crate) fn syntax_tree( | |||
16 | let parse = db.parse(file_id); | 16 | let parse = db.parse(file_id); |
17 | if let Some(text_range) = text_range { | 17 | if let Some(text_range) = text_range { |
18 | let node = match algo::find_covering_element(parse.tree().syntax(), text_range) { | 18 | let node = match algo::find_covering_element(parse.tree().syntax(), text_range) { |
19 | SyntaxElement::Node(node) => node, | 19 | NodeOrToken::Node(node) => node, |
20 | SyntaxElement::Token(token) => { | 20 | NodeOrToken::Token(token) => { |
21 | if let Some(tree) = syntax_tree_for_string(&token, text_range) { | 21 | if let Some(tree) = syntax_tree_for_string(&token, text_range) { |
22 | return tree; | 22 | return tree; |
23 | } | 23 | } |
diff --git a/crates/ra_ide_api/src/typing.rs b/crates/ra_ide_api/src/typing.rs index 5a1cbcc49..6b3fd5904 100644 --- a/crates/ra_ide_api/src/typing.rs +++ b/crates/ra_ide_api/src/typing.rs | |||
@@ -1,11 +1,11 @@ | |||
1 | use ra_db::{FilePosition, SourceDatabase}; | 1 | use ra_db::{FilePosition, SourceDatabase}; |
2 | use ra_fmt::leading_indent; | 2 | use ra_fmt::leading_indent; |
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo::{find_node_at_offset, find_token_at_offset, TokenAtOffset}, | 4 | algo::find_node_at_offset, |
5 | ast::{self, AstToken}, | 5 | ast::{self, AstToken}, |
6 | AstNode, SmolStr, SourceFile, | 6 | AstNode, SmolStr, SourceFile, |
7 | SyntaxKind::*, | 7 | SyntaxKind::*, |
8 | SyntaxToken, TextRange, TextUnit, | 8 | SyntaxToken, TextRange, TextUnit, TokenAtOffset, |
9 | }; | 9 | }; |
10 | use ra_text_edit::{TextEdit, TextEditBuilder}; | 10 | use ra_text_edit::{TextEdit, TextEditBuilder}; |
11 | 11 | ||
@@ -14,7 +14,9 @@ use crate::{db::RootDatabase, SourceChange, SourceFileEdit}; | |||
14 | pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<SourceChange> { | 14 | pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<SourceChange> { |
15 | let parse = db.parse(position.file_id); | 15 | let parse = db.parse(position.file_id); |
16 | let file = parse.tree(); | 16 | let file = parse.tree(); |
17 | let comment = find_token_at_offset(file.syntax(), position.offset) | 17 | let comment = file |
18 | .syntax() | ||
19 | .token_at_offset(position.offset) | ||
18 | .left_biased() | 20 | .left_biased() |
19 | .and_then(ast::Comment::cast)?; | 21 | .and_then(ast::Comment::cast)?; |
20 | 22 | ||
@@ -45,7 +47,7 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<Sour | |||
45 | } | 47 | } |
46 | 48 | ||
47 | fn node_indent(file: &SourceFile, token: &SyntaxToken) -> Option<SmolStr> { | 49 | fn node_indent(file: &SourceFile, token: &SyntaxToken) -> Option<SmolStr> { |
48 | let ws = match find_token_at_offset(file.syntax(), token.text_range().start()) { | 50 | let ws = match file.syntax().token_at_offset(token.text_range().start()) { |
49 | TokenAtOffset::Between(l, r) => { | 51 | TokenAtOffset::Between(l, r) => { |
50 | assert!(r == *token); | 52 | assert!(r == *token); |
51 | l | 53 | l |
@@ -91,7 +93,10 @@ pub(crate) fn on_dot_typed(db: &RootDatabase, position: FilePosition) -> Option< | |||
91 | let parse = db.parse(position.file_id); | 93 | let parse = db.parse(position.file_id); |
92 | assert_eq!(parse.tree().syntax().text().char_at(position.offset), Some('.')); | 94 | assert_eq!(parse.tree().syntax().text().char_at(position.offset), Some('.')); |
93 | 95 | ||
94 | let whitespace = find_token_at_offset(parse.tree().syntax(), position.offset) | 96 | let whitespace = parse |
97 | .tree() | ||
98 | .syntax() | ||
99 | .token_at_offset(position.offset) | ||
95 | .left_biased() | 100 | .left_biased() |
96 | .and_then(ast::Whitespace::cast)?; | 101 | .and_then(ast::Whitespace::cast)?; |
97 | 102 | ||