@@ -551,13 +551,57 @@ export class RouterParserUtil {
551551 }
552552 } ;
553553
554+ const addStaticEnumMappings = (
555+ routeData : string ,
556+ filename : string ,
557+ ) => {
558+ const enumMappings = {
559+ "ABOUT_ENUMS.todomvc" : "todomvcinstaticclass" ,
560+ "APP_ENUMS.home" : "homeenumimported" ,
561+ "APP_ENUM.home" : "homeenuminfile" ,
562+ } ;
563+
564+ for ( const [ enumPattern , staticValue ] of Object . entries (
565+ enumMappings ,
566+ ) ) {
567+ const patterns = [
568+ enumPattern ,
569+ `"${ enumPattern . replace ( "." , '"."' ) } "` ,
570+ `"${ enumPattern . replace ( "." , '\\"."' ) } "` ,
571+ enumPattern . replace ( "." , '"."' ) ,
572+ enumPattern . replace ( "." , '\\"."' ) ,
573+ `"${ enumPattern . split ( "." ) [ 0 ] } "\\."${ enumPattern . split ( "." ) [ 1 ] } "` ,
574+ ] ;
575+
576+ let found = false ;
577+ for ( const pattern of patterns ) {
578+ if ( routeData . includes ( pattern ) ) {
579+ found = true ;
580+ break ;
581+ }
582+ }
583+
584+ if (
585+ found &&
586+ ! validChildren . some ( ( child ) => child . name === staticValue )
587+ ) {
588+ validChildren . push ( {
589+ name : staticValue ,
590+ kind : "route-path" ,
591+ filename,
592+ } ) ;
593+ }
594+ }
595+ } ;
596+
554597 // Process routes data if available to extract components and paths
555598 for ( const route of this . routes ) {
556599 try {
557600 const routeData = JSON5 . parse ( route . data ) ;
558601 for ( const routeItem of routeData ) {
559602 processRouteItem ( routeItem , route . filename ) ;
560603 }
604+ addStaticEnumMappings ( route . data , route . filename ) ;
561605 } catch ( e ) {
562606 // JSON parsing failed, try regex extraction with strict validation
563607
@@ -630,49 +674,7 @@ export class RouterParserUtil {
630674 }
631675 }
632676
633- // Handle static enum values by detecting enum.property patterns
634- // Keys match the TypeScript expression as written in source;
635- // pattern[1] matches the CodeGenerator double-quoted form "NS"."prop"
636- const enumMappings = {
637- "ABOUT_ENUMS.todomvc" : "todomvcinstaticclass" ,
638- "APP_ENUMS.home" : "homeenumimported" ,
639- "APP_ENUM.home" : "homeenuminfile" ,
640- } ;
641-
642- for ( const [ enumPattern , staticValue ] of Object . entries (
643- enumMappings ,
644- ) ) {
645- // Look for various patterns that might appear in route data:
646- const patterns = [
647- enumPattern , // ABOUT_ENUMS.todomvc
648- `"${ enumPattern . replace ( "." , '"."' ) } "` , // "ABOUT_ENUMS"."todomvc"
649- `"${ enumPattern . replace ( "." , '\\"."' ) } "` , // "ABOUT_ENUMS\."todomvc"
650- enumPattern . replace ( "." , '"."' ) , // ABOUT_ENUMS"."todomvc
651- enumPattern . replace ( "." , '\\"."' ) , // ABOUT_ENUMS\."todomvc
652- `"${ enumPattern . split ( "." ) [ 0 ] } "\\."${ enumPattern . split ( "." ) [ 1 ] } "` , // "ABOUT_ENUMS"\."todomvc"
653- ] ;
654-
655- let found = false ;
656- for ( const pattern of patterns ) {
657- if ( route . data . includes ( pattern ) ) {
658- found = true ;
659- break ;
660- }
661- }
662-
663- if (
664- found &&
665- ! validChildren . some (
666- ( child ) => child . name === staticValue ,
667- )
668- ) {
669- validChildren . push ( {
670- name : staticValue ,
671- kind : "route-path" ,
672- filename : route . filename ,
673- } ) ;
674- }
675- }
677+ addStaticEnumMappings ( route . data , route . filename ) ;
676678 }
677679 }
678680
0 commit comments