3
3
use crate :: { resolving:: ResolvedRule , Match , SsrMatches } ;
4
4
use itertools:: Itertools ;
5
5
use rustc_hash:: { FxHashMap , FxHashSet } ;
6
- use syntax:: ast:: { self , AstToken } ;
6
+ use syntax:: ast:: { self , AstNode , AstToken } ;
7
7
use syntax:: { SyntaxElement , SyntaxKind , SyntaxNode , SyntaxToken , TextRange , TextSize } ;
8
8
use test_utils:: mark;
9
9
use text_edit:: TextEdit ;
@@ -93,7 +93,6 @@ impl ReplacementRenderer<'_> {
93
93
}
94
94
95
95
fn render_node ( & mut self , node : & SyntaxNode ) {
96
- use syntax:: ast:: AstNode ;
97
96
if let Some ( mod_path) = self . match_info . rendered_template_paths . get ( & node) {
98
97
self . out . push_str ( & mod_path. to_string ( ) ) ;
99
98
// Emit everything except for the segment's name-ref, since we already effectively
@@ -206,11 +205,10 @@ impl ReplacementRenderer<'_> {
206
205
/// method call doesn't count. e.g. if the token is `$a`, then `$a.foo()` will return true, while
207
206
/// `($a + $b).foo()` or `x.foo($a)` will return false.
208
207
fn token_is_method_call_receiver ( token : & SyntaxToken ) -> bool {
209
- use syntax:: ast:: AstNode ;
210
208
// Find the first method call among the ancestors of `token`, then check if the only token
211
209
// within the receiver is `token`.
212
210
if let Some ( receiver) =
213
- token. ancestors ( ) . find_map ( ast:: MethodCallExpr :: cast) . and_then ( |call| call. expr ( ) )
211
+ token. ancestors ( ) . find_map ( ast:: MethodCallExpr :: cast) . and_then ( |call| call. receiver ( ) )
214
212
{
215
213
let tokens = receiver. syntax ( ) . descendants_with_tokens ( ) . filter_map ( |node_or_token| {
216
214
match node_or_token {
@@ -226,7 +224,6 @@ fn token_is_method_call_receiver(token: &SyntaxToken) -> bool {
226
224
}
227
225
228
226
fn parse_as_kind ( code : & str , kind : SyntaxKind ) -> Option < SyntaxNode > {
229
- use syntax:: ast:: AstNode ;
230
227
if ast:: Expr :: can_cast ( kind) {
231
228
if let Ok ( expr) = ast:: Expr :: parse ( code) {
232
229
return Some ( expr. syntax ( ) . clone ( ) ) ;
0 commit comments