@@ -149,6 +149,31 @@ export namespace RegExpValidator {
149149 */
150150 onLiteralLeave ?: ( start : number , end : number ) => void
151151
152+ /**
153+ * A function that is called when the validator found flags.
154+ * @param start The 0-based index of the first character.
155+ * @param end The next 0-based index of the last character.
156+ * @param flags.global `g` flag.
157+ * @param flags.ignoreCase `i` flag.
158+ * @param flags.multiline `m` flag.
159+ * @param flags.unicode `u` flag.
160+ * @param flags.sticky `y` flag.
161+ * @param flags.dotAll `s` flag.
162+ * @param flags.hasIndices `d` flag.
163+ */
164+ onRegExpFlags ?: (
165+ start : number ,
166+ end : number ,
167+ flags : {
168+ global : boolean
169+ ignoreCase : boolean
170+ multiline : boolean
171+ unicode : boolean
172+ sticky : boolean
173+ dotAll : boolean
174+ hasIndices : boolean
175+ } ,
176+ ) => void
152177 /**
153178 * A function that is called when the validator found flags.
154179 * @param start The 0-based index of the first character.
@@ -160,6 +185,8 @@ export namespace RegExpValidator {
160185 * @param sticky `y` flag.
161186 * @param dotAll `s` flag.
162187 * @param hasIndices `d` flag.
188+ *
189+ * @deprecated Use `onRegExpFlags` instead.
163190 */
164191 onFlags ?: (
165192 start : number ,
@@ -535,17 +562,15 @@ export class RegExpValidator {
535562 this . raise ( `Invalid flag '${ source [ i ] } '` )
536563 }
537564 }
538- this . onFlags (
539- start ,
540- end ,
565+ this . onRegExpFlags ( start , end , {
541566 global,
542567 ignoreCase,
543568 multiline,
544569 unicode,
545570 sticky,
546571 dotAll,
547572 hasIndices,
548- )
573+ } )
549574 }
550575
551576 /**
@@ -599,28 +624,34 @@ export class RegExpValidator {
599624 }
600625 }
601626
602- private onFlags (
627+ private onRegExpFlags (
603628 start : number ,
604629 end : number ,
605- global : boolean ,
606- ignoreCase : boolean ,
607- multiline : boolean ,
608- unicode : boolean ,
609- sticky : boolean ,
610- dotAll : boolean ,
611- hasIndices : boolean ,
630+ flags : {
631+ global : boolean
632+ ignoreCase : boolean
633+ multiline : boolean
634+ unicode : boolean
635+ sticky : boolean
636+ dotAll : boolean
637+ hasIndices : boolean
638+ } ,
612639 ) : void {
640+ if ( this . _options . onRegExpFlags ) {
641+ this . _options . onRegExpFlags ( start , end , flags )
642+ }
643+ // Backward compatibility
613644 if ( this . _options . onFlags ) {
614645 this . _options . onFlags (
615646 start ,
616647 end ,
617- global ,
618- ignoreCase ,
619- multiline ,
620- unicode ,
621- sticky ,
622- dotAll ,
623- hasIndices ,
648+ flags . global ,
649+ flags . ignoreCase ,
650+ flags . multiline ,
651+ flags . unicode ,
652+ flags . sticky ,
653+ flags . dotAll ,
654+ flags . hasIndices ,
624655 )
625656 }
626657 }
0 commit comments