Chromium Code Reviews| 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 engine.element; | 5 library engine.element; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/utilities_general.dart'; | 9 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 10 import 'package:analyzer/src/task/dart.dart'; | 10 import 'package:analyzer/src/task/dart.dart'; |
| (...skipping 3505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3516 */ | 3516 */ |
| 3517 static const List<ExecutableElement> EMPTY_LIST = const <ExecutableElement>[]; | 3517 static const List<ExecutableElement> EMPTY_LIST = const <ExecutableElement>[]; |
| 3518 | 3518 |
| 3519 /** | 3519 /** |
| 3520 * Return a list containing all of the functions defined within this | 3520 * Return a list containing all of the functions defined within this |
| 3521 * executable element. | 3521 * executable element. |
| 3522 */ | 3522 */ |
| 3523 List<FunctionElement> get functions; | 3523 List<FunctionElement> get functions; |
| 3524 | 3524 |
| 3525 /** | 3525 /** |
| 3526 * Return `true` if this executable element did not have an explicit return | |
| 3527 * type specified for it. | |
|
scheglov
2015/08/17 20:08:49
I cannot understand reading just this comment, whe
Brian Wilkerson
2015/08/18 00:07:04
Done
| |
| 3528 */ | |
| 3529 bool get hasImplicitReturnType; | |
| 3530 | |
| 3531 /** | |
| 3526 * Return `true` if this executable element is abstract. Executable elements | 3532 * Return `true` if this executable element is abstract. Executable elements |
| 3527 * are abstract if they are not external and have no body. | 3533 * are abstract if they are not external and have no body. |
| 3528 */ | 3534 */ |
| 3529 bool get isAbstract; | 3535 bool get isAbstract; |
| 3530 | 3536 |
| 3531 /** | 3537 /** |
| 3532 * Return `true` if this executable element has body marked as being | 3538 * Return `true` if this executable element has body marked as being |
| 3533 * asynchronous. | 3539 * asynchronous. |
| 3534 */ | 3540 */ |
| 3535 bool get isAsynchronous; | 3541 bool get isAsynchronous; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3692 } | 3698 } |
| 3693 | 3699 |
| 3694 /** | 3700 /** |
| 3695 * Set whether this method's body is a generator. | 3701 * Set whether this method's body is a generator. |
| 3696 */ | 3702 */ |
| 3697 void set generator(bool isGenerator) { | 3703 void set generator(bool isGenerator) { |
| 3698 setModifier(Modifier.GENERATOR, isGenerator); | 3704 setModifier(Modifier.GENERATOR, isGenerator); |
| 3699 } | 3705 } |
| 3700 | 3706 |
| 3701 @override | 3707 @override |
| 3708 bool get hasImplicitReturnType => hasModifier(Modifier.IMPLICIT_TYPE); | |
| 3709 | |
| 3710 /** | |
| 3711 * Set whether this executable element has an implicit return type. | |
| 3712 */ | |
| 3713 void set hasImplicitReturnType(bool hasImplicitReturnType) { | |
| 3714 setModifier(Modifier.IMPLICIT_TYPE, hasImplicitReturnType); | |
| 3715 } | |
| 3716 | |
| 3717 @override | |
| 3702 bool get isAbstract => hasModifier(Modifier.ABSTRACT); | 3718 bool get isAbstract => hasModifier(Modifier.ABSTRACT); |
| 3703 | 3719 |
| 3704 @override | 3720 @override |
| 3705 bool get isAsynchronous => hasModifier(Modifier.ASYNCHRONOUS); | 3721 bool get isAsynchronous => hasModifier(Modifier.ASYNCHRONOUS); |
| 3706 | 3722 |
| 3707 @override | 3723 @override |
| 3708 bool get isExternal => hasModifier(Modifier.EXTERNAL); | 3724 bool get isExternal => hasModifier(Modifier.EXTERNAL); |
| 3709 | 3725 |
| 3710 @override | 3726 @override |
| 3711 bool get isGenerator => hasModifier(Modifier.GENERATOR); | 3727 bool get isGenerator => hasModifier(Modifier.GENERATOR); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3878 List<FunctionElement> get functions { | 3894 List<FunctionElement> get functions { |
| 3879 // | 3895 // |
| 3880 // Elements within this element should have type parameters substituted, | 3896 // Elements within this element should have type parameters substituted, |
| 3881 // just like this element. | 3897 // just like this element. |
| 3882 // | 3898 // |
| 3883 throw new UnsupportedOperationException(); | 3899 throw new UnsupportedOperationException(); |
| 3884 // return getBaseElement().getFunctions(); | 3900 // return getBaseElement().getFunctions(); |
| 3885 } | 3901 } |
| 3886 | 3902 |
| 3887 @override | 3903 @override |
| 3904 bool get hasImplicitReturnType => baseElement.hasImplicitReturnType; | |
| 3905 | |
| 3906 @override | |
| 3888 bool get isAbstract => baseElement.isAbstract; | 3907 bool get isAbstract => baseElement.isAbstract; |
| 3889 | 3908 |
| 3890 @override | 3909 @override |
| 3891 bool get isAsynchronous => baseElement.isAsynchronous; | 3910 bool get isAsynchronous => baseElement.isAsynchronous; |
| 3892 | 3911 |
| 3893 @override | 3912 @override |
| 3894 bool get isExternal => baseElement.isExternal; | 3913 bool get isExternal => baseElement.isExternal; |
| 3895 | 3914 |
| 3896 @override | 3915 @override |
| 3897 bool get isGenerator => baseElement.isGenerator; | 3916 bool get isGenerator => baseElement.isGenerator; |
| (...skipping 4349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8247 static const Modifier GETTER = const Modifier('GETTER', 9); | 8266 static const Modifier GETTER = const Modifier('GETTER', 9); |
| 8248 | 8267 |
| 8249 /** | 8268 /** |
| 8250 * A flag used for libraries indicating that the defining compilation unit | 8269 * A flag used for libraries indicating that the defining compilation unit |
| 8251 * contains at least one import directive whose URI uses the "dart-ext" | 8270 * contains at least one import directive whose URI uses the "dart-ext" |
| 8252 * scheme. | 8271 * scheme. |
| 8253 */ | 8272 */ |
| 8254 static const Modifier HAS_EXT_URI = const Modifier('HAS_EXT_URI', 10); | 8273 static const Modifier HAS_EXT_URI = const Modifier('HAS_EXT_URI', 10); |
| 8255 | 8274 |
| 8256 /** | 8275 /** |
| 8276 * Indicates that the associated element did not have an explicit type | |
| 8277 * associated with it. If the element is an [ExecutableElement], then the | |
| 8278 * type being referred to is the return type. | |
| 8279 */ | |
| 8280 static const Modifier IMPLICIT_TYPE = const Modifier('IMPLICIT_TYPE', 11); | |
| 8281 | |
| 8282 /** | |
| 8257 * Indicates that a class can validly be used as a mixin. | 8283 * Indicates that a class can validly be used as a mixin. |
| 8258 */ | 8284 */ |
| 8259 static const Modifier MIXIN = const Modifier('MIXIN', 11); | 8285 static const Modifier MIXIN = const Modifier('MIXIN', 12); |
| 8260 | 8286 |
| 8261 /** | 8287 /** |
| 8262 * Indicates that a class is a mixin application. | 8288 * Indicates that a class is a mixin application. |
| 8263 */ | 8289 */ |
| 8264 static const Modifier MIXIN_APPLICATION = | 8290 static const Modifier MIXIN_APPLICATION = |
| 8265 const Modifier('MIXIN_APPLICATION', 12); | 8291 const Modifier('MIXIN_APPLICATION', 13); |
| 8266 | 8292 |
| 8267 /** | 8293 /** |
| 8268 * Indicates that the value of a parameter or local variable might be mutated | 8294 * Indicates that the value of a parameter or local variable might be mutated |
| 8269 * within the context. | 8295 * within the context. |
| 8270 */ | 8296 */ |
| 8271 static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT = | 8297 static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT = |
| 8272 const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 13); | 8298 const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 14); |
| 8273 | 8299 |
| 8274 /** | 8300 /** |
| 8275 * Indicates that the value of a parameter or local variable might be mutated | 8301 * Indicates that the value of a parameter or local variable might be mutated |
| 8276 * within the scope. | 8302 * within the scope. |
| 8277 */ | 8303 */ |
| 8278 static const Modifier POTENTIALLY_MUTATED_IN_SCOPE = | 8304 static const Modifier POTENTIALLY_MUTATED_IN_SCOPE = |
| 8279 const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 14); | 8305 const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 15); |
| 8280 | 8306 |
| 8281 /** | 8307 /** |
| 8282 * Indicates that a class contains an explicit reference to 'super'. | 8308 * Indicates that a class contains an explicit reference to 'super'. |
| 8283 */ | 8309 */ |
| 8284 static const Modifier REFERENCES_SUPER = | 8310 static const Modifier REFERENCES_SUPER = |
| 8285 const Modifier('REFERENCES_SUPER', 15); | 8311 const Modifier('REFERENCES_SUPER', 16); |
| 8286 | 8312 |
| 8287 /** | 8313 /** |
| 8288 * Indicates that the pseudo-modifier 'set' was applied to the element. | 8314 * Indicates that the pseudo-modifier 'set' was applied to the element. |
| 8289 */ | 8315 */ |
| 8290 static const Modifier SETTER = const Modifier('SETTER', 16); | 8316 static const Modifier SETTER = const Modifier('SETTER', 17); |
| 8291 | 8317 |
| 8292 /** | 8318 /** |
| 8293 * Indicates that the modifier 'static' was applied to the element. | 8319 * Indicates that the modifier 'static' was applied to the element. |
| 8294 */ | 8320 */ |
| 8295 static const Modifier STATIC = const Modifier('STATIC', 17); | 8321 static const Modifier STATIC = const Modifier('STATIC', 18); |
| 8296 | 8322 |
| 8297 /** | 8323 /** |
| 8298 * Indicates that the element does not appear in the source code but was | 8324 * Indicates that the element does not appear in the source code but was |
| 8299 * implicitly created. For example, if a class does not define any | 8325 * implicitly created. For example, if a class does not define any |
| 8300 * constructors, an implicit zero-argument constructor will be created and it | 8326 * constructors, an implicit zero-argument constructor will be created and it |
| 8301 * will be marked as being synthetic. | 8327 * will be marked as being synthetic. |
| 8302 */ | 8328 */ |
| 8303 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 18); | 8329 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 19); |
| 8304 | 8330 |
| 8305 static const List<Modifier> values = const [ | 8331 static const List<Modifier> values = const [ |
| 8306 ABSTRACT, | 8332 ABSTRACT, |
| 8307 ASYNCHRONOUS, | 8333 ASYNCHRONOUS, |
| 8308 CONST, | 8334 CONST, |
| 8309 DEFERRED, | 8335 DEFERRED, |
| 8310 ENUM, | 8336 ENUM, |
| 8311 EXTERNAL, | 8337 EXTERNAL, |
| 8312 FACTORY, | 8338 FACTORY, |
| 8313 FINAL, | 8339 FINAL, |
| 8314 GENERATOR, | 8340 GENERATOR, |
| 8315 GETTER, | 8341 GETTER, |
| 8316 HAS_EXT_URI, | 8342 HAS_EXT_URI, |
| 8343 IMPLICIT_TYPE, | |
| 8317 MIXIN, | 8344 MIXIN, |
| 8318 MIXIN_APPLICATION, | 8345 MIXIN_APPLICATION, |
| 8319 POTENTIALLY_MUTATED_IN_CONTEXT, | 8346 POTENTIALLY_MUTATED_IN_CONTEXT, |
| 8320 POTENTIALLY_MUTATED_IN_SCOPE, | 8347 POTENTIALLY_MUTATED_IN_SCOPE, |
| 8321 REFERENCES_SUPER, | 8348 REFERENCES_SUPER, |
| 8322 SETTER, | 8349 SETTER, |
| 8323 STATIC, | 8350 STATIC, |
| 8324 SYNTHETIC | 8351 SYNTHETIC |
| 8325 ]; | 8352 ]; |
| 8326 | 8353 |
| (...skipping 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10439 /** | 10466 /** |
| 10440 * A variable. There are concrete subclasses for different kinds of variables. | 10467 * A variable. There are concrete subclasses for different kinds of variables. |
| 10441 */ | 10468 */ |
| 10442 abstract class VariableElement implements Element, ConstantEvaluationTarget { | 10469 abstract class VariableElement implements Element, ConstantEvaluationTarget { |
| 10443 /** | 10470 /** |
| 10444 * An empty list of variable elements. | 10471 * An empty list of variable elements. |
| 10445 */ | 10472 */ |
| 10446 static const List<VariableElement> EMPTY_LIST = const <VariableElement>[]; | 10473 static const List<VariableElement> EMPTY_LIST = const <VariableElement>[]; |
| 10447 | 10474 |
| 10448 /** | 10475 /** |
| 10476 * Return `true` if this variable element did not have an explicit type | |
| 10477 * specified for it. | |
| 10478 */ | |
| 10479 bool get hasImplicitType; | |
| 10480 | |
| 10481 /** | |
| 10449 * Return a synthetic function representing this variable's initializer, or | 10482 * Return a synthetic function representing this variable's initializer, or |
| 10450 * `null` if this variable does not have an initializer. The function will | 10483 * `null` if this variable does not have an initializer. The function will |
| 10451 * have no parameters. The return type of the function will be the | 10484 * have no parameters. The return type of the function will be the |
| 10452 * compile-time type of the initialization expression. | 10485 * compile-time type of the initialization expression. |
| 10453 */ | 10486 */ |
| 10454 FunctionElement get initializer; | 10487 FunctionElement get initializer; |
| 10455 | 10488 |
| 10456 /** | 10489 /** |
| 10457 * Return `true` if this variable was declared with the 'const' modifier. | 10490 * Return `true` if this variable was declared with the 'const' modifier. |
| 10458 */ | 10491 */ |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10547 } | 10580 } |
| 10548 | 10581 |
| 10549 /** | 10582 /** |
| 10550 * Set whether this variable is final. | 10583 * Set whether this variable is final. |
| 10551 */ | 10584 */ |
| 10552 void set final2(bool isFinal) { | 10585 void set final2(bool isFinal) { |
| 10553 setModifier(Modifier.FINAL, isFinal); | 10586 setModifier(Modifier.FINAL, isFinal); |
| 10554 } | 10587 } |
| 10555 | 10588 |
| 10556 @override | 10589 @override |
| 10590 bool get hasImplicitType => hasModifier(Modifier.IMPLICIT_TYPE); | |
| 10591 | |
| 10592 /** | |
| 10593 * Set whether this variable element has an implicit type. | |
| 10594 */ | |
| 10595 void set hasImplicitType(bool hasImplicitType) { | |
| 10596 setModifier(Modifier.IMPLICIT_TYPE, hasImplicitType); | |
| 10597 } | |
| 10598 | |
| 10599 @override | |
| 10557 FunctionElement get initializer => _initializer; | 10600 FunctionElement get initializer => _initializer; |
| 10558 | 10601 |
| 10559 /** | 10602 /** |
| 10560 * Set the function representing this variable's initializer to the given | 10603 * Set the function representing this variable's initializer to the given |
| 10561 * [function]. | 10604 * [function]. |
| 10562 */ | 10605 */ |
| 10563 void set initializer(FunctionElement function) { | 10606 void set initializer(FunctionElement function) { |
| 10564 if (function != null) { | 10607 if (function != null) { |
| 10565 (function as FunctionElementImpl).enclosingElement = this; | 10608 (function as FunctionElementImpl).enclosingElement = this; |
| 10566 } | 10609 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10602 * Initialize a newly created element to represent a constructor, based on the | 10645 * Initialize a newly created element to represent a constructor, based on the |
| 10603 * [baseElement], defined by the [definingType]. | 10646 * [baseElement], defined by the [definingType]. |
| 10604 */ | 10647 */ |
| 10605 VariableMember(VariableElement baseElement, ParameterizedType definingType) | 10648 VariableMember(VariableElement baseElement, ParameterizedType definingType) |
| 10606 : super(baseElement, definingType); | 10649 : super(baseElement, definingType); |
| 10607 | 10650 |
| 10608 @override | 10651 @override |
| 10609 VariableElement get baseElement => super.baseElement as VariableElement; | 10652 VariableElement get baseElement => super.baseElement as VariableElement; |
| 10610 | 10653 |
| 10611 @override | 10654 @override |
| 10655 bool get hasImplicitType => baseElement.hasImplicitType; | |
| 10656 | |
| 10657 @override | |
| 10612 FunctionElement get initializer { | 10658 FunctionElement get initializer { |
| 10613 // | 10659 // |
| 10614 // Elements within this element should have type parameters substituted, | 10660 // Elements within this element should have type parameters substituted, |
| 10615 // just like this element. | 10661 // just like this element. |
| 10616 // | 10662 // |
| 10617 throw new UnsupportedOperationException(); | 10663 throw new UnsupportedOperationException(); |
| 10618 // return getBaseElement().getInitializer(); | 10664 // return getBaseElement().getInitializer(); |
| 10619 } | 10665 } |
| 10620 | 10666 |
| 10621 @override | 10667 @override |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10715 | 10761 |
| 10716 @override | 10762 @override |
| 10717 void visitElement(Element element) { | 10763 void visitElement(Element element) { |
| 10718 int offset = element.nameOffset; | 10764 int offset = element.nameOffset; |
| 10719 if (offset != -1) { | 10765 if (offset != -1) { |
| 10720 map[offset] = element; | 10766 map[offset] = element; |
| 10721 } | 10767 } |
| 10722 super.visitElement(element); | 10768 super.visitElement(element); |
| 10723 } | 10769 } |
| 10724 } | 10770 } |
| OLD | NEW |