@@ -22,74 +22,3 @@ export function findAll(str: string, search: string): number[] {
2222 }
2323 return result ;
2424}
25-
26- export function findAllInputsInElWithTag ( html : string , name : string , tagNames : string [ ] ) : number [ ] {
27- return findAllIoInElWithTag ( html , name , tagNames , String . raw `\[?` , String . raw `\]?` ) ;
28- }
29-
30- export function findAllOutputsInElWithTag ( html : string , name : string , tagNames : string [ ] ) :
31- number [ ] {
32- return findAllIoInElWithTag ( html , name , tagNames , String . raw `\(` , String . raw `\)` ) ;
33- }
34-
35- /**
36- * Method that can be used to rename all occurrences of an `@Input()` in a HTML string that occur
37- * inside an element with any of the given attributes. This is useful for replacing an `@Input()` on
38- * a `@Directive()` with an attribute selector.
39- */
40- export function findAllInputsInElWithAttr ( html : string , name : string , attrs : string [ ] ) : number [ ] {
41- return findAllIoInElWithAttr ( html , name , attrs , String . raw `\[?` , String . raw `\]?` ) ;
42- }
43-
44- /**
45- * Method that can be used to rename all occurrences of an `@Output()` in a HTML string that occur
46- * inside an element with any of the given attributes. This is useful for replacing an `@Output()`
47- * on a `@Directive()` with an attribute selector.
48- */
49- export function findAllOutputsInElWithAttr ( html : string , name : string , attrs : string [ ] ) : number [ ] {
50- return findAllIoInElWithAttr ( html , name , attrs , String . raw `\(` , String . raw `\)` ) ;
51- }
52-
53- function findAllIoInElWithTag ( html : string , name : string , tagNames : string [ ] ,
54- startIoPattern : string , endIoPattern : string ) : number [ ] {
55-
56- const skipPattern = String . raw `[^>]*\s` ;
57- const openTagPattern = String . raw `<\s*` ;
58- const tagNamesPattern = String . raw `(?:${ tagNames . join ( '|' ) } )` ;
59- const replaceIoPattern = String . raw `
60- (${ openTagPattern } ${ tagNamesPattern } \s(?:${ skipPattern } )?${ startIoPattern } )
61- ${ name }
62- ${ endIoPattern } [=\s>]` ;
63- const replaceIoRegex = new RegExp ( replaceIoPattern . replace ( / \s / g, '' ) , 'g' ) ;
64- const result : number [ ] = [ ] ;
65-
66- let match ;
67- while ( match = replaceIoRegex . exec ( html ) ) {
68- result . push ( match . index + match [ 1 ] . length ) ;
69- }
70-
71- return result ;
72- }
73-
74- function findAllIoInElWithAttr ( html : string , name : string , attrs : string [ ] , startIoPattern : string ,
75- endIoPattern : string ) : number [ ] {
76- const skipPattern = String . raw `[^>]*\s` ;
77- const openTagPattern = String . raw `<\s*\S` ;
78- const attrsPattern = String . raw `(?:${ attrs . join ( '|' ) } )` ;
79- const inputAfterAttrPattern = String . raw `
80- (${ openTagPattern } ${ skipPattern } ${ attrsPattern } [=\s](?:${ skipPattern } )?${ startIoPattern } )
81- ${ name }
82- ${ endIoPattern } [=\s>]` ;
83- const inputBeforeAttrPattern = String . raw `
84- (${ openTagPattern } ${ skipPattern } ${ startIoPattern } )
85- ${ name }
86- ${ endIoPattern } [=\s](?:${ skipPattern } )?${ attrsPattern } [=\s>]` ;
87- const replaceIoPattern = String . raw `${ inputAfterAttrPattern } |${ inputBeforeAttrPattern } ` ;
88- const replaceIoRegex = new RegExp ( replaceIoPattern . replace ( / \s / g, '' ) , 'g' ) ;
89- const result = [ ] ;
90- let match ;
91- while ( match = replaceIoRegex . exec ( html ) ) {
92- result . push ( match . index + ( match [ 1 ] || match [ 2 ] ) . length ) ;
93- }
94- return result ;
95- }
0 commit comments