aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-01-10 15:40:52 +0000
committerLukas Wirth <[email protected]>2021-01-10 16:14:01 +0000
commite618d129030b10ddd55d76c3e451799c7dba3f8d (patch)
tree5c421defb6843fd005ad24488f7d040aa704e6f6 /crates/ide/src
parente1430d822e20635170c8da92b928d4d89dd1f680 (diff)
Replace SyntaxKind usage with T! macro where applicable
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/references.rs9
-rw-r--r--crates/ide/src/syntax_highlighting/macro_rules.rs2
2 files changed, 5 insertions, 6 deletions
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::{
21use syntax::{ 21use syntax::{
22 algo::find_node_at_offset, 22 algo::find_node_at_offset,
23 ast::{self, NameOwner}, 23 ast::{self, NameOwner},
24 match_ast, AstNode, SyntaxKind, SyntaxNode, TextRange, TokenAtOffset, 24 match_ast, AstNode, SyntaxNode, TextRange, TokenAtOffset, T,
25}; 25};
26 26
27use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeInfo, SymbolKind}; 27use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeInfo, SymbolKind};
@@ -203,7 +203,7 @@ fn get_struct_def_name_for_struct_literal_search(
203 position: FilePosition, 203 position: FilePosition,
204) -> Option<ast::Name> { 204) -> Option<ast::Name> {
205 if let TokenAtOffset::Between(ref left, ref right) = syntax.token_at_offset(position.offset) { 205 if let TokenAtOffset::Between(ref left, ref right) = syntax.token_at_offset(position.offset) {
206 if right.kind() != SyntaxKind::L_CURLY && right.kind() != SyntaxKind::L_PAREN { 206 if right.kind() != T!['{'] && right.kind() != T!['('] {
207 return None; 207 return None;
208 } 208 }
209 if let Some(name) = 209 if let Some(name) =
@@ -230,7 +230,7 @@ fn get_enum_def_name_for_struct_literal_search(
230 position: FilePosition, 230 position: FilePosition,
231) -> Option<ast::Name> { 231) -> Option<ast::Name> {
232 if let TokenAtOffset::Between(ref left, ref right) = syntax.token_at_offset(position.offset) { 232 if let TokenAtOffset::Between(ref left, ref right) = syntax.token_at_offset(position.offset) {
233 if right.kind() != SyntaxKind::L_CURLY && right.kind() != SyntaxKind::L_PAREN { 233 if right.kind() != T!['{'] && right.kind() != T!['('] {
234 return None; 234 return None;
235 } 235 }
236 if let Some(name) = 236 if let Some(name) =
@@ -255,8 +255,7 @@ fn try_find_self_references(
255 syntax: &SyntaxNode, 255 syntax: &SyntaxNode,
256 position: FilePosition, 256 position: FilePosition,
257) -> Option<RangeInfo<ReferenceSearchResult>> { 257) -> Option<RangeInfo<ReferenceSearchResult>> {
258 let self_token = 258 let self_token = syntax.token_at_offset(position.offset).find(|t| t.kind() == T![self])?;
259 syntax.token_at_offset(position.offset).find(|t| t.kind() == SyntaxKind::SELF_KW)?;
260 let parent = self_token.parent(); 259 let parent = self_token.parent();
261 match_ast! { 260 match_ast! {
262 match parent { 261 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<TextRange> {
119 let tok = element.as_token()?; 119 let tok = element.as_token()?;
120 match tok.kind() { 120 match tok.kind() {
121 kind if kind == SyntaxKind::IDENT || kind.is_keyword() => { 121 kind if kind == SyntaxKind::IDENT || kind.is_keyword() => {
122 if let Some(_dollar) = tok.prev_token().filter(|t| t.kind() == SyntaxKind::DOLLAR) { 122 if let Some(_dollar) = tok.prev_token().filter(|t| t.kind() == T![$]) {
123 return Some(tok.text_range()); 123 return Some(tok.text_range());
124 } 124 }
125 } 125 }