@@ -5,7 +5,7 @@ use std::fmt;
55use either:: Either ;
66use hir:: { AssocItem , Documentation , FieldSource , HasAttrs , HasSource , InFile , ModuleSource } ;
77use ide_db:: {
8- base_db:: { FileId , SourceDatabase } ,
8+ base_db:: { FileId , FileRange , SourceDatabase } ,
99 symbol_index:: FileSymbolKind ,
1010} ;
1111use ide_db:: { defs:: Definition , RootDatabase } ;
@@ -28,6 +28,7 @@ pub enum SymbolKind {
2828 ValueParam ,
2929 SelfParam ,
3030 Local ,
31+ Label ,
3132 Function ,
3233 Const ,
3334 Static ,
@@ -223,6 +224,7 @@ impl TryToNav for Definition {
223224 Definition :: Local ( it) => Some ( it. to_nav ( db) ) ,
224225 Definition :: TypeParam ( it) => Some ( it. to_nav ( db) ) ,
225226 Definition :: LifetimeParam ( it) => Some ( it. to_nav ( db) ) ,
227+ Definition :: Label ( it) => Some ( it. to_nav ( db) ) ,
226228 }
227229 }
228230}
@@ -421,6 +423,27 @@ impl ToNav for hir::Local {
421423 }
422424}
423425
426+ impl ToNav for hir:: Label {
427+ fn to_nav ( & self , db : & RootDatabase ) -> NavigationTarget {
428+ let src = self . source ( db) ;
429+ let node = src. value . syntax ( ) ;
430+ let FileRange { file_id, range } = src. with_value ( node) . original_file_range ( db) ;
431+ let focus_range =
432+ src. value . lifetime ( ) . and_then ( |lt| lt. lifetime_ident_token ( ) ) . map ( |lt| lt. text_range ( ) ) ;
433+ let name = self . name ( db) . to_string ( ) . into ( ) ;
434+ NavigationTarget {
435+ file_id,
436+ name,
437+ kind : Some ( SymbolKind :: Label ) ,
438+ full_range : range,
439+ focus_range,
440+ container_name : None ,
441+ description : None ,
442+ docs : None ,
443+ }
444+ }
445+ }
446+
424447impl ToNav for hir:: TypeParam {
425448 fn to_nav ( & self , db : & RootDatabase ) -> NavigationTarget {
426449 let src = self . source ( db) ;
0 commit comments