diff options
Diffstat (limited to 'crates/ide/src/runnables.rs')
-rw-r--r-- | crates/ide/src/runnables.rs | 179 |
1 files changed, 39 insertions, 140 deletions
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index 2f465c195..ff386be80 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs | |||
@@ -12,7 +12,7 @@ use syntax::{ | |||
12 | 12 | ||
13 | use crate::{ | 13 | use crate::{ |
14 | display::{ToNav, TryToNav}, | 14 | display::{ToNav, TryToNav}, |
15 | FileId, NavigationTarget, | 15 | FileId, NavigationTarget, SymbolKind, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | #[derive(Debug, Clone)] | 18 | #[derive(Debug, Clone)] |
@@ -137,7 +137,11 @@ fn runnable_fn(sema: &Semantics<RootDatabase>, func: ast::Fn, file_id: FileId) - | |||
137 | } | 137 | } |
138 | }; | 138 | }; |
139 | 139 | ||
140 | let nav = NavigationTarget::from_named(sema.db, InFile::new(file_id.into(), &func)); | 140 | let nav = NavigationTarget::from_named( |
141 | sema.db, | ||
142 | InFile::new(file_id.into(), &func), | ||
143 | SymbolKind::Function, | ||
144 | ); | ||
141 | let cfg = def.attrs(sema.db).cfg(); | 145 | let cfg = def.attrs(sema.db).cfg(); |
142 | Some(Runnable { nav, kind, cfg }) | 146 | Some(Runnable { nav, kind, cfg }) |
143 | } | 147 | } |
@@ -204,7 +208,7 @@ fn module_def_doctest(sema: &Semantics<RootDatabase>, def: hir::ModuleDef) -> Op | |||
204 | nav.focus_range = None; | 208 | nav.focus_range = None; |
205 | nav.description = None; | 209 | nav.description = None; |
206 | nav.docs = None; | 210 | nav.docs = None; |
207 | nav.kind = syntax::SyntaxKind::COMMENT; | 211 | nav.kind = None; |
208 | let res = Runnable { nav, kind: RunnableKind::DocTest { test_id }, cfg: attrs.cfg() }; | 212 | let res = Runnable { nav, kind: RunnableKind::DocTest { test_id }, cfg: attrs.cfg() }; |
209 | Some(res) | 213 | Some(res) |
210 | } | 214 | } |
@@ -348,14 +352,9 @@ fn bench() {} | |||
348 | 0, | 352 | 0, |
349 | ), | 353 | ), |
350 | full_range: 1..13, | 354 | full_range: 1..13, |
351 | focus_range: Some( | 355 | focus_range: 4..8, |
352 | 4..8, | ||
353 | ), | ||
354 | name: "main", | 356 | name: "main", |
355 | kind: FN, | 357 | kind: Function, |
356 | container_name: None, | ||
357 | description: None, | ||
358 | docs: None, | ||
359 | }, | 358 | }, |
360 | kind: Bin, | 359 | kind: Bin, |
361 | cfg: None, | 360 | cfg: None, |
@@ -366,14 +365,9 @@ fn bench() {} | |||
366 | 0, | 365 | 0, |
367 | ), | 366 | ), |
368 | full_range: 15..39, | 367 | full_range: 15..39, |
369 | focus_range: Some( | 368 | focus_range: 26..34, |
370 | 26..34, | ||
371 | ), | ||
372 | name: "test_foo", | 369 | name: "test_foo", |
373 | kind: FN, | 370 | kind: Function, |
374 | container_name: None, | ||
375 | description: None, | ||
376 | docs: None, | ||
377 | }, | 371 | }, |
378 | kind: Test { | 372 | kind: Test { |
379 | test_id: Path( | 373 | test_id: Path( |
@@ -391,14 +385,9 @@ fn bench() {} | |||
391 | 0, | 385 | 0, |
392 | ), | 386 | ), |
393 | full_range: 41..75, | 387 | full_range: 41..75, |
394 | focus_range: Some( | 388 | focus_range: 62..70, |
395 | 62..70, | ||
396 | ), | ||
397 | name: "test_foo", | 389 | name: "test_foo", |
398 | kind: FN, | 390 | kind: Function, |
399 | container_name: None, | ||
400 | description: None, | ||
401 | docs: None, | ||
402 | }, | 391 | }, |
403 | kind: Test { | 392 | kind: Test { |
404 | test_id: Path( | 393 | test_id: Path( |
@@ -416,14 +405,9 @@ fn bench() {} | |||
416 | 0, | 405 | 0, |
417 | ), | 406 | ), |
418 | full_range: 77..99, | 407 | full_range: 77..99, |
419 | focus_range: Some( | 408 | focus_range: 89..94, |
420 | 89..94, | ||
421 | ), | ||
422 | name: "bench", | 409 | name: "bench", |
423 | kind: FN, | 410 | kind: Function, |
424 | container_name: None, | ||
425 | description: None, | ||
426 | docs: None, | ||
427 | }, | 411 | }, |
428 | kind: Bench { | 412 | kind: Bench { |
429 | test_id: Path( | 413 | test_id: Path( |
@@ -513,14 +497,9 @@ struct StructWithRunnable(String); | |||
513 | 0, | 497 | 0, |
514 | ), | 498 | ), |
515 | full_range: 1..13, | 499 | full_range: 1..13, |
516 | focus_range: Some( | 500 | focus_range: 4..8, |
517 | 4..8, | ||
518 | ), | ||
519 | name: "main", | 501 | name: "main", |
520 | kind: FN, | 502 | kind: Function, |
521 | container_name: None, | ||
522 | description: None, | ||
523 | docs: None, | ||
524 | }, | 503 | }, |
525 | kind: Bin, | 504 | kind: Bin, |
526 | cfg: None, | 505 | cfg: None, |
@@ -531,12 +510,7 @@ struct StructWithRunnable(String); | |||
531 | 0, | 510 | 0, |
532 | ), | 511 | ), |
533 | full_range: 15..74, | 512 | full_range: 15..74, |
534 | focus_range: None, | ||
535 | name: "should_have_runnable", | 513 | name: "should_have_runnable", |
536 | kind: COMMENT, | ||
537 | container_name: None, | ||
538 | description: None, | ||
539 | docs: None, | ||
540 | }, | 514 | }, |
541 | kind: DocTest { | 515 | kind: DocTest { |
542 | test_id: Path( | 516 | test_id: Path( |
@@ -551,12 +525,7 @@ struct StructWithRunnable(String); | |||
551 | 0, | 525 | 0, |
552 | ), | 526 | ), |
553 | full_range: 76..148, | 527 | full_range: 76..148, |
554 | focus_range: None, | ||
555 | name: "should_have_runnable_1", | 528 | name: "should_have_runnable_1", |
556 | kind: COMMENT, | ||
557 | container_name: None, | ||
558 | description: None, | ||
559 | docs: None, | ||
560 | }, | 529 | }, |
561 | kind: DocTest { | 530 | kind: DocTest { |
562 | test_id: Path( | 531 | test_id: Path( |
@@ -571,12 +540,7 @@ struct StructWithRunnable(String); | |||
571 | 0, | 540 | 0, |
572 | ), | 541 | ), |
573 | full_range: 150..254, | 542 | full_range: 150..254, |
574 | focus_range: None, | ||
575 | name: "should_have_runnable_2", | 543 | name: "should_have_runnable_2", |
576 | kind: COMMENT, | ||
577 | container_name: None, | ||
578 | description: None, | ||
579 | docs: None, | ||
580 | }, | 544 | }, |
581 | kind: DocTest { | 545 | kind: DocTest { |
582 | test_id: Path( | 546 | test_id: Path( |
@@ -591,12 +555,7 @@ struct StructWithRunnable(String); | |||
591 | 0, | 555 | 0, |
592 | ), | 556 | ), |
593 | full_range: 756..821, | 557 | full_range: 756..821, |
594 | focus_range: None, | ||
595 | name: "StructWithRunnable", | 558 | name: "StructWithRunnable", |
596 | kind: COMMENT, | ||
597 | container_name: None, | ||
598 | description: None, | ||
599 | docs: None, | ||
600 | }, | 559 | }, |
601 | kind: DocTest { | 560 | kind: DocTest { |
602 | test_id: Path( | 561 | test_id: Path( |
@@ -635,14 +594,9 @@ impl Data { | |||
635 | 0, | 594 | 0, |
636 | ), | 595 | ), |
637 | full_range: 1..13, | 596 | full_range: 1..13, |
638 | focus_range: Some( | 597 | focus_range: 4..8, |
639 | 4..8, | ||
640 | ), | ||
641 | name: "main", | 598 | name: "main", |
642 | kind: FN, | 599 | kind: Function, |
643 | container_name: None, | ||
644 | description: None, | ||
645 | docs: None, | ||
646 | }, | 600 | }, |
647 | kind: Bin, | 601 | kind: Bin, |
648 | cfg: None, | 602 | cfg: None, |
@@ -653,12 +607,7 @@ impl Data { | |||
653 | 0, | 607 | 0, |
654 | ), | 608 | ), |
655 | full_range: 44..98, | 609 | full_range: 44..98, |
656 | focus_range: None, | ||
657 | name: "foo", | 610 | name: "foo", |
658 | kind: COMMENT, | ||
659 | container_name: None, | ||
660 | description: None, | ||
661 | docs: None, | ||
662 | }, | 611 | }, |
663 | kind: DocTest { | 612 | kind: DocTest { |
664 | test_id: Path( | 613 | test_id: Path( |
@@ -692,14 +641,9 @@ mod test_mod { | |||
692 | 0, | 641 | 0, |
693 | ), | 642 | ), |
694 | full_range: 1..51, | 643 | full_range: 1..51, |
695 | focus_range: Some( | 644 | focus_range: 5..13, |
696 | 5..13, | ||
697 | ), | ||
698 | name: "test_mod", | 645 | name: "test_mod", |
699 | kind: MODULE, | 646 | kind: Module, |
700 | container_name: None, | ||
701 | description: None, | ||
702 | docs: None, | ||
703 | }, | 647 | }, |
704 | kind: TestMod { | 648 | kind: TestMod { |
705 | path: "test_mod", | 649 | path: "test_mod", |
@@ -712,14 +656,9 @@ mod test_mod { | |||
712 | 0, | 656 | 0, |
713 | ), | 657 | ), |
714 | full_range: 20..49, | 658 | full_range: 20..49, |
715 | focus_range: Some( | 659 | focus_range: 35..44, |
716 | 35..44, | ||
717 | ), | ||
718 | name: "test_foo1", | 660 | name: "test_foo1", |
719 | kind: FN, | 661 | kind: Function, |
720 | container_name: None, | ||
721 | description: None, | ||
722 | docs: None, | ||
723 | }, | 662 | }, |
724 | kind: Test { | 663 | kind: Test { |
725 | test_id: Path( | 664 | test_id: Path( |
@@ -772,14 +711,9 @@ mod root_tests { | |||
772 | 0, | 711 | 0, |
773 | ), | 712 | ), |
774 | full_range: 22..323, | 713 | full_range: 22..323, |
775 | focus_range: Some( | 714 | focus_range: 26..40, |
776 | 26..40, | ||
777 | ), | ||
778 | name: "nested_tests_0", | 715 | name: "nested_tests_0", |
779 | kind: MODULE, | 716 | kind: Module, |
780 | container_name: None, | ||
781 | description: None, | ||
782 | docs: None, | ||
783 | }, | 717 | }, |
784 | kind: TestMod { | 718 | kind: TestMod { |
785 | path: "root_tests::nested_tests_0", | 719 | path: "root_tests::nested_tests_0", |
@@ -792,14 +726,9 @@ mod root_tests { | |||
792 | 0, | 726 | 0, |
793 | ), | 727 | ), |
794 | full_range: 51..192, | 728 | full_range: 51..192, |
795 | focus_range: Some( | 729 | focus_range: 55..69, |
796 | 55..69, | ||
797 | ), | ||
798 | name: "nested_tests_1", | 730 | name: "nested_tests_1", |
799 | kind: MODULE, | 731 | kind: Module, |
800 | container_name: None, | ||
801 | description: None, | ||
802 | docs: None, | ||
803 | }, | 732 | }, |
804 | kind: TestMod { | 733 | kind: TestMod { |
805 | path: "root_tests::nested_tests_0::nested_tests_1", | 734 | path: "root_tests::nested_tests_0::nested_tests_1", |
@@ -812,14 +741,9 @@ mod root_tests { | |||
812 | 0, | 741 | 0, |
813 | ), | 742 | ), |
814 | full_range: 84..126, | 743 | full_range: 84..126, |
815 | focus_range: Some( | 744 | focus_range: 107..121, |
816 | 107..121, | ||
817 | ), | ||
818 | name: "nested_test_11", | 745 | name: "nested_test_11", |
819 | kind: FN, | 746 | kind: Function, |
820 | container_name: None, | ||
821 | description: None, | ||
822 | docs: None, | ||
823 | }, | 747 | }, |
824 | kind: Test { | 748 | kind: Test { |
825 | test_id: Path( | 749 | test_id: Path( |
@@ -837,14 +761,9 @@ mod root_tests { | |||
837 | 0, | 761 | 0, |
838 | ), | 762 | ), |
839 | full_range: 140..182, | 763 | full_range: 140..182, |
840 | focus_range: Some( | 764 | focus_range: 163..177, |
841 | 163..177, | ||
842 | ), | ||
843 | name: "nested_test_12", | 765 | name: "nested_test_12", |
844 | kind: FN, | 766 | kind: Function, |
845 | container_name: None, | ||
846 | description: None, | ||
847 | docs: None, | ||
848 | }, | 767 | }, |
849 | kind: Test { | 768 | kind: Test { |
850 | test_id: Path( | 769 | test_id: Path( |
@@ -862,14 +781,9 @@ mod root_tests { | |||
862 | 0, | 781 | 0, |
863 | ), | 782 | ), |
864 | full_range: 202..286, | 783 | full_range: 202..286, |
865 | focus_range: Some( | 784 | focus_range: 206..220, |
866 | 206..220, | ||
867 | ), | ||
868 | name: "nested_tests_2", | 785 | name: "nested_tests_2", |
869 | kind: MODULE, | 786 | kind: Module, |
870 | container_name: None, | ||
871 | description: None, | ||
872 | docs: None, | ||
873 | }, | 787 | }, |
874 | kind: TestMod { | 788 | kind: TestMod { |
875 | path: "root_tests::nested_tests_0::nested_tests_2", | 789 | path: "root_tests::nested_tests_0::nested_tests_2", |
@@ -882,14 +796,9 @@ mod root_tests { | |||
882 | 0, | 796 | 0, |
883 | ), | 797 | ), |
884 | full_range: 235..276, | 798 | full_range: 235..276, |
885 | focus_range: Some( | 799 | focus_range: 258..271, |
886 | 258..271, | ||
887 | ), | ||
888 | name: "nested_test_2", | 800 | name: "nested_test_2", |
889 | kind: FN, | 801 | kind: Function, |
890 | container_name: None, | ||
891 | description: None, | ||
892 | docs: None, | ||
893 | }, | 802 | }, |
894 | kind: Test { | 803 | kind: Test { |
895 | test_id: Path( | 804 | test_id: Path( |
@@ -925,14 +834,9 @@ fn test_foo1() {} | |||
925 | 0, | 834 | 0, |
926 | ), | 835 | ), |
927 | full_range: 1..50, | 836 | full_range: 1..50, |
928 | focus_range: Some( | 837 | focus_range: 36..45, |
929 | 36..45, | ||
930 | ), | ||
931 | name: "test_foo1", | 838 | name: "test_foo1", |
932 | kind: FN, | 839 | kind: Function, |
933 | container_name: None, | ||
934 | description: None, | ||
935 | docs: None, | ||
936 | }, | 840 | }, |
937 | kind: Test { | 841 | kind: Test { |
938 | test_id: Path( | 842 | test_id: Path( |
@@ -975,14 +879,9 @@ fn test_foo1() {} | |||
975 | 0, | 879 | 0, |
976 | ), | 880 | ), |
977 | full_range: 1..72, | 881 | full_range: 1..72, |
978 | focus_range: Some( | 882 | focus_range: 58..67, |
979 | 58..67, | ||
980 | ), | ||
981 | name: "test_foo1", | 883 | name: "test_foo1", |
982 | kind: FN, | 884 | kind: Function, |
983 | container_name: None, | ||
984 | description: None, | ||
985 | docs: None, | ||
986 | }, | 885 | }, |
987 | kind: Test { | 886 | kind: Test { |
988 | test_id: Path( | 887 | test_id: Path( |