001 /*
002 * Copyright 2008 Google Inc.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005 * in compliance with the License. You may obtain a copy of the License at
006 *
007 * http://www.apache.org/licenses/LICENSE-2.0
008 *
009 * Unless required by applicable law or agreed to in writing, software distributed under the License
010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011 * or implied. See the License for the specific language governing permissions and limitations under
012 * the License.
013 */
014
015 package com.google.dart.compiler.backend.js.ast;
016
017 /**
018 * Taken from GWT project with modifications.
019 * Original:
020 * repository: https://gwt.googlesource.com/gwt
021 * revision: e32bf0a95029165d9e6ab457c7ee7ca8b07b908c
022 * file: dev/core/src/com/google/gwt/dev/js/ast/JsVisitor.java
023 */
024
025 import java.util.List;
026
027 /**
028 * Implemented by nodes that will visit child nodes.
029 */
030 @SuppressWarnings("UnusedParameters")
031 public abstract class JsVisitorWithContext {
032
033 public final <T extends JsNode> T accept(T node) {
034 return doAccept(node);
035 }
036
037 public JsExpression acceptLvalue(JsExpression expr) {
038 return doAcceptLvalue(expr);
039 }
040
041 public final <T extends JsNode> void acceptList(List<T> collection) {
042 doAcceptList(collection);
043 }
044
045 public final <T extends JsStatement> T acceptStatement(T statement) {
046 //noinspection unchecked
047 return (T) doAcceptStatement(statement);
048 }
049
050 public final <T extends JsStatement> void acceptStatementList(List<T> statements) {
051 doAcceptStatementList(statements);
052 }
053
054 public void endVisit(JsArrayAccess x, JsContext ctx) {
055 }
056
057 public void endVisit(JsArrayLiteral x, JsContext ctx) {
058 }
059
060 public void endVisit(JsBinaryOperation x, JsContext ctx) {
061 }
062
063 public void endVisit(JsBlock x, JsContext ctx) {
064 }
065
066 public void endVisit(JsLiteral.JsBooleanLiteral x, JsContext ctx) {
067 }
068
069 public void endVisit(JsBreak x, JsContext ctx) {
070 }
071
072 public void endVisit(JsCase x, JsContext ctx) {
073 }
074
075 public void endVisit(JsCatch x, JsContext ctx) {
076 }
077
078 public void endVisit(JsConditional x, JsContext ctx) {
079 }
080
081 public void endVisit(JsContinue x, JsContext ctx) {
082 }
083
084 public void endVisit(JsDebugger x, JsContext ctx) {
085 }
086
087 public void endVisit(JsDefault x, JsContext ctx) {
088 }
089
090 public void endVisit(JsDoWhile x, JsContext ctx) {
091 }
092
093 public void endVisit(JsEmpty x, JsContext ctx) {
094 }
095
096 public void endVisit(JsExpressionStatement x, JsContext ctx) {
097 }
098
099 public void endVisit(JsFor x, JsContext ctx) {
100 }
101
102 public void endVisit(JsForIn x, JsContext ctx) {
103 }
104
105 public void endVisit(JsFunction x, JsContext ctx) {
106 }
107
108 public void endVisit(JsIf x, JsContext ctx) {
109 }
110
111 public void endVisit(JsInvocation x, JsContext ctx) {
112 }
113
114 public void endVisit(JsLabel x, JsContext ctx) {
115 }
116
117 public void endVisit(JsName x, JsContext ctx) {
118 }
119
120 public void endVisit(JsNameRef x, JsContext ctx) {
121 }
122
123 public void endVisit(JsNew x, JsContext ctx) {
124 }
125
126 public void endVisit(JsNullLiteral x, JsContext ctx) {
127 }
128
129 public void endVisit(JsNumberLiteral x, JsContext ctx) {
130 }
131
132 public void endVisit(JsObjectLiteral x, JsContext ctx) {
133 }
134
135 public void endVisit(JsParameter x, JsContext ctx) {
136 }
137
138 public void endVisit(JsPostfixOperation x, JsContext ctx) {
139 }
140
141 public void endVisit(JsPrefixOperation x, JsContext ctx) {
142 }
143
144 public void endVisit(JsProgram x, JsContext ctx) {
145 }
146
147 public void endVisit(JsProgramFragment x, JsContext ctx) {
148 }
149
150 public void endVisit(JsPropertyInitializer x, JsContext ctx) {
151 }
152
153 public void endVisit(JsRegExp x, JsContext ctx) {
154 }
155
156 public void endVisit(JsReturn x, JsContext ctx) {
157 }
158
159 public void endVisit(JsStringLiteral x, JsContext ctx) {
160 }
161
162 public void endVisit(JsSwitch x, JsContext ctx) {
163 }
164
165 public void endVisit(JsLiteral.JsThisRef x, JsContext ctx) {
166 }
167
168 public void endVisit(JsThrow x, JsContext ctx) {
169 }
170
171 public void endVisit(JsTry x, JsContext ctx) {
172 }
173
174 public void endVisit(JsVars.JsVar x, JsContext ctx) {
175 }
176
177 public void endVisit(JsVars x, JsContext ctx) {
178 }
179
180 public void endVisit(JsWhile x, JsContext ctx) {
181 }
182
183 public boolean visit(JsArrayAccess x, JsContext ctx) {
184 return true;
185 }
186
187 public boolean visit(JsArrayLiteral x, JsContext ctx) {
188 return true;
189 }
190
191 public boolean visit(JsBinaryOperation x, JsContext ctx) {
192 return true;
193 }
194
195 public boolean visit(JsBlock x, JsContext ctx) {
196 return true;
197 }
198
199 public boolean visit(JsLiteral.JsBooleanLiteral x, JsContext ctx) {
200 return true;
201 }
202
203 public boolean visit(JsBreak x, JsContext ctx) {
204 return true;
205 }
206
207 public boolean visit(JsCase x, JsContext ctx) {
208 return true;
209 }
210
211 public boolean visit(JsCatch x, JsContext ctx) {
212 return true;
213 }
214
215 public boolean visit(JsConditional x, JsContext ctx) {
216 return true;
217 }
218
219 public boolean visit(JsContinue x, JsContext ctx) {
220 return true;
221 }
222
223 public boolean visit(JsDebugger x, JsContext ctx) {
224 return true;
225 }
226
227 public boolean visit(JsDefault x, JsContext ctx) {
228 return true;
229 }
230
231 public boolean visit(JsDoWhile x, JsContext ctx) {
232 return true;
233 }
234
235 public boolean visit(JsEmpty x, JsContext ctx) {
236 return true;
237 }
238
239 public boolean visit(JsExpressionStatement x, JsContext ctx) {
240 return true;
241 }
242
243 public boolean visit(JsFor x, JsContext ctx) {
244 return true;
245 }
246
247 public boolean visit(JsForIn x, JsContext ctx) {
248 return true;
249 }
250
251 public boolean visit(JsFunction x, JsContext ctx) {
252 return true;
253 }
254
255 public boolean visit(JsIf x, JsContext ctx) {
256 return true;
257 }
258
259 public boolean visit(JsInvocation x, JsContext ctx) {
260 return true;
261 }
262
263 public boolean visit(JsLabel x, JsContext ctx) {
264 return true;
265 }
266
267 public boolean visit(JsName x, JsContext ctx) {
268 return true;
269 }
270
271 public boolean visit(JsNameRef x, JsContext ctx) {
272 return true;
273 }
274
275 public boolean visit(JsNew x, JsContext ctx) {
276 return true;
277 }
278
279 public boolean visit(JsNullLiteral x, JsContext ctx) {
280 return true;
281 }
282
283 public boolean visit(JsNumberLiteral x, JsContext ctx) {
284 return true;
285 }
286
287 public boolean visit(JsObjectLiteral x, JsContext ctx) {
288 return true;
289 }
290
291 public boolean visit(JsParameter x, JsContext ctx) {
292 return true;
293 }
294
295 public boolean visit(JsPostfixOperation x, JsContext ctx) {
296 return true;
297 }
298
299 public boolean visit(JsPrefixOperation x, JsContext ctx) {
300 return true;
301 }
302
303 public boolean visit(JsProgram x, JsContext ctx) {
304 return true;
305 }
306
307 public boolean visit(JsProgramFragment x, JsContext ctx) {
308 return true;
309 }
310
311 public boolean visit(JsPropertyInitializer x, JsContext ctx) {
312 return true;
313 }
314
315 public boolean visit(JsRegExp x, JsContext ctx) {
316 return true;
317 }
318
319 public boolean visit(JsReturn x, JsContext ctx) {
320 return true;
321 }
322
323 public boolean visit(JsStringLiteral x, JsContext ctx) {
324 return true;
325 }
326
327 public boolean visit(JsSwitch x, JsContext ctx) {
328 return true;
329 }
330
331 public boolean visit(JsLiteral.JsThisRef x, JsContext ctx) {
332 return true;
333 }
334
335 public boolean visit(JsThrow x, JsContext ctx) {
336 return true;
337 }
338
339 public boolean visit(JsTry x, JsContext ctx) {
340 return true;
341 }
342
343 public boolean visit(JsVars.JsVar x, JsContext ctx) {
344 return true;
345 }
346
347 public boolean visit(JsVars x, JsContext ctx) {
348 return true;
349 }
350
351 public boolean visit(JsWhile x, JsContext ctx) {
352 return true;
353 }
354
355 protected abstract <T extends JsNode> T doAccept(T node);
356
357 protected abstract JsExpression doAcceptLvalue(JsExpression expr);
358
359 protected abstract <T extends JsNode> void doAcceptList(List<T> collection);
360
361 protected abstract <T extends JsStatement> JsStatement doAcceptStatement(T statement);
362
363 protected abstract <T extends JsStatement> void doAcceptStatementList(List<T> statements);
364
365 protected abstract <T extends JsNode> void doTraverse(T node, JsContext ctx) ;
366 }