diff options
Diffstat (limited to 'crates/ra_assists/src/assist_ctx.rs')
-rw-r--r-- | crates/ra_assists/src/assist_ctx.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs index e270c5d60..20d33fb16 100644 --- a/crates/ra_assists/src/assist_ctx.rs +++ b/crates/ra_assists/src/assist_ctx.rs | |||
@@ -5,7 +5,7 @@ use ra_db::FileRange; | |||
5 | use ra_fmt::{leading_indent, reindent}; | 5 | use ra_fmt::{leading_indent, reindent}; |
6 | use ra_syntax::{ | 6 | use ra_syntax::{ |
7 | algo::{self, find_covering_element, find_node_at_offset}, | 7 | algo::{self, find_covering_element, find_node_at_offset}, |
8 | AstNode, SourceFile, SyntaxElement, SyntaxNode, SyntaxToken, TextRange, TextUnit, | 8 | AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextUnit, |
9 | TokenAtOffset, | 9 | TokenAtOffset, |
10 | }; | 10 | }; |
11 | use ra_text_edit::TextEditBuilder; | 11 | use ra_text_edit::TextEditBuilder; |
@@ -111,6 +111,10 @@ impl<'a, DB: HirDatabase> AssistCtx<'a, DB> { | |||
111 | self.source_file.syntax().token_at_offset(self.frange.range.start()) | 111 | self.source_file.syntax().token_at_offset(self.frange.range.start()) |
112 | } | 112 | } |
113 | 113 | ||
114 | pub(crate) fn find_token_at_offset(&self, kind: SyntaxKind) -> Option<SyntaxToken> { | ||
115 | self.token_at_offset().find(|it| it.kind() == kind) | ||
116 | } | ||
117 | |||
114 | pub(crate) fn node_at_offset<N: AstNode>(&self) -> Option<N> { | 118 | pub(crate) fn node_at_offset<N: AstNode>(&self) -> Option<N> { |
115 | find_node_at_offset(self.source_file.syntax(), self.frange.range.start()) | 119 | find_node_at_offset(self.source_file.syntax(), self.frange.range.start()) |
116 | } | 120 | } |