diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-29 16:25:12 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-29 16:25:12 +0100 |
commit | 32ee06032785ea1792144f7263cbce93a4de467b (patch) | |
tree | fac101a18e111a2a05bce14fbb68981c5bef3bfd /crates/ra_syntax/src/algo.rs | |
parent | 82ce5792ab70ab8d20a1afde72c5400c27b9c190 (diff) | |
parent | bbc4dc995612916a4c0a99396b5259a5fb1dda80 (diff) |
Merge #5127
5127: Update the rest of the tests r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/algo.rs')
-rw-r--r-- | crates/ra_syntax/src/algo.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs index f7a885eb3..26b3c813a 100644 --- a/crates/ra_syntax/src/algo.rs +++ b/crates/ra_syntax/src/algo.rs | |||
@@ -41,6 +41,10 @@ pub fn find_node_at_offset<N: AstNode>(syntax: &SyntaxNode, offset: TextSize) -> | |||
41 | ancestors_at_offset(syntax, offset).find_map(N::cast) | 41 | ancestors_at_offset(syntax, offset).find_map(N::cast) |
42 | } | 42 | } |
43 | 43 | ||
44 | pub fn find_node_at_range<N: AstNode>(syntax: &SyntaxNode, range: TextRange) -> Option<N> { | ||
45 | find_covering_element(syntax, range).ancestors().find_map(N::cast) | ||
46 | } | ||
47 | |||
44 | /// Skip to next non `trivia` token | 48 | /// Skip to next non `trivia` token |
45 | pub fn skip_trivia_token(mut token: SyntaxToken, direction: Direction) -> Option<SyntaxToken> { | 49 | pub fn skip_trivia_token(mut token: SyntaxToken, direction: Direction) -> Option<SyntaxToken> { |
46 | while token.kind().is_trivia() { | 50 | while token.kind().is_trivia() { |