OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 elements.modelx; | 5 library elements.modelx; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/resolution.dart' show Resolution, ParsingContext; | 8 import '../common/resolution.dart' show Resolution, ParsingContext; |
9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
10 import '../constants/constant_constructors.dart'; | 10 import '../constants/constant_constructors.dart'; |
(...skipping 3175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3186 */ | 3186 */ |
3187 ConstantExpression constant; | 3187 ConstantExpression constant; |
3188 Element annotatedElement; | 3188 Element annotatedElement; |
3189 int resolutionState; | 3189 int resolutionState; |
3190 | 3190 |
3191 /** | 3191 /** |
3192 * The beginning token of this annotation, or [:null:] if it is synthetic. | 3192 * The beginning token of this annotation, or [:null:] if it is synthetic. |
3193 */ | 3193 */ |
3194 Token get beginToken; | 3194 Token get beginToken; |
3195 | 3195 |
| 3196 Token get endToken; |
| 3197 |
3196 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]); | 3198 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]); |
3197 | 3199 |
3198 MetadataAnnotation ensureResolved(Resolution resolution) { | 3200 MetadataAnnotation ensureResolved(Resolution resolution) { |
3199 if (annotatedElement.isClass || annotatedElement.isTypedef) { | 3201 if (annotatedElement.isClass || annotatedElement.isTypedef) { |
3200 TypeDeclarationElement typeDeclaration = annotatedElement; | 3202 TypeDeclarationElement typeDeclaration = annotatedElement; |
3201 typeDeclaration.ensureResolved(resolution); | 3203 typeDeclaration.ensureResolved(resolution); |
3202 } | 3204 } |
3203 if (resolutionState == STATE_NOT_STARTED) { | 3205 if (resolutionState == STATE_NOT_STARTED) { |
3204 resolution.resolveMetadataAnnotation(this); | 3206 resolution.resolveMetadataAnnotation(this); |
3205 } | 3207 } |
3206 return this; | 3208 return this; |
3207 } | 3209 } |
3208 | 3210 |
3209 Node parseNode(ParsingContext parsing); | 3211 Node parseNode(ParsingContext parsing); |
3210 | 3212 |
| 3213 SourceSpan get sourcePosition { |
| 3214 Uri uri = annotatedElement.compilationUnit.script.resourceUri; |
| 3215 return new SourceSpan.fromTokens(uri, beginToken, endToken); |
| 3216 } |
| 3217 |
3211 String toString() => 'MetadataAnnotation($constant, $resolutionState)'; | 3218 String toString() => 'MetadataAnnotation($constant, $resolutionState)'; |
3212 } | 3219 } |
3213 | 3220 |
3214 /// Metadata annotation on a parameter. | 3221 /// Metadata annotation on a parameter. |
3215 class ParameterMetadataAnnotation extends MetadataAnnotationX { | 3222 class ParameterMetadataAnnotation extends MetadataAnnotationX { |
3216 final Metadata metadata; | 3223 final Metadata metadata; |
3217 | 3224 |
3218 ParameterMetadataAnnotation(Metadata this.metadata); | 3225 ParameterMetadataAnnotation(Metadata this.metadata); |
3219 | 3226 |
3220 Node parseNode(ParsingContext parsing) => metadata.expression; | 3227 Node parseNode(ParsingContext parsing) => metadata.expression; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3286 body = node.asFunctionExpression().body; | 3293 body = node.asFunctionExpression().body; |
3287 } | 3294 } |
3288 return new ParsedResolvedAst( | 3295 return new ParsedResolvedAst( |
3289 declaration, | 3296 declaration, |
3290 node, | 3297 node, |
3291 body, | 3298 body, |
3292 definingElement.treeElements, | 3299 definingElement.treeElements, |
3293 definingElement.compilationUnit.script.resourceUri); | 3300 definingElement.compilationUnit.script.resourceUri); |
3294 } | 3301 } |
3295 } | 3302 } |
OLD | NEW |