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 | |
3198 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]); | 3196 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]); |
3199 | 3197 |
3200 MetadataAnnotation ensureResolved(Resolution resolution) { | 3198 MetadataAnnotation ensureResolved(Resolution resolution) { |
3201 if (annotatedElement.isClass || annotatedElement.isTypedef) { | 3199 if (annotatedElement.isClass || annotatedElement.isTypedef) { |
3202 TypeDeclarationElement typeDeclaration = annotatedElement; | 3200 TypeDeclarationElement typeDeclaration = annotatedElement; |
3203 typeDeclaration.ensureResolved(resolution); | 3201 typeDeclaration.ensureResolved(resolution); |
3204 } | 3202 } |
3205 if (resolutionState == STATE_NOT_STARTED) { | 3203 if (resolutionState == STATE_NOT_STARTED) { |
3206 resolution.resolveMetadataAnnotation(this); | 3204 resolution.resolveMetadataAnnotation(this); |
3207 } | 3205 } |
3208 return this; | 3206 return this; |
3209 } | 3207 } |
3210 | 3208 |
3211 Node parseNode(ParsingContext parsing); | 3209 Node parseNode(ParsingContext parsing); |
3212 | 3210 |
3213 SourceSpan get sourcePosition { | |
3214 Uri uri = annotatedElement.compilationUnit.script.resourceUri; | |
3215 return new SourceSpan.fromTokens(uri, beginToken, endToken); | |
3216 } | |
3217 | |
3218 String toString() => 'MetadataAnnotation($constant, $resolutionState)'; | 3211 String toString() => 'MetadataAnnotation($constant, $resolutionState)'; |
3219 } | 3212 } |
3220 | 3213 |
3221 /// Metadata annotation on a parameter. | 3214 /// Metadata annotation on a parameter. |
3222 class ParameterMetadataAnnotation extends MetadataAnnotationX { | 3215 class ParameterMetadataAnnotation extends MetadataAnnotationX { |
3223 final Metadata metadata; | 3216 final Metadata metadata; |
3224 | 3217 |
3225 ParameterMetadataAnnotation(Metadata this.metadata); | 3218 ParameterMetadataAnnotation(Metadata this.metadata); |
3226 | 3219 |
3227 Node parseNode(ParsingContext parsing) => metadata.expression; | 3220 Node parseNode(ParsingContext parsing) => metadata.expression; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3293 body = node.asFunctionExpression().body; | 3286 body = node.asFunctionExpression().body; |
3294 } | 3287 } |
3295 return new ParsedResolvedAst( | 3288 return new ParsedResolvedAst( |
3296 declaration, | 3289 declaration, |
3297 node, | 3290 node, |
3298 body, | 3291 body, |
3299 definingElement.treeElements, | 3292 definingElement.treeElements, |
3300 definingElement.compilationUnit.script.resourceUri); | 3293 definingElement.compilationUnit.script.resourceUri); |
3301 } | 3294 } |
3302 } | 3295 } |
OLD | NEW |