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); | |
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 isError(Element e) { |
| 431 return e != null && e.isError; |
| 432 } |
| 433 |
| 434 static bool isMalformed(Element e) { |
| 435 return e != null && e.isMalformed; |
| 436 } |
428 | 437 |
429 /// Unwraps [element] reporting any warnings attached to it, if any. | 438 /// Unwraps [element] reporting any warnings attached to it, if any. |
430 static Element unwrap(Element element, | 439 static Element unwrap(Element element, |
431 DiagnosticReporter listener, | 440 DiagnosticReporter listener, |
432 Spannable spannable) { | 441 Spannable spannable) { |
433 if (element != null && element.isWarnOnUse) { | 442 if (element != null && element.isWarnOnUse) { |
434 WarnOnUseElement wrappedElement = element; | 443 WarnOnUseElement wrappedElement = element; |
435 element = wrappedElement.unwrap(listener, spannable); | 444 element = wrappedElement.unwrap(listener, spannable); |
436 } | 445 } |
437 return element; | 446 return element; |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 } | 788 } |
780 } | 789 } |
781 | 790 |
782 /// An element representing an erroneous resolution. | 791 /// An element representing an erroneous resolution. |
783 /// | 792 /// |
784 /// An [ErroneousElement] is used instead of `null` to provide additional | 793 /// An [ErroneousElement] is used instead of `null` to provide additional |
785 /// information about the error that caused the element to be unresolvable | 794 /// information about the error that caused the element to be unresolvable |
786 /// or otherwise invalid. | 795 /// or otherwise invalid. |
787 /// | 796 /// |
788 /// Accessing any field or calling any method defined on [ErroneousElement] | 797 /// Accessing any field or calling any method defined on [ErroneousElement] |
789 /// except [isErroneous] will currently throw an exception. (This might | 798 /// except [isError] will currently throw an exception. (This might |
790 /// change when we actually want more information on the erroneous element, | 799 /// change when we actually want more information on the erroneous element, |
791 /// e.g., the name of the element we were trying to resolve.) | 800 /// e.g., the name of the element we were trying to resolve.) |
792 /// | 801 /// |
793 /// Code that cannot not handle an [ErroneousElement] should use | 802 /// Code that cannot not handle an [ErroneousElement] should use |
794 /// `Element.isUnresolved(element)` to check for unresolvable elements instead | 803 /// `Element.isUnresolved(element)` to check for unresolvable elements instead |
795 /// of `element == null`. | 804 /// of `element == null`. |
796 abstract class ErroneousElement extends Element implements ConstructorElement { | 805 abstract class ErroneousElement extends Element implements ConstructorElement { |
797 MessageKind get messageKind; | 806 MessageKind get messageKind; |
798 Map get messageArguments; | 807 Map get messageArguments; |
799 String get message; | 808 String get message; |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 bool get isDeclaredByField; | 1719 bool get isDeclaredByField; |
1711 | 1720 |
1712 /// Returns `true` if this member is abstract. | 1721 /// Returns `true` if this member is abstract. |
1713 bool get isAbstract; | 1722 bool get isAbstract; |
1714 | 1723 |
1715 /// If abstract, [implementation] points to the overridden concrete member, | 1724 /// If abstract, [implementation] points to the overridden concrete member, |
1716 /// if any. Otherwise [implementation] points to the member itself. | 1725 /// if any. Otherwise [implementation] points to the member itself. |
1717 Member get implementation; | 1726 Member get implementation; |
1718 } | 1727 } |
1719 | 1728 |
OLD | NEW |