aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/references.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/references.rs')
-rw-r--r--crates/ra_ide/src/references.rs48
1 files changed, 24 insertions, 24 deletions
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs
index fe1c074d1..cf456630a 100644
--- a/crates/ra_ide/src/references.rs
+++ b/crates/ra_ide/src/references.rs
@@ -150,7 +150,7 @@ fn decl_access(def: &Definition, syntax: &SyntaxNode, range: TextRange) -> Optio
150 let stmt = find_node_at_offset::<ast::LetStmt>(syntax, range.start())?; 150 let stmt = find_node_at_offset::<ast::LetStmt>(syntax, range.start())?;
151 if stmt.initializer().is_some() { 151 if stmt.initializer().is_some() {
152 let pat = stmt.pat()?; 152 let pat = stmt.pat()?;
153 if let ast::Pat::BindPat(it) = pat { 153 if let ast::Pat::IdentPat(it) = pat {
154 if it.mut_token().is_some() { 154 if it.mut_token().is_some() {
155 return Some(ReferenceAccess::Write); 155 return Some(ReferenceAccess::Write);
156 } 156 }
@@ -172,16 +172,16 @@ fn get_struct_def_name_for_struct_literal_search(
172 if let Some(name) = 172 if let Some(name) =
173 sema.find_node_at_offset_with_descend::<ast::Name>(&syntax, left.text_range().start()) 173 sema.find_node_at_offset_with_descend::<ast::Name>(&syntax, left.text_range().start())
174 { 174 {
175 return name.syntax().ancestors().find_map(ast::StructDef::cast).and_then(|l| l.name()); 175 return name.syntax().ancestors().find_map(ast::Struct::cast).and_then(|l| l.name());
176 } 176 }
177 if sema 177 if sema
178 .find_node_at_offset_with_descend::<ast::TypeParamList>( 178 .find_node_at_offset_with_descend::<ast::GenericParamList>(
179 &syntax, 179 &syntax,
180 left.text_range().start(), 180 left.text_range().start(),
181 ) 181 )
182 .is_some() 182 .is_some()
183 { 183 {
184 return left.ancestors().find_map(ast::StructDef::cast).and_then(|l| l.name()); 184 return left.ancestors().find_map(ast::Struct::cast).and_then(|l| l.name());
185 } 185 }
186 } 186 }
187 None 187 None
@@ -212,7 +212,7 @@ fn main() {
212 ); 212 );
213 check_result( 213 check_result(
214 refs, 214 refs,
215 "Foo STRUCT_DEF FileId(1) 0..26 7..10 Other", 215 "Foo STRUCT FileId(1) 0..26 7..10 Other",
216 &["FileId(1) 101..104 StructLiteral"], 216 &["FileId(1) 101..104 StructLiteral"],
217 ); 217 );
218 } 218 }
@@ -230,7 +230,7 @@ struct Foo<|> {}
230 ); 230 );
231 check_result( 231 check_result(
232 refs, 232 refs,
233 "Foo STRUCT_DEF FileId(1) 0..13 7..10 Other", 233 "Foo STRUCT FileId(1) 0..13 7..10 Other",
234 &["FileId(1) 41..44 Other", "FileId(1) 54..57 StructLiteral"], 234 &["FileId(1) 41..44 Other", "FileId(1) 54..57 StructLiteral"],
235 ); 235 );
236 } 236 }
@@ -248,7 +248,7 @@ struct Foo<T> <|>{}
248 ); 248 );
249 check_result( 249 check_result(
250 refs, 250 refs,
251 "Foo STRUCT_DEF FileId(1) 0..16 7..10 Other", 251 "Foo STRUCT FileId(1) 0..16 7..10 Other",
252 &["FileId(1) 64..67 StructLiteral"], 252 &["FileId(1) 64..67 StructLiteral"],
253 ); 253 );
254 } 254 }
@@ -267,7 +267,7 @@ fn main() {
267 ); 267 );
268 check_result( 268 check_result(
269 refs, 269 refs,
270 "Foo STRUCT_DEF FileId(1) 0..16 7..10 Other", 270 "Foo STRUCT FileId(1) 0..16 7..10 Other",
271 &["FileId(1) 54..57 StructLiteral"], 271 &["FileId(1) 54..57 StructLiteral"],
272 ); 272 );
273 } 273 }
@@ -290,7 +290,7 @@ fn main() {
290 ); 290 );
291 check_result( 291 check_result(
292 refs, 292 refs,
293 "i BIND_PAT FileId(1) 24..25 Other Write", 293 "i IDENT_PAT FileId(1) 24..25 Other Write",
294 &[ 294 &[
295 "FileId(1) 50..51 Other Write", 295 "FileId(1) 50..51 Other Write",
296 "FileId(1) 54..55 Other Read", 296 "FileId(1) 54..55 Other Read",
@@ -316,7 +316,7 @@ fn bar() {
316 ); 316 );
317 check_result( 317 check_result(
318 refs, 318 refs,
319 "spam BIND_PAT FileId(1) 19..23 Other", 319 "spam IDENT_PAT FileId(1) 19..23 Other",
320 &["FileId(1) 34..38 Other Read", "FileId(1) 41..45 Other Read"], 320 &["FileId(1) 34..38 Other Read", "FileId(1) 41..45 Other Read"],
321 ); 321 );
322 } 322 }
@@ -330,7 +330,7 @@ fn foo(i : u32) -> u32 {
330} 330}
331"#, 331"#,
332 ); 332 );
333 check_result(refs, "i BIND_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]); 333 check_result(refs, "i IDENT_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]);
334 } 334 }
335 335
336 #[test] 336 #[test]
@@ -342,7 +342,7 @@ fn foo(i<|> : u32) -> u32 {
342} 342}
343"#, 343"#,
344 ); 344 );
345 check_result(refs, "i BIND_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]); 345 check_result(refs, "i IDENT_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]);
346 } 346 }
347 347
348 #[test] 348 #[test]
@@ -361,7 +361,7 @@ fn main(s: Foo) {
361 ); 361 );
362 check_result( 362 check_result(
363 refs, 363 refs,
364 "spam RECORD_FIELD_DEF FileId(1) 17..30 21..25 Other", 364 "spam RECORD_FIELD FileId(1) 17..30 21..25 Other",
365 &["FileId(1) 67..71 Other Read"], 365 &["FileId(1) 67..71 Other Read"],
366 ); 366 );
367 } 367 }
@@ -376,7 +376,7 @@ impl Foo {
376} 376}
377"#, 377"#,
378 ); 378 );
379 check_result(refs, "f FN_DEF FileId(1) 27..43 30..31 Other", &[]); 379 check_result(refs, "f FN FileId(1) 27..43 30..31 Other", &[]);
380 } 380 }
381 381
382 #[test] 382 #[test]
@@ -390,7 +390,7 @@ enum Foo {
390} 390}
391"#, 391"#,
392 ); 392 );
393 check_result(refs, "B ENUM_VARIANT FileId(1) 22..23 22..23 Other", &[]); 393 check_result(refs, "B VARIANT FileId(1) 22..23 22..23 Other", &[]);
394 } 394 }
395 395
396 #[test] 396 #[test]
@@ -431,7 +431,7 @@ fn f() {
431 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); 431 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
432 check_result( 432 check_result(
433 refs, 433 refs,
434 "Foo STRUCT_DEF FileId(2) 17..51 28..31 Other", 434 "Foo STRUCT FileId(2) 17..51 28..31 Other",
435 &["FileId(1) 53..56 StructLiteral", "FileId(3) 79..82 StructLiteral"], 435 &["FileId(1) 53..56 StructLiteral", "FileId(3) 79..82 StructLiteral"],
436 ); 436 );
437 } 437 }
@@ -486,7 +486,7 @@ pub(super) struct Foo<|> {
486 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); 486 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
487 check_result( 487 check_result(
488 refs, 488 refs,
489 "Foo STRUCT_DEF FileId(3) 0..41 18..21 Other", 489 "Foo STRUCT FileId(3) 0..41 18..21 Other",
490 &["FileId(2) 20..23 Other", "FileId(2) 47..50 StructLiteral"], 490 &["FileId(2) 20..23 Other", "FileId(2) 47..50 StructLiteral"],
491 ); 491 );
492 } 492 }
@@ -514,7 +514,7 @@ pub(super) struct Foo<|> {
514 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); 514 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
515 check_result( 515 check_result(
516 refs, 516 refs,
517 "quux FN_DEF FileId(1) 19..35 26..30 Other", 517 "quux FN FileId(1) 19..35 26..30 Other",
518 &["FileId(2) 16..20 StructLiteral", "FileId(3) 16..20 StructLiteral"], 518 &["FileId(2) 16..20 StructLiteral", "FileId(3) 16..20 StructLiteral"],
519 ); 519 );
520 520
@@ -522,7 +522,7 @@ pub(super) struct Foo<|> {
522 analysis.find_all_refs(pos, Some(SearchScope::single_file(bar))).unwrap().unwrap(); 522 analysis.find_all_refs(pos, Some(SearchScope::single_file(bar))).unwrap().unwrap();
523 check_result( 523 check_result(
524 refs, 524 refs,
525 "quux FN_DEF FileId(1) 19..35 26..30 Other", 525 "quux FN FileId(1) 19..35 26..30 Other",
526 &["FileId(3) 16..20 StructLiteral"], 526 &["FileId(3) 16..20 StructLiteral"],
527 ); 527 );
528 } 528 }
@@ -559,7 +559,7 @@ fn foo() {
559 ); 559 );
560 check_result( 560 check_result(
561 refs, 561 refs,
562 "i BIND_PAT FileId(1) 23..24 Other Write", 562 "i IDENT_PAT FileId(1) 23..24 Other Write",
563 &["FileId(1) 34..35 Other Write", "FileId(1) 38..39 Other Read"], 563 &["FileId(1) 34..35 Other Write", "FileId(1) 38..39 Other Read"],
564 ); 564 );
565 } 565 }
@@ -580,7 +580,7 @@ fn foo() {
580 ); 580 );
581 check_result( 581 check_result(
582 refs, 582 refs,
583 "f RECORD_FIELD_DEF FileId(1) 15..21 15..16 Other", 583 "f RECORD_FIELD FileId(1) 15..21 15..16 Other",
584 &["FileId(1) 55..56 Other Read", "FileId(1) 68..69 Other Write"], 584 &["FileId(1) 55..56 Other Read", "FileId(1) 68..69 Other Write"],
585 ); 585 );
586 } 586 }
@@ -595,7 +595,7 @@ fn foo() {
595} 595}
596"#, 596"#,
597 ); 597 );
598 check_result(refs, "i BIND_PAT FileId(1) 19..20 Other", &["FileId(1) 26..27 Other Write"]); 598 check_result(refs, "i IDENT_PAT FileId(1) 19..20 Other", &["FileId(1) 26..27 Other Write"]);
599 } 599 }
600 600
601 #[test] 601 #[test]
@@ -619,7 +619,7 @@ fn main() {
619 ); 619 );
620 check_result( 620 check_result(
621 refs, 621 refs,
622 "new FN_DEF FileId(1) 54..101 61..64 Other", 622 "new FN FileId(1) 54..101 61..64 Other",
623 &["FileId(1) 146..149 StructLiteral"], 623 &["FileId(1) 146..149 StructLiteral"],
624 ); 624 );
625 } 625 }
@@ -646,7 +646,7 @@ fn main() {
646 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); 646 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
647 check_result( 647 check_result(
648 refs, 648 refs,
649 "f FN_DEF FileId(1) 26..35 29..30 Other", 649 "f FN FileId(1) 26..35 29..30 Other",
650 &["FileId(2) 11..12 Other", "FileId(2) 28..29 StructLiteral"], 650 &["FileId(2) 11..12 Other", "FileId(2) 28..29 StructLiteral"],
651 ); 651 );
652 } 652 }