@@ -131,14 +131,11 @@ export class TemplateBinding {
131131}
132132
133133export interface AstVisitor {
134- visitPropertyRead ( ast : PropertyRead ) : any ;
135- visitPropertyWrite ( ast : PropertyWrite ) : any ;
136134 visitBinary ( ast : Binary ) : any ;
137135 visitChain ( ast : Chain ) : any ;
138136 visitConditional ( ast : Conditional ) : any ;
139- visitIf ( ast : If ) : any ;
140- visitPipe ( ast : BindingPipe ) : any ;
141137 visitFunctionCall ( ast : FunctionCall ) : any ;
138+ visitIf ( ast : If ) : any ;
142139 visitImplicitReceiver ( ast : ImplicitReceiver ) : any ;
143140 visitInterpolation ( ast : Interpolation ) : any ;
144141 visitKeyedRead ( ast : KeyedRead ) : any ;
@@ -147,9 +144,88 @@ export interface AstVisitor {
147144 visitLiteralMap ( ast : LiteralMap ) : any ;
148145 visitLiteralPrimitive ( ast : LiteralPrimitive ) : any ;
149146 visitMethodCall ( ast : MethodCall ) : any ;
147+ visitPipe ( ast : BindingPipe ) : any ;
150148 visitPrefixNot ( ast : PrefixNot ) : any ;
151- visitSafePropertyRead ( ast : SafePropertyRead ) : any ;
149+ visitPropertyRead ( ast : PropertyRead ) : any ;
150+ visitPropertyWrite ( ast : PropertyWrite ) : any ;
152151 visitSafeMethodCall ( ast : SafeMethodCall ) : any ;
152+ visitSafePropertyRead ( ast : SafePropertyRead ) : any ;
153+ }
154+
155+ export class RecursiveAstVisitor implements AstVisitor {
156+ visitBinary ( ast : Binary ) : any {
157+ ast . left . visit ( this ) ;
158+ ast . right . visit ( this ) ;
159+ return null ;
160+ }
161+ visitChain ( ast : Chain ) : any { return this . visitAll ( ast . expressions ) ; }
162+ visitConditional ( ast : Conditional ) : any {
163+ ast . condition . visit ( this ) ;
164+ ast . trueExp . visit ( this ) ;
165+ ast . falseExp . visit ( this ) ;
166+ return null ;
167+ }
168+ visitIf ( ast : If ) : any {
169+ ast . condition . visit ( this ) ;
170+ ast . trueExp . visit ( this ) ;
171+ ast . falseExp . visit ( this ) ;
172+ return null ;
173+ }
174+ visitPipe ( ast : BindingPipe ) : any {
175+ ast . exp . visit ( this ) ;
176+ this . visitAll ( ast . args ) ;
177+ return null ;
178+ }
179+ visitFunctionCall ( ast : FunctionCall ) : any {
180+ ast . target . visit ( this ) ;
181+ this . visitAll ( ast . args ) ;
182+ return null ;
183+ }
184+ visitImplicitReceiver ( ast : ImplicitReceiver ) : any { return null ; }
185+ visitInterpolation ( ast : Interpolation ) : any { return this . visitAll ( ast . expressions ) ; }
186+ visitKeyedRead ( ast : KeyedRead ) : any {
187+ ast . obj . visit ( this ) ;
188+ ast . key . visit ( this ) ;
189+ return null ;
190+ }
191+ visitKeyedWrite ( ast : KeyedWrite ) : any {
192+ ast . obj . visit ( this ) ;
193+ ast . key . visit ( this ) ;
194+ ast . value . visit ( this ) ;
195+ return null ;
196+ }
197+ visitLiteralArray ( ast : LiteralArray ) : any { return this . visitAll ( ast . expressions ) ; }
198+ visitLiteralMap ( ast : LiteralMap ) : any { return this . visitAll ( ast . values ) ; }
199+ visitLiteralPrimitive ( ast : LiteralPrimitive ) : any { return null ; }
200+ visitMethodCall ( ast : MethodCall ) : any {
201+ ast . receiver . visit ( this ) ;
202+ return this . visitAll ( ast . args ) ;
203+ }
204+ visitPrefixNot ( ast : PrefixNot ) : any {
205+ ast . expression . visit ( this ) ;
206+ return null ;
207+ }
208+ visitPropertyRead ( ast : PropertyRead ) : any {
209+ ast . receiver . visit ( this ) ;
210+ return null ;
211+ }
212+ visitPropertyWrite ( ast : PropertyWrite ) : any {
213+ ast . receiver . visit ( this ) ;
214+ ast . value . visit ( this ) ;
215+ return null ;
216+ }
217+ visitSafePropertyRead ( ast : SafePropertyRead ) : any {
218+ ast . receiver . visit ( this ) ;
219+ return null ;
220+ }
221+ visitSafeMethodCall ( ast : SafeMethodCall ) : any {
222+ ast . receiver . visit ( this ) ;
223+ return this . visitAll ( ast . args ) ;
224+ }
225+ visitAll ( asts : List < AST > ) : any {
226+ ListWrapper . forEach ( asts , ( ast ) => { ast . visit ( this ) ; } ) ;
227+ return null ;
228+ }
153229}
154230
155231export class AstTransformer implements AstVisitor {
@@ -232,4 +308,4 @@ export class AstTransformer implements AstVisitor {
232308 let falseExp = isPresent ( ast . falseExp ) ? ast . falseExp . visit ( this ) : null ;
233309 return new If ( ast . condition . visit ( this ) , ast . trueExp . visit ( this ) , falseExp ) ;
234310 }
235- }
311+ }
0 commit comments