11use hir:: { HasSource , InFile , InRealFile , Semantics } ;
22use ide_db:: {
3- defs:: Definition , helpers:: visit_file_defs, FileId , FilePosition , FileRange , FxHashSet ,
3+ defs:: Definition , helpers:: visit_file_defs, FileId , FilePosition , FileRange , FxIndexSet ,
44 RootDatabase ,
55} ;
66use itertools:: Itertools ;
@@ -55,7 +55,7 @@ pub(crate) fn annotations(
5555 config : & AnnotationConfig ,
5656 file_id : FileId ,
5757) -> Vec < Annotation > {
58- let mut annotations = FxHashSet :: default ( ) ;
58+ let mut annotations = FxIndexSet :: default ( ) ;
5959
6060 if config. annotate_runnables {
6161 for runnable in runnables ( db, file_id) {
@@ -170,7 +170,19 @@ pub(crate) fn annotations(
170170 } ) ) ;
171171 }
172172
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 ( )
174186}
175187
176188pub ( crate ) fn resolve_annotation ( db : & RootDatabase , mut annotation : Annotation ) -> Annotation {
@@ -535,6 +547,20 @@ fn main() {
535547 ),
536548 },
537549 },
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+ },
538564 Annotation {
539565 range: 69..73,
540566 kind: Runnable(
@@ -559,20 +585,6 @@ fn main() {
559585 },
560586 ),
561587 },
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- },
576588 ]
577589 "# ] ] ,
578590 ) ;
@@ -717,6 +729,20 @@ fn main() {
717729 ),
718730 },
719731 },
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+ },
720746 Annotation {
721747 range: 61..65,
722748 kind: Runnable(
@@ -741,20 +767,6 @@ fn main() {
741767 },
742768 ),
743769 },
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- },
758770 ]
759771 "# ] ] ,
760772 ) ;
0 commit comments