diff options
Diffstat (limited to 'crates/ide/src/references.rs')
-rw-r--r-- | crates/ide/src/references.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index 0d5cd5f9a..b774a2be1 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | //! or `ast::NameRef`. If it's a `ast::NameRef`, at the classification step we | 3 | //! or `ast::NameRef`. If it's a `ast::NameRef`, at the classification step we |
4 | //! try to resolve the direct tree parent of this element, otherwise we | 4 | //! try to resolve the direct tree parent of this element, otherwise we |
5 | //! already have a definition and just need to get its HIR together with | 5 | //! already have a definition and just need to get its HIR together with |
6 | //! some information that is needed for futher steps of searching. | 6 | //! some information that is needed for further steps of searching. |
7 | //! After that, we collect files that might contain references and look | 7 | //! After that, we collect files that might contain references and look |
8 | //! for text occurrences of the identifier. If there's an `ast::NameRef` | 8 | //! for text occurrences of the identifier. If there's an `ast::NameRef` |
9 | //! at the index that the match starts at and its tree parent is | 9 | //! at the index that the match starts at and its tree parent is |
@@ -21,7 +21,7 @@ use ide_db::{ | |||
21 | use syntax::{ | 21 | use 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 | ||
27 | use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeInfo, SymbolKind}; | 27 | use 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 { |