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 part of tree; | 5 part of tree; |
6 | 6 |
7 abstract class Visitor<R> { | 7 abstract class Visitor<R> { |
8 const Visitor(); | 8 const Visitor(); |
9 | 9 |
10 R visitNode(Node node); | 10 R visitNode(Node node); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 * Returns Xml-like tree representation of this node. | 140 * Returns Xml-like tree representation of this node. |
141 */ | 141 */ |
142 toDebugString() { | 142 toDebugString() { |
143 return PrettyPrinter.prettyPrint(this); | 143 return PrettyPrinter.prettyPrint(this); |
144 } | 144 } |
145 | 145 |
146 String getObjectDescription() => super.toString(); | 146 String getObjectDescription() => super.toString(); |
147 | 147 |
148 Token getBeginToken(); | 148 Token getBeginToken(); |
149 | 149 |
| 150 /// Returns the token that ends the 'prefix' of this node. |
| 151 /// |
| 152 /// For instance the end of the parameters in a [FunctionExpression] or the |
| 153 /// last token before the start of a class body for a [ClassNode]. |
| 154 Token getPrefixEndToken() => getEndToken(); |
| 155 |
150 Token getEndToken(); | 156 Token getEndToken(); |
151 | 157 |
152 Assert asAssert() => null; | 158 Assert asAssert() => null; |
153 AsyncModifier asAsyncModifier() => null; | 159 AsyncModifier asAsyncModifier() => null; |
154 Await asAwait() => null; | 160 Await asAwait() => null; |
155 Block asBlock() => null; | 161 Block asBlock() => null; |
156 BreakStatement asBreakStatement() => null; | 162 BreakStatement asBreakStatement() => null; |
157 Cascade asCascade() => null; | 163 Cascade asCascade() => null; |
158 CascadeReceiver asCascadeReceiver() => null; | 164 CascadeReceiver asCascadeReceiver() => null; |
159 CaseMatch asCaseMatch() => null; | 165 CaseMatch asCaseMatch() => null; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 visitChildren(Visitor visitor) { | 262 visitChildren(Visitor visitor) { |
257 if (name != null) name.accept(visitor); | 263 if (name != null) name.accept(visitor); |
258 if (typeParameters != null) typeParameters.accept(visitor); | 264 if (typeParameters != null) typeParameters.accept(visitor); |
259 if (superclass != null) superclass.accept(visitor); | 265 if (superclass != null) superclass.accept(visitor); |
260 if (interfaces != null) interfaces.accept(visitor); | 266 if (interfaces != null) interfaces.accept(visitor); |
261 if (body != null) body.accept(visitor); | 267 if (body != null) body.accept(visitor); |
262 } | 268 } |
263 | 269 |
264 Token getBeginToken() => beginToken; | 270 Token getBeginToken() => beginToken; |
265 | 271 |
| 272 @override |
| 273 Token getPrefixEndToken() { |
| 274 Token token; |
| 275 if (interfaces != null) { |
| 276 token = interfaces.getEndToken(); |
| 277 } |
| 278 if (token == null && superclass != null) { |
| 279 token = superclass.getEndToken(); |
| 280 } |
| 281 if (token == null && typeParameters != null) { |
| 282 token == typeParameters.getEndToken(); |
| 283 } |
| 284 if (token == null) { |
| 285 token = name.getEndToken(); |
| 286 } |
| 287 assert(invariant(beginToken, token != null)); |
| 288 return token; |
| 289 } |
| 290 |
266 Token getEndToken() => endToken; | 291 Token getEndToken() => endToken; |
267 } | 292 } |
268 | 293 |
269 class MixinApplication extends Node { | 294 class MixinApplication extends Node { |
270 final TypeAnnotation superclass; | 295 final TypeAnnotation superclass; |
271 final NodeList mixins; | 296 final NodeList mixins; |
272 | 297 |
273 MixinApplication(this.superclass, this.mixins); | 298 MixinApplication(this.superclass, this.mixins); |
274 | 299 |
275 MixinApplication asMixinApplication() => this; | 300 MixinApplication asMixinApplication() => this; |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 | 756 |
732 FunctionDeclaration(this.function); | 757 FunctionDeclaration(this.function); |
733 | 758 |
734 FunctionDeclaration asFunctionDeclaration() => this; | 759 FunctionDeclaration asFunctionDeclaration() => this; |
735 | 760 |
736 accept(Visitor visitor) => visitor.visitFunctionDeclaration(this); | 761 accept(Visitor visitor) => visitor.visitFunctionDeclaration(this); |
737 | 762 |
738 visitChildren(Visitor visitor) => function.accept(visitor); | 763 visitChildren(Visitor visitor) => function.accept(visitor); |
739 | 764 |
740 Token getBeginToken() => function.getBeginToken(); | 765 Token getBeginToken() => function.getBeginToken(); |
| 766 |
| 767 @override |
| 768 Token getPrefixEndToken() => function.getPrefixEndToken(); |
| 769 |
741 Token getEndToken() => function.getEndToken(); | 770 Token getEndToken() => function.getEndToken(); |
742 } | 771 } |
743 | 772 |
744 /// Node representing the method implementation modifiers `sync*`, `async`, and | 773 /// Node representing the method implementation modifiers `sync*`, `async`, and |
745 /// `async*` or the invalid modifier `sync`. | 774 /// `async*` or the invalid modifier `sync`. |
746 class AsyncModifier extends Node { | 775 class AsyncModifier extends Node { |
747 /// The `async` or `sync` token. | 776 /// The `async` or `sync` token. |
748 final Token asyncToken; | 777 final Token asyncToken; |
749 | 778 |
750 /// The `*` token. | 779 /// The `*` token. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 return block.statements.isEmpty; | 848 return block.statements.isEmpty; |
820 } | 849 } |
821 | 850 |
822 Token getBeginToken() { | 851 Token getBeginToken() { |
823 Token token = firstBeginToken(modifiers, returnType); | 852 Token token = firstBeginToken(modifiers, returnType); |
824 if (token != null) return token; | 853 if (token != null) return token; |
825 if (getOrSet != null) return getOrSet; | 854 if (getOrSet != null) return getOrSet; |
826 return firstBeginToken(name, parameters); | 855 return firstBeginToken(name, parameters); |
827 } | 856 } |
828 | 857 |
| 858 @override |
| 859 Token getPrefixEndToken() { |
| 860 return parameters != null ? parameters.getEndToken() : name.getEndToken(); |
| 861 } |
| 862 |
829 Token getEndToken() { | 863 Token getEndToken() { |
830 Token token = (body == null) ? null : body.getEndToken(); | 864 Token token = (body == null) ? null : body.getEndToken(); |
831 token = (token == null) ? parameters.getEndToken() : token; | 865 token = (token == null) ? parameters.getEndToken() : token; |
832 return (token == null) ? name.getEndToken() : token; | 866 return (token == null) ? name.getEndToken() : token; |
833 } | 867 } |
834 } | 868 } |
835 | 869 |
836 typedef void DecodeErrorHandler(Token token, var error); | 870 typedef void DecodeErrorHandler(Token token, var error); |
837 | 871 |
838 abstract class Literal<T> extends Expression { | 872 abstract class Literal<T> extends Expression { |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 | 1327 |
1294 accept(Visitor visitor) => visitor.visitTypeAnnotation(this); | 1328 accept(Visitor visitor) => visitor.visitTypeAnnotation(this); |
1295 | 1329 |
1296 visitChildren(Visitor visitor) { | 1330 visitChildren(Visitor visitor) { |
1297 typeName.accept(visitor); | 1331 typeName.accept(visitor); |
1298 if (typeArguments != null) typeArguments.accept(visitor); | 1332 if (typeArguments != null) typeArguments.accept(visitor); |
1299 } | 1333 } |
1300 | 1334 |
1301 Token getBeginToken() => typeName.getBeginToken(); | 1335 Token getBeginToken() => typeName.getBeginToken(); |
1302 | 1336 |
1303 Token getEndToken() => typeName.getEndToken(); | 1337 Token getEndToken() { |
| 1338 if (typeArguments != null) return typeArguments.getEndToken(); |
| 1339 return typeName.getEndToken(); |
| 1340 } |
1304 } | 1341 } |
1305 | 1342 |
1306 class TypeVariable extends Node { | 1343 class TypeVariable extends Node { |
1307 final Identifier name; | 1344 final Identifier name; |
1308 final TypeAnnotation bound; | 1345 final TypeAnnotation bound; |
1309 TypeVariable(Identifier this.name, TypeAnnotation this.bound); | 1346 TypeVariable(Identifier this.name, TypeAnnotation this.bound); |
1310 | 1347 |
1311 accept(Visitor visitor) => visitor.visitTypeVariable(this); | 1348 accept(Visitor visitor) => visitor.visitTypeVariable(this); |
1312 | 1349 |
1313 visitChildren(Visitor visitor) { | 1350 visitChildren(Visitor visitor) { |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2444 | 2481 |
2445 // VariableDefinitions. | 2482 // VariableDefinitions. |
2446 get metadata => null; | 2483 get metadata => null; |
2447 get type => null; | 2484 get type => null; |
2448 | 2485 |
2449 // Typedef. | 2486 // Typedef. |
2450 get typeParameters => null; | 2487 get typeParameters => null; |
2451 get formals => null; | 2488 get formals => null; |
2452 get typedefKeyword => null; | 2489 get typedefKeyword => null; |
2453 } | 2490 } |
OLD | NEW |