@@ -47,6 +47,8 @@ pub enum FoundDeclaration<'a> {
4747 InterfaceObject ( & ' a InterfaceObjectDeclaration ) ,
4848 File ( & ' a FileDeclaration ) ,
4949 Type ( & ' a TypeDeclaration ) ,
50+ PhysicalTypePrimary ( & ' a WithDecl < Ident > ) ,
51+ PhysicalTypeSecondary ( & ' a WithDecl < Ident > , & ' a PhysicalLiteral ) ,
5052 Component ( & ' a ComponentDeclaration ) ,
5153 //Attribute(&'a AttributeDeclaration),
5254 Alias ( & ' a AliasDeclaration ) ,
@@ -750,11 +752,22 @@ impl Search for TypeDeclaration {
750752 . or_not_found( ) ) ;
751753 }
752754 }
753- // @TODO others
754- _ => {
755+ TypeDefinition :: Physical ( ref physical) => {
756+ let PhysicalTypeDeclaration {
757+ range,
758+ primary_unit,
759+ secondary_units,
760+ } = physical;
761+ return_if_found ! ( range. search( searcher) ) ;
755762 return_if_found ! ( searcher
756- . search_decl( FoundDeclaration :: Type ( self ) )
763+ . search_decl( FoundDeclaration :: PhysicalTypePrimary ( primary_unit ) )
757764 . or_not_found( ) ) ;
765+ for ( ident, literal) in secondary_units. iter ( ) {
766+ return_if_found ! ( searcher
767+ . search_decl( FoundDeclaration :: PhysicalTypeSecondary ( ident, literal) )
768+ . or_not_found( ) ) ;
769+ return_if_found ! ( searcher. search_ident_ref( & literal. unit) . or_not_found( ) ) ;
770+ }
758771 }
759772 }
760773 NotFound
@@ -779,7 +792,12 @@ fn search_pos_expr(pos: &SrcPos, expr: &Expression, searcher: &mut impl Searcher
779792 Allocator :: Subtype ( ref subtype) => subtype. search ( searcher) ,
780793 }
781794 }
782- Expression :: Literal ( _) => NotFound ,
795+ Expression :: Literal ( literal) => match literal {
796+ Literal :: Physical ( PhysicalLiteral { unit, .. } ) => {
797+ searcher. search_ident_ref ( unit) . or_not_found ( )
798+ }
799+ _ => NotFound ,
800+ } ,
783801 }
784802}
785803
@@ -1329,6 +1347,8 @@ impl<'a> HasNamedEntity for FoundDeclaration<'a> {
13291347 FoundDeclaration :: EnumerationLiteral ( _, elem) => elem. decl . as_ref ( ) ,
13301348 FoundDeclaration :: File ( value) => value. ident . decl . as_ref ( ) ,
13311349 FoundDeclaration :: Type ( value) => value. ident . decl . as_ref ( ) ,
1350+ FoundDeclaration :: PhysicalTypePrimary ( value) => value. decl . as_ref ( ) ,
1351+ FoundDeclaration :: PhysicalTypeSecondary ( value, _) => value. decl . as_ref ( ) ,
13321352 FoundDeclaration :: Component ( value) => value. ident . decl . as_ref ( ) ,
13331353 FoundDeclaration :: Alias ( value) => value. designator . decl . as_ref ( ) ,
13341354 FoundDeclaration :: Package ( value) => value. ident . decl . as_ref ( ) ,
@@ -1357,6 +1377,8 @@ impl<'a> HasSrcPos for FoundDeclaration<'a> {
13571377 FoundDeclaration :: EnumerationLiteral ( _, elem) => & elem. tree . pos ,
13581378 FoundDeclaration :: File ( value) => value. ident . pos ( ) ,
13591379 FoundDeclaration :: Type ( value) => value. ident . pos ( ) ,
1380+ FoundDeclaration :: PhysicalTypePrimary ( value) => value. pos ( ) ,
1381+ FoundDeclaration :: PhysicalTypeSecondary ( value, _) => value. as_ref ( ) ,
13601382 FoundDeclaration :: Component ( value) => value. ident . pos ( ) ,
13611383 FoundDeclaration :: Alias ( value) => & value. designator . tree . pos ,
13621384 FoundDeclaration :: Package ( value) => value. ident . pos ( ) ,
@@ -1407,6 +1429,12 @@ impl std::fmt::Display for FoundDeclaration<'_> {
14071429 FoundDeclaration :: File ( ref value) => {
14081430 write ! ( f, "{}" , value)
14091431 }
1432+ FoundDeclaration :: PhysicalTypePrimary ( ref value) => {
1433+ write ! ( f, "{}" , value)
1434+ }
1435+ FoundDeclaration :: PhysicalTypeSecondary ( _, ref literal) => {
1436+ write ! ( f, "{}" , literal)
1437+ }
14101438 FoundDeclaration :: Type ( ref value) => {
14111439 write ! ( f, "{}" , value)
14121440 }
0 commit comments