1
1
use hir:: { HasSource , InFile , InRealFile , Semantics } ;
2
2
use ide_db:: {
3
3
defs:: Definition , helpers:: visit_file_defs, FileId , FilePosition , FileRange , FxHashSet ,
4
- RootDatabase ,
4
+ FxIndexSet , RootDatabase ,
5
5
} ;
6
6
use itertools:: Itertools ;
7
7
use syntax:: { ast:: HasName , AstNode , TextRange } ;
@@ -55,7 +55,7 @@ pub(crate) fn annotations(
55
55
config : & AnnotationConfig ,
56
56
file_id : FileId ,
57
57
) -> Vec < Annotation > {
58
- let mut annotations = FxHashSet :: default ( ) ;
58
+ let mut annotations = FxIndexSet :: default ( ) ;
59
59
60
60
if config. annotate_runnables {
61
61
for runnable in runnables ( db, file_id) {
@@ -170,7 +170,19 @@ pub(crate) fn annotations(
170
170
} ) ) ;
171
171
}
172
172
173
- annotations. into_iter ( ) . sorted_by_key ( |a| ( a. range . start ( ) , a. range . end ( ) ) ) . collect ( )
173
+ annotations
174
+ . into_iter ( )
175
+ . sorted_by_key ( |a| {
176
+ (
177
+ a. range . start ( ) ,
178
+ a. range . end ( ) ,
179
+ match & a. kind {
180
+ AnnotationKind :: Runnable ( runnable) => Some ( runnable. nav . name . clone ( ) ) ,
181
+ _ => None ,
182
+ } ,
183
+ )
184
+ } )
185
+ . collect ( )
174
186
}
175
187
176
188
pub ( crate ) fn resolve_annotation ( db : & RootDatabase , mut annotation : Annotation ) -> Annotation {
@@ -535,6 +547,20 @@ fn main() {
535
547
),
536
548
},
537
549
},
550
+ Annotation {
551
+ range: 69..73,
552
+ kind: HasReferences {
553
+ pos: FilePositionWrapper {
554
+ file_id: FileId(
555
+ 0,
556
+ ),
557
+ offset: 69,
558
+ },
559
+ data: Some(
560
+ [],
561
+ ),
562
+ },
563
+ },
538
564
Annotation {
539
565
range: 69..73,
540
566
kind: Runnable(
@@ -559,20 +585,6 @@ fn main() {
559
585
},
560
586
),
561
587
},
562
- Annotation {
563
- range: 69..73,
564
- kind: HasReferences {
565
- pos: FilePositionWrapper {
566
- file_id: FileId(
567
- 0,
568
- ),
569
- offset: 69,
570
- },
571
- data: Some(
572
- [],
573
- ),
574
- },
575
- },
576
588
]
577
589
"# ] ] ,
578
590
) ;
@@ -717,6 +729,20 @@ fn main() {
717
729
),
718
730
},
719
731
},
732
+ Annotation {
733
+ range: 61..65,
734
+ kind: HasReferences {
735
+ pos: FilePositionWrapper {
736
+ file_id: FileId(
737
+ 0,
738
+ ),
739
+ offset: 61,
740
+ },
741
+ data: Some(
742
+ [],
743
+ ),
744
+ },
745
+ },
720
746
Annotation {
721
747
range: 61..65,
722
748
kind: Runnable(
@@ -741,20 +767,6 @@ fn main() {
741
767
},
742
768
),
743
769
},
744
- Annotation {
745
- range: 61..65,
746
- kind: HasReferences {
747
- pos: FilePositionWrapper {
748
- file_id: FileId(
749
- 0,
750
- ),
751
- offset: 61,
752
- },
753
- data: Some(
754
- [],
755
- ),
756
- },
757
- },
758
770
]
759
771
"# ] ] ,
760
772
) ;
0 commit comments