From e618d129030b10ddd55d76c3e451799c7dba3f8d Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 10 Jan 2021 16:40:52 +0100 Subject: Replace SyntaxKind usage with T! macro where applicable --- crates/ide/src/references.rs | 9 ++++----- crates/ide/src/syntax_highlighting/macro_rules.rs | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index 0d5cd5f9a..d44d96dd4 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs @@ -21,7 +21,7 @@ use ide_db::{ use syntax::{ algo::find_node_at_offset, ast::{self, NameOwner}, - match_ast, AstNode, SyntaxKind, SyntaxNode, TextRange, TokenAtOffset, + match_ast, AstNode, SyntaxNode, TextRange, TokenAtOffset, T, }; use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeInfo, SymbolKind}; @@ -203,7 +203,7 @@ fn get_struct_def_name_for_struct_literal_search( position: FilePosition, ) -> Option { if let TokenAtOffset::Between(ref left, ref right) = syntax.token_at_offset(position.offset) { - if right.kind() != SyntaxKind::L_CURLY && right.kind() != SyntaxKind::L_PAREN { + if right.kind() != T!['{'] && right.kind() != T!['('] { return None; } if let Some(name) = @@ -230,7 +230,7 @@ fn get_enum_def_name_for_struct_literal_search( position: FilePosition, ) -> Option { if let TokenAtOffset::Between(ref left, ref right) = syntax.token_at_offset(position.offset) { - if right.kind() != SyntaxKind::L_CURLY && right.kind() != SyntaxKind::L_PAREN { + if right.kind() != T!['{'] && right.kind() != T!['('] { return None; } if let Some(name) = @@ -255,8 +255,7 @@ fn try_find_self_references( syntax: &SyntaxNode, position: FilePosition, ) -> Option> { - let self_token = - syntax.token_at_offset(position.offset).find(|t| t.kind() == SyntaxKind::SELF_KW)?; + let self_token = syntax.token_at_offset(position.offset).find(|t| t.kind() == T![self])?; let parent = self_token.parent(); match_ast! { match parent { diff --git a/crates/ide/src/syntax_highlighting/macro_rules.rs b/crates/ide/src/syntax_highlighting/macro_rules.rs index 21d8a9835..44620e912 100644 --- a/crates/ide/src/syntax_highlighting/macro_rules.rs +++ b/crates/ide/src/syntax_highlighting/macro_rules.rs @@ -119,7 +119,7 @@ fn is_metavariable(element: SyntaxElement) -> Option { let tok = element.as_token()?; match tok.kind() { kind if kind == SyntaxKind::IDENT || kind.is_keyword() => { - if let Some(_dollar) = tok.prev_token().filter(|t| t.kind() == SyntaxKind::DOLLAR) { + if let Some(_dollar) = tok.prev_token().filter(|t| t.kind() == T![$]) { return Some(tok.text_range()); } } -- cgit v1.2.3