@@ -55,8 +55,8 @@ pub enum FoundDeclaration<'a> {
5555 Component ( & ' a mut ComponentDeclaration ) ,
5656 Attribute ( & ' a mut AttributeDeclaration ) ,
5757 Alias ( & ' a mut AliasDeclaration ) ,
58- Function ( & ' a mut FunctionSpecification ) ,
59- Procedure ( & ' a mut ProcedureSpecification ) ,
58+ SubprogramDecl ( & ' a mut SubprogramDeclaration ) ,
59+ Subprogram ( & ' a mut SubprogramBody ) ,
6060 SubprogramInstantiation ( & ' a mut SubprogramInstantiation ) ,
6161 Package ( & ' a mut PackageDeclaration ) ,
6262 PackageBody ( & ' a mut PackageBody ) ,
@@ -1001,14 +1001,12 @@ impl Search for Declaration {
10011001 return_if_found ! ( typ. search( ctx, searcher) ) ;
10021002 }
10031003 Declaration :: SubprogramBody ( body) => {
1004- return_if_found ! ( body. specification. search( ctx, searcher) ) ;
1004+ return_if_found ! ( searcher
1005+ . search_decl( ctx, FoundDeclaration :: Subprogram ( body) )
1006+ . or_not_found( ) ) ;
1007+ return_if_found ! ( search_subpgm_inner( & mut body. specification, ctx, searcher) ) ;
10051008 return_if_found ! ( body. declarations. search( ctx, searcher) ) ;
10061009 return_if_found ! ( body. statements. search( ctx, searcher) ) ;
1007- if let Some ( ref end_ident_pos) = body. end_ident_pos {
1008- return_if_found ! ( searcher
1009- . search_pos_with_ref( ctx, end_ident_pos, body. specification. reference_mut( ) )
1010- . or_not_found( ) ) ;
1011- }
10121010 }
10131011 Declaration :: SubprogramDeclaration ( decl) => {
10141012 return_if_found ! ( decl. search( ctx, searcher) ) ;
@@ -1118,18 +1116,9 @@ impl Search for InterfaceDeclaration {
11181116 return_if_found ! ( decl. expression. search( ctx, searcher) ) ;
11191117 }
11201118 InterfaceDeclaration :: Subprogram ( ref mut decl, ref mut subpgm_default) => {
1121- match decl {
1122- SubprogramDeclaration :: Function ( f) => {
1123- return_if_found ! ( searcher
1124- . search_decl( ctx, FoundDeclaration :: Function ( f) )
1125- . or_not_found( ) ) ;
1126- }
1127- SubprogramDeclaration :: Procedure ( p) => {
1128- return_if_found ! ( searcher
1129- . search_decl( ctx, FoundDeclaration :: Procedure ( p) )
1130- . or_not_found( ) ) ;
1131- }
1132- }
1119+ return_if_found ! ( searcher
1120+ . search_decl( ctx, FoundDeclaration :: SubprogramDecl ( decl) )
1121+ . or_not_found( ) ) ;
11331122
11341123 if let Some ( subpgm_default) = subpgm_default {
11351124 match subpgm_default {
@@ -1169,37 +1158,29 @@ impl Search for InterfaceDeclaration {
11691158}
11701159
11711160impl Search for SubprogramDeclaration {
1172- fn search ( & mut self , ctx : & dyn TokenAccess , searcher : & mut impl Searcher ) -> SearchResult {
1173- match self {
1174- SubprogramDeclaration :: Function ( ref mut decl) => {
1175- return_if_found ! ( decl. search( ctx, searcher) ) ;
1176- }
1177- SubprogramDeclaration :: Procedure ( ref mut decl) => {
1178- return_if_found ! ( decl. search( ctx, searcher) ) ;
1179- }
1180- }
1181- NotFound
1182- }
1183- }
1184-
1185- impl Search for ProcedureSpecification {
11861161 fn search ( & mut self , ctx : & dyn TokenAccess , searcher : & mut impl Searcher ) -> SearchResult {
11871162 return_if_found ! ( searcher
1188- . search_decl( ctx, FoundDeclaration :: Procedure ( self ) )
1163+ . search_decl( ctx, FoundDeclaration :: SubprogramDecl ( self ) )
11891164 . or_not_found( ) ) ;
1190- return_if_found ! ( self . header. search( ctx, searcher) ) ;
1191- self . parameter_list . search ( ctx, searcher)
1165+ search_subpgm_inner ( self , ctx, searcher)
11921166 }
11931167}
11941168
1195- impl Search for FunctionSpecification {
1196- fn search ( & mut self , ctx : & dyn TokenAccess , searcher : & mut impl Searcher ) -> SearchResult {
1197- return_if_found ! ( searcher
1198- . search_decl( ctx, FoundDeclaration :: Function ( self ) )
1199- . or_not_found( ) ) ;
1200- return_if_found ! ( self . header. search( ctx, searcher) ) ;
1201- return_if_found ! ( self . parameter_list. search( ctx, searcher) ) ;
1202- self . return_type . search ( ctx, searcher)
1169+ fn search_subpgm_inner (
1170+ subgpm : & mut SubprogramDeclaration ,
1171+ ctx : & dyn TokenAccess ,
1172+ searcher : & mut impl Searcher ,
1173+ ) -> SearchResult {
1174+ match subgpm {
1175+ SubprogramDeclaration :: Function ( ref mut decl) => {
1176+ return_if_found ! ( decl. header. search( ctx, searcher) ) ;
1177+ return_if_found ! ( decl. parameter_list. search( ctx, searcher) ) ;
1178+ decl. return_type . search ( ctx, searcher)
1179+ }
1180+ SubprogramDeclaration :: Procedure ( ref mut decl) => {
1181+ return_if_found ! ( decl. header. search( ctx, searcher) ) ;
1182+ decl. parameter_list . search ( ctx, searcher)
1183+ }
12031184 }
12041185}
12051186
@@ -1662,8 +1643,8 @@ impl<'a> FoundDeclaration<'a> {
16621643 FoundDeclaration :: InterfaceObject ( _) => None ,
16631644 FoundDeclaration :: ForIndex ( ..) => None ,
16641645 FoundDeclaration :: ForGenerateIndex ( ..) => None ,
1665- FoundDeclaration :: Function ( .. ) => None ,
1666- FoundDeclaration :: Procedure ( ..) => None ,
1646+ FoundDeclaration :: Subprogram ( value ) => value . end_ident_pos . as_ref ( ) ,
1647+ FoundDeclaration :: SubprogramDecl ( ..) => None ,
16671648 FoundDeclaration :: Object ( ..) => None ,
16681649 FoundDeclaration :: ElementDeclaration ( ..) => None ,
16691650 FoundDeclaration :: EnumerationLiteral ( ..) => None ,
@@ -1698,8 +1679,8 @@ impl<'a> HasEntityId for FoundDeclaration<'a> {
16981679 FoundDeclaration :: InterfaceObject ( value) => value. ident . decl ,
16991680 FoundDeclaration :: ForIndex ( ident, _) => ident. decl ,
17001681 FoundDeclaration :: ForGenerateIndex ( _, value) => value. index_name . decl ,
1701- FoundDeclaration :: Function ( value) => value. designator . decl ,
1702- FoundDeclaration :: Procedure ( value) => value. designator . decl ,
1682+ FoundDeclaration :: Subprogram ( value) => value. specification . ent_id ( ) ,
1683+ FoundDeclaration :: SubprogramDecl ( value) => value. ent_id ( ) ,
17031684 FoundDeclaration :: SubprogramInstantiation ( value) => value. ident . decl ,
17041685 FoundDeclaration :: Object ( value) => value. ident . decl ,
17051686 FoundDeclaration :: ElementDeclaration ( elem) => elem. ident . decl ,
@@ -1734,9 +1715,9 @@ impl<'a> HasSrcPos for FoundDeclaration<'a> {
17341715 FoundDeclaration :: InterfaceObject ( value) => value. ident . pos ( ) ,
17351716 FoundDeclaration :: ForIndex ( ident, _) => ident. pos ( ) ,
17361717 FoundDeclaration :: ForGenerateIndex ( _, value) => value. index_name . pos ( ) ,
1737- FoundDeclaration :: Function ( value) => & value. designator . tree . pos ,
1718+ FoundDeclaration :: Subprogram ( value) => & value. specification . subpgm_designator ( ) . pos ,
1719+ FoundDeclaration :: SubprogramDecl ( value) => & value. subpgm_designator ( ) . pos ,
17381720 FoundDeclaration :: SubprogramInstantiation ( value) => & value. ident . tree . pos ,
1739- FoundDeclaration :: Procedure ( value) => & value. designator . tree . pos ,
17401721 FoundDeclaration :: Object ( value) => value. ident . pos ( ) ,
17411722 FoundDeclaration :: ElementDeclaration ( elem) => elem. ident . pos ( ) ,
17421723 FoundDeclaration :: EnumerationLiteral ( _, elem) => & elem. tree . pos ,
@@ -1779,13 +1760,13 @@ impl std::fmt::Display for FoundDeclaration<'_> {
17791760 Some ( ident) => write ! ( f, "{ident}: {value}" ) ,
17801761 None => write ! ( f, "{value}" ) ,
17811762 } ,
1782- FoundDeclaration :: Function ( ref value) => {
1783- write ! ( f, "{value };" )
1763+ FoundDeclaration :: Subprogram ( ref value) => {
1764+ write ! ( f, "{};" , value . specification )
17841765 }
1785- FoundDeclaration :: SubprogramInstantiation ( ref value) => {
1766+ FoundDeclaration :: SubprogramDecl ( ref value) => {
17861767 write ! ( f, "{value};" )
17871768 }
1788- FoundDeclaration :: Procedure ( ref value) => {
1769+ FoundDeclaration :: SubprogramInstantiation ( ref value) => {
17891770 write ! ( f, "{value};" )
17901771 }
17911772 FoundDeclaration :: Object ( ref value) => {
0 commit comments