OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library visitor; | 5 library visitor; |
6 | 6 |
7 import '../closure.dart' | 7 import '../closure.dart' |
8 show BoxFieldElement, ClosureClassElement, ClosureFieldElement; | 8 show BoxFieldElement, ClosureClassElement, ClosureFieldElement; |
9 import 'elements.dart'; | 9 import 'elements.dart'; |
10 | 10 |
11 abstract class ElementVisitor<R, A> { | 11 abstract class ElementVisitor<R, A> { |
12 const ElementVisitor(); | 12 const ElementVisitor(); |
13 | 13 |
14 R visit(Element e, A arg) => e.accept(this, arg); | 14 R visit(covariant Element e, covariant A arg) => e.accept(this, arg); |
15 | 15 |
16 R visitErroneousElement(ErroneousElement e, A arg) => null; | 16 R visitErroneousElement(covariant ErroneousElement e, covariant A arg) => |
17 R visitWarnOnUseElement(WarnOnUseElement e, A arg) => null; | 17 null; |
18 R visitAmbiguousElement(AmbiguousElement e, A arg) => null; | 18 R visitWarnOnUseElement(covariant WarnOnUseElement e, covariant A arg) => |
19 R visitCompilationUnitElement(CompilationUnitElement e, A arg) => null; | 19 null; |
20 R visitLibraryElement(LibraryElement e, A arg) => null; | 20 R visitAmbiguousElement(covariant AmbiguousElement e, covariant A arg) => |
21 R visitImportElement(ImportElement e, A arg) => null; | 21 null; |
22 R visitExportElement(ExportElement e, A arg) => null; | 22 R visitCompilationUnitElement( |
23 R visitPrefixElement(PrefixElement e, A arg) => null; | 23 covariant CompilationUnitElement e, covariant A arg) => |
24 R visitTypedefElement(TypedefElement e, A arg) => null; | 24 null; |
25 R visitLocalVariableElement(LocalVariableElement e, A arg) => null; | 25 R visitLibraryElement(covariant LibraryElement e, covariant A arg) => null; |
26 R visitParameterElement(ParameterElement e, A arg) => null; | 26 R visitImportElement(covariant ImportElement e, covariant A arg) => null; |
27 R visitFormalElement(FormalElement e, A arg) => null; | 27 R visitExportElement(covariant ExportElement e, covariant A arg) => null; |
28 R visitFieldElement(FieldElement e, A arg) => null; | 28 R visitPrefixElement(covariant PrefixElement e, covariant A arg) => null; |
29 R visitFieldParameterElement(InitializingFormalElement e, A arg) => null; | 29 R visitTypedefElement(covariant TypedefElement e, covariant A arg) => null; |
30 R visitAbstractFieldElement(AbstractFieldElement e, A arg) => null; | 30 R visitLocalVariableElement( |
31 R visitMethodElement(FunctionElement e, A arg) => null; | 31 covariant LocalVariableElement e, covariant A arg) => |
32 R visitGetterElement(GetterElement e, A arg) => null; | 32 null; |
33 R visitSetterElement(SetterElement e, A arg) => null; | 33 R visitParameterElement(covariant ParameterElement e, covariant A arg) => |
34 R visitLocalFunctionElement(LocalFunctionElement e, A arg) => null; | 34 null; |
35 R visitConstructorElement(ConstructorElement e, A arg) => null; | 35 R visitFormalElement(covariant FormalElement e, covariant A arg) => null; |
36 R visitConstructorBodyElement(ConstructorBodyElement e, A arg) => null; | 36 R visitFieldElement(covariant FieldElement e, covariant A arg) => null; |
37 R visitClassElement(ClassElement e, A arg) => null; | 37 R visitFieldParameterElement( |
38 R visitMixinApplicationElement(MixinApplicationElement e, A arg) => null; | 38 covariant InitializingFormalElement e, covariant A arg) => |
39 R visitEnumClassElement(EnumClassElement e, A arg) => null; | 39 null; |
40 R visitTypeVariableElement(TypeVariableElement e, A arg) => null; | 40 R visitAbstractFieldElement( |
41 R visitBoxFieldElement(BoxFieldElement e, A arg) => null; | 41 covariant AbstractFieldElement e, covariant A arg) => |
42 R visitClosureClassElement(ClosureClassElement e, A arg) => null; | 42 null; |
43 R visitClosureFieldElement(ClosureFieldElement e, A arg) => null; | 43 R visitMethodElement(covariant MethodElement e, covariant A arg) => null; |
| 44 R visitGetterElement(covariant GetterElement e, covariant A arg) => null; |
| 45 R visitSetterElement(covariant SetterElement e, covariant A arg) => null; |
| 46 R visitLocalFunctionElement( |
| 47 covariant LocalFunctionElement e, covariant A arg) => |
| 48 null; |
| 49 R visitConstructorElement(covariant ConstructorElement e, covariant A arg) => |
| 50 null; |
| 51 R visitConstructorBodyElement( |
| 52 covariant ConstructorBodyElement e, covariant A arg) => |
| 53 null; |
| 54 R visitClassElement(covariant ClassElement e, covariant A arg) => null; |
| 55 R visitMixinApplicationElement( |
| 56 covariant MixinApplicationElement e, covariant A arg) => |
| 57 null; |
| 58 R visitEnumClassElement(covariant EnumClassElement e, covariant A arg) => |
| 59 null; |
| 60 R visitTypeVariableElement( |
| 61 covariant TypeVariableElement e, covariant A arg) => |
| 62 null; |
| 63 R visitBoxFieldElement(covariant BoxFieldElement e, covariant A arg) => null; |
| 64 R visitClosureClassElement( |
| 65 covariant ClosureClassElement e, covariant A arg) => |
| 66 null; |
| 67 R visitClosureFieldElement( |
| 68 covariant ClosureFieldElement e, covariant A arg) => |
| 69 null; |
44 } | 70 } |
45 | 71 |
46 abstract class BaseElementVisitor<R, A> extends ElementVisitor<R, A> { | 72 abstract class BaseElementVisitor<R, A> extends ElementVisitor<R, A> { |
47 const BaseElementVisitor(); | 73 const BaseElementVisitor(); |
48 | 74 |
49 R visitElement(Element e, A arg); | 75 R visitElement(covariant Element e, covariant A arg); |
50 | 76 |
51 @override | 77 @override |
52 R visitErroneousElement(ErroneousElement e, A arg) { | 78 R visitErroneousElement(covariant ErroneousElement e, covariant A arg) { |
53 return visitElement(e, arg); | 79 return visitElement(e, arg); |
54 } | 80 } |
55 | 81 |
56 @override | 82 @override |
57 R visitWarnOnUseElement(WarnOnUseElement e, A arg) { | 83 R visitWarnOnUseElement(covariant WarnOnUseElement e, covariant A arg) { |
58 return visitElement(e, arg); | 84 return visitElement(e, arg); |
59 } | 85 } |
60 | 86 |
61 @override | 87 @override |
62 R visitAmbiguousElement(AmbiguousElement e, A arg) { | 88 R visitAmbiguousElement(covariant AmbiguousElement e, covariant A arg) { |
63 return visitElement(e, arg); | 89 return visitElement(e, arg); |
64 } | 90 } |
65 | 91 |
66 R visitScopeContainerElement(ScopeContainerElement e, A arg) { | 92 R visitScopeContainerElement( |
67 return visitElement(e, arg); | 93 covariant ScopeContainerElement e, covariant A arg) { |
68 } | 94 return visitElement(e, arg); |
69 | 95 } |
70 @override | 96 |
71 R visitCompilationUnitElement(CompilationUnitElement e, A arg) { | 97 @override |
72 return visitElement(e, arg); | 98 R visitCompilationUnitElement( |
73 } | 99 covariant CompilationUnitElement e, covariant A arg) { |
74 | 100 return visitElement(e, arg); |
75 @override | 101 } |
76 R visitLibraryElement(LibraryElement e, A arg) { | 102 |
| 103 @override |
| 104 R visitLibraryElement(covariant LibraryElement e, covariant A arg) { |
77 return visitScopeContainerElement(e, arg); | 105 return visitScopeContainerElement(e, arg); |
78 } | 106 } |
79 | 107 |
80 @override | 108 @override |
81 R visitImportElement(ImportElement e, A arg) { | 109 R visitImportElement(covariant ImportElement e, covariant A arg) { |
82 return visitElement(e, arg); | 110 return visitElement(e, arg); |
83 } | 111 } |
84 | 112 |
85 @override | 113 @override |
86 R visitExportElement(ExportElement e, A arg) { | 114 R visitExportElement(covariant ExportElement e, covariant A arg) { |
87 return visitElement(e, arg); | 115 return visitElement(e, arg); |
88 } | 116 } |
89 | 117 |
90 @override | 118 @override |
91 R visitPrefixElement(PrefixElement e, A arg) { | 119 R visitPrefixElement(covariant PrefixElement e, covariant A arg) { |
92 return visitElement(e, arg); | 120 return visitElement(e, arg); |
93 } | 121 } |
94 | 122 |
95 @override | 123 @override |
96 R visitTypedefElement(TypedefElement e, A arg) { | 124 R visitTypedefElement(covariant TypedefElement e, covariant A arg) { |
97 return visitElement(e, arg); | 125 return visitElement(e, arg); |
98 } | 126 } |
99 | 127 |
100 R visitVariableElement(VariableElement e, A arg) { | 128 R visitVariableElement(covariant VariableElement e, covariant A arg) { |
101 return visitElement(e, arg); | 129 return visitElement(e, arg); |
102 } | 130 } |
103 | 131 |
104 @override | 132 @override |
105 R visitLocalVariableElement(LocalVariableElement e, A arg) { | 133 R visitLocalVariableElement( |
106 return visitVariableElement(e, arg); | 134 covariant LocalVariableElement e, covariant A arg) { |
107 } | 135 return visitVariableElement(e, arg); |
108 | 136 } |
109 @override | 137 |
110 R visitParameterElement(ParameterElement e, A arg) { | 138 @override |
111 return visitVariableElement(e, arg); | 139 R visitParameterElement(covariant ParameterElement e, covariant A arg) { |
112 } | 140 return visitVariableElement(e, arg); |
113 | 141 } |
114 @override | 142 |
115 R visitFormalElement(FormalElement e, A arg) { | 143 @override |
116 return visitElement(e, arg); | 144 R visitFormalElement(covariant FormalElement e, covariant A arg) { |
117 } | 145 return visitElement(e, arg); |
118 | 146 } |
119 @override | 147 |
120 R visitFieldElement(FieldElement e, A arg) { | 148 @override |
121 return visitVariableElement(e, arg); | 149 R visitFieldElement(covariant FieldElement e, covariant A arg) { |
122 } | 150 return visitVariableElement(e, arg); |
123 | 151 } |
124 @override | 152 |
125 R visitFieldParameterElement(InitializingFormalElement e, A arg) { | 153 @override |
| 154 R visitFieldParameterElement( |
| 155 covariant InitializingFormalElement e, covariant A arg) { |
126 return visitParameterElement(e, arg); | 156 return visitParameterElement(e, arg); |
127 } | 157 } |
128 | 158 |
129 @override | 159 @override |
130 R visitAbstractFieldElement(AbstractFieldElement e, A arg) { | 160 R visitAbstractFieldElement( |
131 return visitElement(e, arg); | 161 covariant AbstractFieldElement e, covariant A arg) { |
132 } | 162 return visitElement(e, arg); |
133 | 163 } |
134 R visitFunctionElement(FunctionElement e, A arg) { | 164 |
135 return visitElement(e, arg); | 165 R visitFunctionElement(covariant FunctionElement e, covariant A arg) { |
136 } | 166 return visitElement(e, arg); |
137 | 167 } |
138 @override | 168 |
139 R visitMethodElement(MethodElement e, A arg) { | 169 @override |
140 return visitFunctionElement(e, arg); | 170 R visitMethodElement(covariant MethodElement e, covariant A arg) { |
141 } | 171 return visitFunctionElement(e, arg); |
142 | 172 } |
143 @override | 173 |
144 R visitGetterElement(GetterElement e, A arg) { | 174 @override |
145 return visitFunctionElement(e, arg); | 175 R visitGetterElement(covariant GetterElement e, covariant A arg) { |
146 } | 176 return visitFunctionElement(e, arg); |
147 | 177 } |
148 @override | 178 |
149 R visitSetterElement(SetterElement e, A arg) { | 179 @override |
150 return visitFunctionElement(e, arg); | 180 R visitSetterElement(covariant SetterElement e, covariant A arg) { |
151 } | 181 return visitFunctionElement(e, arg); |
152 | 182 } |
153 @override | 183 |
154 R visitLocalFunctionElement(LocalFunctionElement e, A arg) { | 184 @override |
155 return visitFunctionElement(e, arg); | 185 R visitLocalFunctionElement( |
156 } | 186 covariant LocalFunctionElement e, covariant A arg) { |
157 | 187 return visitFunctionElement(e, arg); |
158 @override | 188 } |
159 R visitConstructorElement(ConstructorElement e, A arg) { | 189 |
160 return visitFunctionElement(e, arg); | 190 @override |
161 } | 191 R visitConstructorElement(covariant ConstructorElement e, covariant A arg) { |
162 | 192 return visitFunctionElement(e, arg); |
163 @override | 193 } |
164 R visitConstructorBodyElement(ConstructorBodyElement e, A arg) { | 194 |
165 return visitElement(e, arg); | 195 @override |
166 } | 196 R visitConstructorBodyElement( |
167 | 197 covariant ConstructorBodyElement e, covariant A arg) { |
168 @override | 198 return visitElement(e, arg); |
169 R visitClassElement(ClassElement e, A arg) { | 199 } |
| 200 |
| 201 @override |
| 202 R visitClassElement(covariant ClassElement e, covariant A arg) { |
170 return visitScopeContainerElement(e, arg); | 203 return visitScopeContainerElement(e, arg); |
171 } | 204 } |
172 | 205 |
173 R visitTypeDeclarationElement(TypeDeclarationElement e, A arg) { | 206 R visitTypeDeclarationElement( |
174 return visitElement(e, arg); | 207 covariant TypeDeclarationElement e, covariant A arg) { |
175 } | 208 return visitElement(e, arg); |
176 | 209 } |
177 @override | 210 |
178 R visitMixinApplicationElement(MixinApplicationElement e, A arg) { | 211 @override |
| 212 R visitMixinApplicationElement( |
| 213 covariant MixinApplicationElement e, covariant A arg) { |
179 return visitClassElement(e, arg); | 214 return visitClassElement(e, arg); |
180 } | 215 } |
181 | 216 |
182 @override | 217 @override |
183 R visitEnumClassElement(EnumClassElement e, A arg) { | 218 R visitEnumClassElement(covariant EnumClassElement e, covariant A arg) { |
184 return visitClassElement(e, arg); | 219 return visitClassElement(e, arg); |
185 } | 220 } |
186 | 221 |
187 @override | 222 @override |
188 R visitTypeVariableElement(TypeVariableElement e, A arg) { | 223 R visitTypeVariableElement(covariant TypeVariableElement e, covariant A arg) { |
189 return visitElement(e, arg); | 224 return visitElement(e, arg); |
190 } | 225 } |
191 | 226 |
192 @override | 227 @override |
193 R visitBoxFieldElement(BoxFieldElement e, A arg) { | 228 R visitBoxFieldElement(covariant BoxFieldElement e, covariant A arg) { |
194 return visitElement(e, arg); | 229 return visitElement(e, arg); |
195 } | 230 } |
196 | 231 |
197 @override | 232 @override |
198 R visitClosureClassElement(ClosureClassElement e, A arg) { | 233 R visitClosureClassElement(covariant ClosureClassElement e, covariant A arg) { |
199 return visitClassElement(e, arg); | 234 return visitClassElement(e, arg); |
200 } | 235 } |
201 | 236 |
202 @override | 237 @override |
203 R visitClosureFieldElement(ClosureFieldElement e, A arg) { | 238 R visitClosureFieldElement(covariant ClosureFieldElement e, covariant A arg) { |
204 return visitVariableElement(e, arg); | 239 return visitVariableElement(e, arg); |
205 } | 240 } |
206 } | 241 } |
OLD | NEW |