| 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 void set constructors(List<ConstructorElement> constructors) { | 577 void set constructors(List<ConstructorElement> constructors) { |
| 578 assert(_unlinkedClass == null); | 578 assert(_unlinkedClass == null); |
| 579 assert(!isMixinApplication); | 579 assert(!isMixinApplication); |
| 580 for (ConstructorElement constructor in constructors) { | 580 for (ConstructorElement constructor in constructors) { |
| 581 (constructor as ConstructorElementImpl).enclosingElement = this; | 581 (constructor as ConstructorElementImpl).enclosingElement = this; |
| 582 } | 582 } |
| 583 this._constructors = constructors; | 583 this._constructors = constructors; |
| 584 } | 584 } |
| 585 | 585 |
| 586 @override | 586 @override |
| 587 SourceRange get docRange { | |
| 588 if (_unlinkedClass != null) { | |
| 589 UnlinkedDocumentationComment comment = | |
| 590 _unlinkedClass.documentationComment; | |
| 591 return comment != null | |
| 592 ? new SourceRange(comment.offset, comment.length) | |
| 593 : null; | |
| 594 } | |
| 595 return super.docRange; | |
| 596 } | |
| 597 | |
| 598 @override | |
| 599 String get documentationComment { | 587 String get documentationComment { |
| 600 if (_unlinkedClass != null) { | 588 if (_unlinkedClass != null) { |
| 601 return _unlinkedClass?.documentationComment?.text; | 589 return _unlinkedClass?.documentationComment?.text; |
| 602 } | 590 } |
| 603 return super.documentationComment; | 591 return super.documentationComment; |
| 604 } | 592 } |
| 605 | 593 |
| 606 /** | 594 /** |
| 607 * Return `true` if [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS] should | 595 * Return `true` if [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS] should |
| 608 * be reported for this class. | 596 * be reported for this class. |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1814 */ | 1802 */ |
| 1815 class ConstFieldElementImpl_EnumValue extends ConstFieldElementImpl_ofEnum { | 1803 class ConstFieldElementImpl_EnumValue extends ConstFieldElementImpl_ofEnum { |
| 1816 final UnlinkedEnumValue _unlinkedEnumValue; | 1804 final UnlinkedEnumValue _unlinkedEnumValue; |
| 1817 final int _index; | 1805 final int _index; |
| 1818 | 1806 |
| 1819 ConstFieldElementImpl_EnumValue( | 1807 ConstFieldElementImpl_EnumValue( |
| 1820 EnumElementImpl enumElement, this._unlinkedEnumValue, this._index) | 1808 EnumElementImpl enumElement, this._unlinkedEnumValue, this._index) |
| 1821 : super(enumElement); | 1809 : super(enumElement); |
| 1822 | 1810 |
| 1823 @override | 1811 @override |
| 1824 SourceRange get docRange { | |
| 1825 if (_unlinkedEnumValue != null) { | |
| 1826 UnlinkedDocumentationComment comment = | |
| 1827 _unlinkedEnumValue.documentationComment; | |
| 1828 return comment != null | |
| 1829 ? new SourceRange(comment.offset, comment.length) | |
| 1830 : null; | |
| 1831 } | |
| 1832 return super.docRange; | |
| 1833 } | |
| 1834 | |
| 1835 @override | |
| 1836 String get documentationComment { | 1812 String get documentationComment { |
| 1837 if (_unlinkedEnumValue != null) { | 1813 if (_unlinkedEnumValue != null) { |
| 1838 return _unlinkedEnumValue?.documentationComment?.text; | 1814 return _unlinkedEnumValue?.documentationComment?.text; |
| 1839 } | 1815 } |
| 1840 return super.documentationComment; | 1816 return super.documentationComment; |
| 1841 } | 1817 } |
| 1842 | 1818 |
| 1843 @override | 1819 @override |
| 1844 EvaluationResultImpl get evaluationResult { | 1820 EvaluationResultImpl get evaluationResult { |
| 1845 if (_evaluationResult == null) { | 1821 if (_evaluationResult == null) { |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2693 * A cached copy of the calculated location for this element. | 2669 * A cached copy of the calculated location for this element. |
| 2694 */ | 2670 */ |
| 2695 ElementLocation _cachedLocation; | 2671 ElementLocation _cachedLocation; |
| 2696 | 2672 |
| 2697 /** | 2673 /** |
| 2698 * The documentation comment for this element. | 2674 * The documentation comment for this element. |
| 2699 */ | 2675 */ |
| 2700 String _docComment; | 2676 String _docComment; |
| 2701 | 2677 |
| 2702 /** | 2678 /** |
| 2703 * The offset to the beginning of the documentation comment, | |
| 2704 * or `null` if this element does not have a documentation comment. | |
| 2705 */ | |
| 2706 int _docRangeOffset; | |
| 2707 | |
| 2708 /** | |
| 2709 * The length of the documentation comment range for this element. | |
| 2710 */ | |
| 2711 int _docRangeLength; | |
| 2712 | |
| 2713 /** | |
| 2714 * The offset of the beginning of the element's code in the file that contains | 2679 * The offset of the beginning of the element's code in the file that contains |
| 2715 * the element, or `null` if the element is synthetic. | 2680 * the element, or `null` if the element is synthetic. |
| 2716 */ | 2681 */ |
| 2717 int _codeOffset; | 2682 int _codeOffset; |
| 2718 | 2683 |
| 2719 /** | 2684 /** |
| 2720 * The length of the element's code, or `null` if the element is synthetic. | 2685 * The length of the element's code, or `null` if the element is synthetic. |
| 2721 */ | 2686 */ |
| 2722 int _codeLength; | 2687 int _codeLength; |
| 2723 | 2688 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2756 if (_enclosingElement == null) { | 2721 if (_enclosingElement == null) { |
| 2757 return null; | 2722 return null; |
| 2758 } | 2723 } |
| 2759 return _enclosingElement.context; | 2724 return _enclosingElement.context; |
| 2760 } | 2725 } |
| 2761 | 2726 |
| 2762 @override | 2727 @override |
| 2763 String get displayName => _name; | 2728 String get displayName => _name; |
| 2764 | 2729 |
| 2765 @override | 2730 @override |
| 2766 SourceRange get docRange { | |
| 2767 if (_docRangeOffset != null && _docRangeLength != null) { | |
| 2768 return new SourceRange(_docRangeOffset, _docRangeLength); | |
| 2769 } | |
| 2770 return null; | |
| 2771 } | |
| 2772 | |
| 2773 @override | |
| 2774 String get documentationComment => _docComment; | 2731 String get documentationComment => _docComment; |
| 2775 | 2732 |
| 2776 /** | 2733 /** |
| 2777 * The documentation comment source for this element. | 2734 * The documentation comment source for this element. |
| 2778 */ | 2735 */ |
| 2779 void set documentationComment(String doc) { | 2736 void set documentationComment(String doc) { |
| 2780 assert(!isResynthesized); | 2737 assert(!isResynthesized); |
| 2781 _docComment = doc?.replaceAll('\r\n', '\n'); | 2738 _docComment = doc?.replaceAll('\r\n', '\n'); |
| 2782 } | 2739 } |
| 2783 | 2740 |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3108 /** | 3065 /** |
| 3109 * Set the code range for this element. | 3066 * Set the code range for this element. |
| 3110 */ | 3067 */ |
| 3111 void setCodeRange(int offset, int length) { | 3068 void setCodeRange(int offset, int length) { |
| 3112 assert(!isResynthesized); | 3069 assert(!isResynthesized); |
| 3113 _codeOffset = offset; | 3070 _codeOffset = offset; |
| 3114 _codeLength = length; | 3071 _codeLength = length; |
| 3115 } | 3072 } |
| 3116 | 3073 |
| 3117 /** | 3074 /** |
| 3118 * Set the documentation comment source range for this element. | |
| 3119 */ | |
| 3120 void setDocRange(int offset, int length) { | |
| 3121 assert(!isResynthesized); | |
| 3122 _docRangeOffset = offset; | |
| 3123 _docRangeLength = length; | |
| 3124 } | |
| 3125 | |
| 3126 /** | |
| 3127 * Set whether the given [modifier] is associated with this element to | 3075 * Set whether the given [modifier] is associated with this element to |
| 3128 * correspond to the given [value]. | 3076 * correspond to the given [value]. |
| 3129 */ | 3077 */ |
| 3130 void setModifier(Modifier modifier, bool value) { | 3078 void setModifier(Modifier modifier, bool value) { |
| 3131 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value); | 3079 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value); |
| 3132 } | 3080 } |
| 3133 | 3081 |
| 3134 @override | 3082 @override |
| 3135 String toString() { | 3083 String toString() { |
| 3136 StringBuffer buffer = new StringBuffer(); | 3084 StringBuffer buffer = new StringBuffer(); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3402 @override | 3350 @override |
| 3403 List<ConstructorElement> get constructors { | 3351 List<ConstructorElement> get constructors { |
| 3404 // The equivalent code for enums in the spec shows a single constructor, | 3352 // The equivalent code for enums in the spec shows a single constructor, |
| 3405 // but that constructor is not callable (since it is a compile-time error | 3353 // but that constructor is not callable (since it is a compile-time error |
| 3406 // to subclass, mix-in, implement, or explicitly instantiate an enum). | 3354 // to subclass, mix-in, implement, or explicitly instantiate an enum). |
| 3407 // So we represent this as having no constructors. | 3355 // So we represent this as having no constructors. |
| 3408 return const <ConstructorElement>[]; | 3356 return const <ConstructorElement>[]; |
| 3409 } | 3357 } |
| 3410 | 3358 |
| 3411 @override | 3359 @override |
| 3412 SourceRange get docRange { | |
| 3413 if (_unlinkedEnum != null) { | |
| 3414 UnlinkedDocumentationComment comment = _unlinkedEnum.documentationComment; | |
| 3415 return comment != null | |
| 3416 ? new SourceRange(comment.offset, comment.length) | |
| 3417 : null; | |
| 3418 } | |
| 3419 return super.docRange; | |
| 3420 } | |
| 3421 | |
| 3422 @override | |
| 3423 String get documentationComment { | 3360 String get documentationComment { |
| 3424 if (_unlinkedEnum != null) { | 3361 if (_unlinkedEnum != null) { |
| 3425 return _unlinkedEnum?.documentationComment?.text; | 3362 return _unlinkedEnum?.documentationComment?.text; |
| 3426 } | 3363 } |
| 3427 return super.documentationComment; | 3364 return super.documentationComment; |
| 3428 } | 3365 } |
| 3429 | 3366 |
| 3430 @override | 3367 @override |
| 3431 List<FieldElement> get fields { | 3368 List<FieldElement> get fields { |
| 3432 if (_unlinkedEnum != null && _fields == null) { | 3369 if (_unlinkedEnum != null && _fields == null) { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3666 | 3603 |
| 3667 @override | 3604 @override |
| 3668 String get displayName { | 3605 String get displayName { |
| 3669 if (serializedExecutable != null) { | 3606 if (serializedExecutable != null) { |
| 3670 return serializedExecutable.name; | 3607 return serializedExecutable.name; |
| 3671 } | 3608 } |
| 3672 return super.displayName; | 3609 return super.displayName; |
| 3673 } | 3610 } |
| 3674 | 3611 |
| 3675 @override | 3612 @override |
| 3676 SourceRange get docRange { | |
| 3677 if (serializedExecutable != null) { | |
| 3678 UnlinkedDocumentationComment comment = | |
| 3679 serializedExecutable.documentationComment; | |
| 3680 return comment != null | |
| 3681 ? new SourceRange(comment.offset, comment.length) | |
| 3682 : null; | |
| 3683 } | |
| 3684 return super.docRange; | |
| 3685 } | |
| 3686 | |
| 3687 @override | |
| 3688 String get documentationComment { | 3613 String get documentationComment { |
| 3689 if (serializedExecutable != null) { | 3614 if (serializedExecutable != null) { |
| 3690 return serializedExecutable?.documentationComment?.text; | 3615 return serializedExecutable?.documentationComment?.text; |
| 3691 } | 3616 } |
| 3692 return super.documentationComment; | 3617 return super.documentationComment; |
| 3693 } | 3618 } |
| 3694 | 3619 |
| 3695 /** | 3620 /** |
| 3696 * Set whether this executable element is external. | 3621 * Set whether this executable element is external. |
| 3697 */ | 3622 */ |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4644 if (_unlinkedTypedef != null) { | 4569 if (_unlinkedTypedef != null) { |
| 4645 return _unlinkedTypedef.codeRange?.offset; | 4570 return _unlinkedTypedef.codeRange?.offset; |
| 4646 } | 4571 } |
| 4647 return super.codeOffset; | 4572 return super.codeOffset; |
| 4648 } | 4573 } |
| 4649 | 4574 |
| 4650 @override | 4575 @override |
| 4651 String get displayName => name; | 4576 String get displayName => name; |
| 4652 | 4577 |
| 4653 @override | 4578 @override |
| 4654 SourceRange get docRange { | |
| 4655 if (_unlinkedTypedef != null) { | |
| 4656 UnlinkedDocumentationComment comment = | |
| 4657 _unlinkedTypedef.documentationComment; | |
| 4658 return comment != null | |
| 4659 ? new SourceRange(comment.offset, comment.length) | |
| 4660 : null; | |
| 4661 } | |
| 4662 return super.docRange; | |
| 4663 } | |
| 4664 | |
| 4665 @override | |
| 4666 String get documentationComment { | 4579 String get documentationComment { |
| 4667 if (_unlinkedTypedef != null) { | 4580 if (_unlinkedTypedef != null) { |
| 4668 return _unlinkedTypedef?.documentationComment?.text; | 4581 return _unlinkedTypedef?.documentationComment?.text; |
| 4669 } | 4582 } |
| 4670 return super.documentationComment; | 4583 return super.documentationComment; |
| 4671 } | 4584 } |
| 4672 | 4585 |
| 4673 @override | 4586 @override |
| 4674 CompilationUnitElement get enclosingElement => | 4587 CompilationUnitElement get enclosingElement => |
| 4675 super.enclosingElement as CompilationUnitElement; | 4588 super.enclosingElement as CompilationUnitElement; |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5413 * Set the compilation unit that defines this library to the given compilation | 5326 * Set the compilation unit that defines this library to the given compilation |
| 5414 * [unit]. | 5327 * [unit]. |
| 5415 */ | 5328 */ |
| 5416 void set definingCompilationUnit(CompilationUnitElement unit) { | 5329 void set definingCompilationUnit(CompilationUnitElement unit) { |
| 5417 assert((unit as CompilationUnitElementImpl).librarySource == unit.source); | 5330 assert((unit as CompilationUnitElementImpl).librarySource == unit.source); |
| 5418 (unit as CompilationUnitElementImpl).enclosingElement = this; | 5331 (unit as CompilationUnitElementImpl).enclosingElement = this; |
| 5419 this._definingCompilationUnit = unit; | 5332 this._definingCompilationUnit = unit; |
| 5420 } | 5333 } |
| 5421 | 5334 |
| 5422 @override | 5335 @override |
| 5423 SourceRange get docRange { | |
| 5424 if (_unlinkedDefiningUnit != null) { | |
| 5425 UnlinkedDocumentationComment comment = | |
| 5426 _unlinkedDefiningUnit.libraryDocumentationComment; | |
| 5427 return comment != null | |
| 5428 ? new SourceRange(comment.offset, comment.length) | |
| 5429 : null; | |
| 5430 } | |
| 5431 return super.docRange; | |
| 5432 } | |
| 5433 | |
| 5434 @override | |
| 5435 String get documentationComment { | 5336 String get documentationComment { |
| 5436 if (_unlinkedDefiningUnit != null) { | 5337 if (_unlinkedDefiningUnit != null) { |
| 5437 return _unlinkedDefiningUnit?.libraryDocumentationComment?.text; | 5338 return _unlinkedDefiningUnit?.libraryDocumentationComment?.text; |
| 5438 } | 5339 } |
| 5439 return super.documentationComment; | 5340 return super.documentationComment; |
| 5440 } | 5341 } |
| 5441 | 5342 |
| 5442 FunctionElement get entryPoint { | 5343 FunctionElement get entryPoint { |
| 5443 if (resynthesizerContext != null) { | 5344 if (resynthesizerContext != null) { |
| 5444 _entryPoint ??= resynthesizerContext.findEntryPoint(); | 5345 _entryPoint ??= resynthesizerContext.findEntryPoint(); |
| (...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6483 } | 6384 } |
| 6484 List<Element> elements = nonSdkElements.toList(); | 6385 List<Element> elements = nonSdkElements.toList(); |
| 6485 elements.addAll(sdkElements); | 6386 elements.addAll(sdkElements); |
| 6486 return elements; | 6387 return elements; |
| 6487 } | 6388 } |
| 6488 | 6389 |
| 6489 @override | 6390 @override |
| 6490 String get displayName => _name; | 6391 String get displayName => _name; |
| 6491 | 6392 |
| 6492 @override | 6393 @override |
| 6493 SourceRange get docRange => null; | |
| 6494 | |
| 6495 @override | |
| 6496 String get documentationComment => null; | 6394 String get documentationComment => null; |
| 6497 | 6395 |
| 6498 @override | 6396 @override |
| 6499 Element get enclosingElement => null; | 6397 Element get enclosingElement => null; |
| 6500 | 6398 |
| 6501 @override | 6399 @override |
| 6502 bool get isDeprecated => false; | 6400 bool get isDeprecated => false; |
| 6503 | 6401 |
| 6504 @override | 6402 @override |
| 6505 bool get isFactory => false; | 6403 bool get isFactory => false; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6769 return super.codeOffset; | 6667 return super.codeOffset; |
| 6770 } | 6668 } |
| 6771 | 6669 |
| 6772 @override | 6670 @override |
| 6773 void set const3(bool isConst) { | 6671 void set const3(bool isConst) { |
| 6774 assert(_unlinkedVariable == null); | 6672 assert(_unlinkedVariable == null); |
| 6775 super.const3 = isConst; | 6673 super.const3 = isConst; |
| 6776 } | 6674 } |
| 6777 | 6675 |
| 6778 @override | 6676 @override |
| 6779 SourceRange get docRange { | |
| 6780 if (_unlinkedVariable != null) { | |
| 6781 UnlinkedDocumentationComment comment = | |
| 6782 _unlinkedVariable.documentationComment; | |
| 6783 return comment != null | |
| 6784 ? new SourceRange(comment.offset, comment.length) | |
| 6785 : null; | |
| 6786 } | |
| 6787 return super.docRange; | |
| 6788 } | |
| 6789 | |
| 6790 @override | |
| 6791 String get documentationComment { | 6677 String get documentationComment { |
| 6792 if (_unlinkedVariable != null) { | 6678 if (_unlinkedVariable != null) { |
| 6793 return _unlinkedVariable?.documentationComment?.text; | 6679 return _unlinkedVariable?.documentationComment?.text; |
| 6794 } | 6680 } |
| 6795 return super.documentationComment; | 6681 return super.documentationComment; |
| 6796 } | 6682 } |
| 6797 | 6683 |
| 6798 @override | 6684 @override |
| 6799 void set final2(bool isFinal) { | 6685 void set final2(bool isFinal) { |
| 6800 assert(_unlinkedVariable == null); | 6686 assert(_unlinkedVariable == null); |
| (...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8511 | 8397 |
| 8512 @override | 8398 @override |
| 8513 void visitElement(Element element) { | 8399 void visitElement(Element element) { |
| 8514 int offset = element.nameOffset; | 8400 int offset = element.nameOffset; |
| 8515 if (offset != -1) { | 8401 if (offset != -1) { |
| 8516 map[offset] = element; | 8402 map[offset] = element; |
| 8517 } | 8403 } |
| 8518 super.visitElement(element); | 8404 super.visitElement(element); |
| 8519 } | 8405 } |
| 8520 } | 8406 } |
| OLD | NEW |