@@ -80,8 +80,11 @@ const lineOf = (text: string, index: number): number => text.slice(0, index).spl
8080/** Extensions read as JS/TS source: their comments are blanked first, since a comment writes no row. */
8181const CODE_EXT = new Set ( [ '.ts' , '.mts' , '.cts' , '.js' , '.mjs' , '.cjs' ] ) ;
8282
83+ /** Cheap pre-filter: a file that never spells the key cannot hold a producer (and is never masked). */
84+ const SPELLS_RECIPIENT_KEY = / r e c i p i e n t _ ? [ t T ] y p e / ;
85+
8386const producersIn = ( ext : string , raw : string , live = 'guest' ) : number [ ] => {
84- if ( ! raw . includes ( live ) ) return [ ] ;
87+ if ( ! raw . includes ( live ) || ! SPELLS_RECIPIENT_KEY . test ( raw ) ) return [ ] ;
8588 // `maskComments` blanks comment content and keeps offsets and line numbers.
8689 const text = CODE_EXT . has ( ext ) ? maskComments ( raw ) : raw ;
8790 const out : number [ ] = [ ] ;
@@ -108,6 +111,7 @@ const literalsInBrackets = (text: string, open: number): string[] => {
108111
109112/** Leg 2: the options of the `recipient_type` select in a file that declares `sys_record_share`, or `null`. */
110113const recordShareSelectOptions = ( raw : string ) : string [ ] | null => {
114+ if ( ! raw . includes ( 'sys_record_share' ) || ! raw . includes ( 'recipient_type' ) ) return null ;
111115 const text = maskComments ( raw ) ;
112116 if ( ! / n a m e : \s * [ ' " ] s y s _ r e c o r d _ s h a r e [ ' " ] / . test ( text ) ) return null ;
113117 const at = text . search ( / r e c i p i e n t _ t y p e \s * : \s * F i e l d \. s e l e c t \( / ) ;
@@ -118,6 +122,7 @@ const recordShareSelectOptions = (raw: string): string[] | null => {
118122
119123/** Leg 3: the literal members of `RecordShareRecipientType`, or `null` when the file does not declare it. */
120124const unionMembers = ( raw : string ) : string [ ] | null => {
125+ if ( ! raw . includes ( 'RecordShareRecipientType' ) ) return null ;
121126 const m = / e x p o r t \s + t y p e \s + R e c o r d S h a r e R e c i p i e n t T y p e \s * = ( [ ^ ; ] * ) ; / . exec ( maskComments ( raw ) ) ;
122127 if ( ! m ) return null ;
123128 return [ ...m [ 1 ] ! . matchAll ( / ' ( [ ^ ' ] * ) ' / g) ] . map ( ( x ) => x [ 1 ] ! ) ;
0 commit comments