Chromium Code Reviews| 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 library elements; | 5 library elements; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/resolution.dart' show | 8 import '../common/resolution.dart' show |
| 9 Resolution; | 9 Resolution; |
| 10 import '../compiler.dart' show | 10 import '../compiler.dart' show |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 static const ElementKind INITIALIZING_FORMAL = | 79 static const ElementKind INITIALIZING_FORMAL = |
| 80 const ElementKind('initializing_formal', ElementCategory.VARIABLE); | 80 const ElementKind('initializing_formal', ElementCategory.VARIABLE); |
| 81 static const ElementKind FUNCTION = | 81 static const ElementKind FUNCTION = |
| 82 const ElementKind('function', ElementCategory.FUNCTION); | 82 const ElementKind('function', ElementCategory.FUNCTION); |
| 83 static const ElementKind CLASS = | 83 static const ElementKind CLASS = |
| 84 const ElementKind('class', ElementCategory.CLASS); | 84 const ElementKind('class', ElementCategory.CLASS); |
| 85 static const ElementKind GENERATIVE_CONSTRUCTOR = | 85 static const ElementKind GENERATIVE_CONSTRUCTOR = |
| 86 const ElementKind('generative_constructor', ElementCategory.FACTORY); | 86 const ElementKind('generative_constructor', ElementCategory.FACTORY); |
| 87 static const ElementKind FIELD = | 87 static const ElementKind FIELD = |
| 88 const ElementKind('field', ElementCategory.VARIABLE); | 88 const ElementKind('field', ElementCategory.VARIABLE); |
| 89 static const ElementKind FIELD_LIST = | |
| 90 const ElementKind('field_list', ElementCategory.NONE); | |
|
Johnni Winther
2015/10/21 07:51:56
Nice!
sigurdm
2015/10/22 07:33:14
Acknowledged.
| |
| 91 static const ElementKind GENERATIVE_CONSTRUCTOR_BODY = | 89 static const ElementKind GENERATIVE_CONSTRUCTOR_BODY = |
| 92 const ElementKind('generative_constructor_body', ElementCategory.NONE); | 90 const ElementKind('generative_constructor_body', ElementCategory.NONE); |
| 93 static const ElementKind COMPILATION_UNIT = | 91 static const ElementKind COMPILATION_UNIT = |
| 94 const ElementKind('compilation_unit', ElementCategory.NONE); | 92 const ElementKind('compilation_unit', ElementCategory.NONE); |
| 95 static const ElementKind GETTER = | 93 static const ElementKind GETTER = |
| 96 const ElementKind('getter', ElementCategory.NONE); | 94 const ElementKind('getter', ElementCategory.NONE); |
| 97 static const ElementKind SETTER = | 95 static const ElementKind SETTER = |
| 98 const ElementKind('setter', ElementCategory.NONE); | 96 const ElementKind('setter', ElementCategory.NONE); |
| 99 static const ElementKind TYPE_VARIABLE = | 97 static const ElementKind TYPE_VARIABLE = |
| 100 const ElementKind('type_variable', ElementCategory.TYPE_VARIABLE); | 98 const ElementKind('type_variable', ElementCategory.TYPE_VARIABLE); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 /// | 263 /// |
| 266 /// This property is `false` if this element is an initializing formal. | 264 /// This property is `false` if this element is an initializing formal. |
| 267 /// See [isInitializingFormal]. | 265 /// See [isInitializingFormal]. |
| 268 bool get isParameter; | 266 bool get isParameter; |
| 269 | 267 |
| 270 /// `true` if this element is an initializing formal of constructor, that | 268 /// `true` if this element is an initializing formal of constructor, that |
| 271 /// is a formal of the form `this.foo`. | 269 /// is a formal of the form `this.foo`. |
| 272 bool get isInitializingFormal; | 270 bool get isInitializingFormal; |
| 273 | 271 |
| 274 /// `true` if this element represents a resolution error. | 272 /// `true` if this element represents a resolution error. |
| 275 bool get isErroneous; | 273 bool get isError; |
| 276 | 274 |
| 277 /// `true` if this element represents an ambiguous name. | 275 /// `true` if this element represents an ambiguous name. |
| 278 /// | 276 /// |
| 279 /// Ambiguous names occur when two imports/exports contain different entities | 277 /// Ambiguous names occur when two imports/exports contain different entities |
| 280 /// by the same name. If an ambiguous name is resolved an warning or error | 278 /// by the same name. If an ambiguous name is resolved an warning or error |
| 281 /// is produced. | 279 /// is produced. |
| 282 bool get isAmbiguous; | 280 bool get isAmbiguous; |
| 283 | 281 |
| 282 /// True if there has been errors during resolution or parsing of this | |
| 283 /// element. | |
| 284 bool get isMalformed; | |
| 285 | |
| 284 /// `true` if this element represents an entity whose access causes one or | 286 /// `true` if this element represents an entity whose access causes one or |
| 285 /// more warnings. | 287 /// more warnings. |
| 286 bool get isWarnOnUse; | 288 bool get isWarnOnUse; |
| 287 | 289 |
| 288 bool get isClosure; | 290 bool get isClosure; |
| 289 | 291 |
| 290 /// `true` if the element is a (static or instance) member of a class. | 292 /// `true` if the element is a (static or instance) member of a class. |
| 291 /// | 293 /// |
| 292 /// Members are constructors, methods and fields. | 294 /// Members are constructors, methods and fields. |
| 293 bool get isClassMember; | 295 bool get isClassMember; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 AnalyzableElement get analyzableElement; | 417 AnalyzableElement get analyzableElement; |
| 416 | 418 |
| 417 accept(ElementVisitor visitor, arg); | 419 accept(ElementVisitor visitor, arg); |
| 418 | 420 |
| 419 void setJsInteropName(String name); | 421 void setJsInteropName(String name); |
| 420 void markAsJsInterop(); | 422 void markAsJsInterop(); |
| 421 } | 423 } |
| 422 | 424 |
| 423 class Elements { | 425 class Elements { |
| 424 static bool isUnresolved(Element e) { | 426 static bool isUnresolved(Element e) { |
| 425 return e == null || e.isErroneous; | 427 return e == null || e.isMalformed; |
| 426 } | 428 } |
| 427 static bool isErroneous(Element e) => e != null && e.isErroneous; | 429 |
| 430 static bool isMalformed(Element e) { | |
| 431 return e != null && e.isMalformed; | |
| 432 } | |
| 428 | 433 |
| 429 /// Unwraps [element] reporting any warnings attached to it, if any. | 434 /// Unwraps [element] reporting any warnings attached to it, if any. |
| 430 static Element unwrap(Element element, | 435 static Element unwrap(Element element, |
| 431 DiagnosticReporter listener, | 436 DiagnosticReporter listener, |
| 432 Spannable spannable) { | 437 Spannable spannable) { |
| 433 if (element != null && element.isWarnOnUse) { | 438 if (element != null && element.isWarnOnUse) { |
| 434 WarnOnUseElement wrappedElement = element; | 439 WarnOnUseElement wrappedElement = element; |
| 435 element = wrappedElement.unwrap(listener, spannable); | 440 element = wrappedElement.unwrap(listener, spannable); |
| 436 } | 441 } |
| 437 return element; | 442 return element; |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 779 } | 784 } |
| 780 } | 785 } |
| 781 | 786 |
| 782 /// An element representing an erroneous resolution. | 787 /// An element representing an erroneous resolution. |
| 783 /// | 788 /// |
| 784 /// An [ErroneousElement] is used instead of `null` to provide additional | 789 /// An [ErroneousElement] is used instead of `null` to provide additional |
| 785 /// information about the error that caused the element to be unresolvable | 790 /// information about the error that caused the element to be unresolvable |
| 786 /// or otherwise invalid. | 791 /// or otherwise invalid. |
| 787 /// | 792 /// |
| 788 /// Accessing any field or calling any method defined on [ErroneousElement] | 793 /// Accessing any field or calling any method defined on [ErroneousElement] |
| 789 /// except [isErroneous] will currently throw an exception. (This might | 794 /// except [isError] will currently throw an exception. (This might |
| 790 /// change when we actually want more information on the erroneous element, | 795 /// change when we actually want more information on the erroneous element, |
| 791 /// e.g., the name of the element we were trying to resolve.) | 796 /// e.g., the name of the element we were trying to resolve.) |
| 792 /// | 797 /// |
| 793 /// Code that cannot not handle an [ErroneousElement] should use | 798 /// Code that cannot not handle an [ErroneousElement] should use |
| 794 /// `Element.isUnresolved(element)` to check for unresolvable elements instead | 799 /// `Element.isUnresolved(element)` to check for unresolvable elements instead |
| 795 /// of `element == null`. | 800 /// of `element == null`. |
| 796 abstract class ErroneousElement extends Element implements ConstructorElement { | 801 abstract class ErroneousElement extends Element implements ConstructorElement { |
| 797 MessageKind get messageKind; | 802 MessageKind get messageKind; |
| 798 Map get messageArguments; | 803 Map get messageArguments; |
| 799 String get message; | 804 String get message; |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1710 bool get isDeclaredByField; | 1715 bool get isDeclaredByField; |
| 1711 | 1716 |
| 1712 /// Returns `true` if this member is abstract. | 1717 /// Returns `true` if this member is abstract. |
| 1713 bool get isAbstract; | 1718 bool get isAbstract; |
| 1714 | 1719 |
| 1715 /// If abstract, [implementation] points to the overridden concrete member, | 1720 /// If abstract, [implementation] points to the overridden concrete member, |
| 1716 /// if any. Otherwise [implementation] points to the member itself. | 1721 /// if any. Otherwise [implementation] points to the member itself. |
| 1717 Member get implementation; | 1722 Member get implementation; |
| 1718 } | 1723 } |
| 1719 | 1724 |
| OLD | NEW |