| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.src.dart.element.element; | 5 library analyzer.src.dart.element.element; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' show min; | 8 import 'dart:math' show min; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 2496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 */ | 2507 */ |
| 2508 static String _REQUIRED_CLASS_NAME = "Required"; | 2508 static String _REQUIRED_CLASS_NAME = "Required"; |
| 2509 | 2509 |
| 2510 /** | 2510 /** |
| 2511 * The name of the top-level variable used to mark a parameter as being | 2511 * The name of the top-level variable used to mark a parameter as being |
| 2512 * required. | 2512 * required. |
| 2513 */ | 2513 */ |
| 2514 static String _REQUIRED_VARIABLE_NAME = "required"; | 2514 static String _REQUIRED_VARIABLE_NAME = "required"; |
| 2515 | 2515 |
| 2516 /** | 2516 /** |
| 2517 * The name of the top-level variable used to mark a member as intended to be |
| 2518 * overridden. |
| 2519 */ |
| 2520 static String _VIRTUAL_VARIABLE_NAME = "virtual"; |
| 2521 |
| 2522 /** |
| 2517 * The element representing the field, variable, or constructor being used as | 2523 * The element representing the field, variable, or constructor being used as |
| 2518 * an annotation. | 2524 * an annotation. |
| 2519 */ | 2525 */ |
| 2520 Element element; | 2526 Element element; |
| 2521 | 2527 |
| 2522 /** | 2528 /** |
| 2523 * The compilation unit in which this annotation appears. | 2529 * The compilation unit in which this annotation appears. |
| 2524 */ | 2530 */ |
| 2525 CompilationUnitElementImpl compilationUnit; | 2531 CompilationUnitElementImpl compilationUnit; |
| 2526 | 2532 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2609 @override | 2615 @override |
| 2610 bool get isRequired => | 2616 bool get isRequired => |
| 2611 element is ConstructorElement && | 2617 element is ConstructorElement && |
| 2612 element.enclosingElement.name == _REQUIRED_CLASS_NAME && | 2618 element.enclosingElement.name == _REQUIRED_CLASS_NAME && |
| 2613 element.library?.name == _META_LIB_NAME || | 2619 element.library?.name == _META_LIB_NAME || |
| 2614 element is PropertyAccessorElement && | 2620 element is PropertyAccessorElement && |
| 2615 element.name == _REQUIRED_VARIABLE_NAME && | 2621 element.name == _REQUIRED_VARIABLE_NAME && |
| 2616 element.library?.name == _META_LIB_NAME; | 2622 element.library?.name == _META_LIB_NAME; |
| 2617 | 2623 |
| 2618 /** | 2624 /** |
| 2625 * Return `true` if this annotation marks the associated member as supporting |
| 2626 * overrides. |
| 2627 * |
| 2628 * This is currently used by fields in Strong Mode, as other members are |
| 2629 * already virtual-by-default. |
| 2630 */ |
| 2631 bool get isVirtual => |
| 2632 element is PropertyAccessorElement && |
| 2633 element.name == _VIRTUAL_VARIABLE_NAME && |
| 2634 element.library?.name == _META_LIB_NAME; |
| 2635 |
| 2636 /** |
| 2619 * Get the library containing this annotation. | 2637 * Get the library containing this annotation. |
| 2620 */ | 2638 */ |
| 2621 Source get librarySource => compilationUnit.librarySource; | 2639 Source get librarySource => compilationUnit.librarySource; |
| 2622 | 2640 |
| 2623 @override | 2641 @override |
| 2624 Source get source => compilationUnit.source; | 2642 Source get source => compilationUnit.source; |
| 2625 | 2643 |
| 2626 @override | 2644 @override |
| 2627 DartObject computeConstantValue() { | 2645 DartObject computeConstantValue() { |
| 2628 if (evaluationResult == null) { | 2646 if (evaluationResult == null) { |
| (...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4175 | 4193 |
| 4176 @override | 4194 @override |
| 4177 bool get isStatic { | 4195 bool get isStatic { |
| 4178 if (_unlinkedVariable != null) { | 4196 if (_unlinkedVariable != null) { |
| 4179 return _unlinkedVariable.isStatic; | 4197 return _unlinkedVariable.isStatic; |
| 4180 } | 4198 } |
| 4181 return hasModifier(Modifier.STATIC); | 4199 return hasModifier(Modifier.STATIC); |
| 4182 } | 4200 } |
| 4183 | 4201 |
| 4184 @override | 4202 @override |
| 4203 bool get isVirtual { |
| 4204 for (ElementAnnotationImpl annotation in metadata) { |
| 4205 if (annotation.isVirtual) { |
| 4206 return true; |
| 4207 } |
| 4208 } |
| 4209 return false; |
| 4210 } |
| 4211 |
| 4212 @override |
| 4185 ElementKind get kind => ElementKind.FIELD; | 4213 ElementKind get kind => ElementKind.FIELD; |
| 4186 | 4214 |
| 4187 /** | 4215 /** |
| 4188 * Set whether this field is static. | 4216 * Set whether this field is static. |
| 4189 */ | 4217 */ |
| 4190 void set static(bool isStatic) { | 4218 void set static(bool isStatic) { |
| 4191 assert(_unlinkedVariable == null); | 4219 assert(_unlinkedVariable == null); |
| 4192 setModifier(Modifier.STATIC, isStatic); | 4220 setModifier(Modifier.STATIC, isStatic); |
| 4193 } | 4221 } |
| 4194 | 4222 |
| (...skipping 4169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8364 | 8392 |
| 8365 @override | 8393 @override |
| 8366 void visitElement(Element element) { | 8394 void visitElement(Element element) { |
| 8367 int offset = element.nameOffset; | 8395 int offset = element.nameOffset; |
| 8368 if (offset != -1) { | 8396 if (offset != -1) { |
| 8369 map[offset] = element; | 8397 map[offset] = element; |
| 8370 } | 8398 } |
| 8371 super.visitElement(element); | 8399 super.visitElement(element); |
| 8372 } | 8400 } |
| 8373 } | 8401 } |
| OLD | NEW |