| 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 |
| 587 String get documentationComment { | 599 String get documentationComment { |
| 588 if (_unlinkedClass != null) { | 600 if (_unlinkedClass != null) { |
| 589 return _unlinkedClass?.documentationComment?.text; | 601 return _unlinkedClass?.documentationComment?.text; |
| 590 } | 602 } |
| 591 return super.documentationComment; | 603 return super.documentationComment; |
| 592 } | 604 } |
| 593 | 605 |
| 594 /** | 606 /** |
| 595 * Return `true` if [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS] should | 607 * Return `true` if [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS] should |
| 596 * be reported for this class. | 608 * be reported for this class. |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1795 */ | 1807 */ |
| 1796 class ConstFieldElementImpl_EnumValue extends ConstFieldElementImpl_ofEnum { | 1808 class ConstFieldElementImpl_EnumValue extends ConstFieldElementImpl_ofEnum { |
| 1797 final UnlinkedEnumValue _unlinkedEnumValue; | 1809 final UnlinkedEnumValue _unlinkedEnumValue; |
| 1798 final int _index; | 1810 final int _index; |
| 1799 | 1811 |
| 1800 ConstFieldElementImpl_EnumValue( | 1812 ConstFieldElementImpl_EnumValue( |
| 1801 EnumElementImpl enumElement, this._unlinkedEnumValue, this._index) | 1813 EnumElementImpl enumElement, this._unlinkedEnumValue, this._index) |
| 1802 : super(enumElement); | 1814 : super(enumElement); |
| 1803 | 1815 |
| 1804 @override | 1816 @override |
| 1817 SourceRange get docRange { |
| 1818 if (_unlinkedEnumValue != null) { |
| 1819 UnlinkedDocumentationComment comment = |
| 1820 _unlinkedEnumValue.documentationComment; |
| 1821 return comment != null |
| 1822 ? new SourceRange(comment.offset, comment.length) |
| 1823 : null; |
| 1824 } |
| 1825 return super.docRange; |
| 1826 } |
| 1827 |
| 1828 @override |
| 1805 String get documentationComment { | 1829 String get documentationComment { |
| 1806 if (_unlinkedEnumValue != null) { | 1830 if (_unlinkedEnumValue != null) { |
| 1807 return _unlinkedEnumValue?.documentationComment?.text; | 1831 return _unlinkedEnumValue?.documentationComment?.text; |
| 1808 } | 1832 } |
| 1809 return super.documentationComment; | 1833 return super.documentationComment; |
| 1810 } | 1834 } |
| 1811 | 1835 |
| 1812 @override | 1836 @override |
| 1813 EvaluationResultImpl get evaluationResult { | 1837 EvaluationResultImpl get evaluationResult { |
| 1814 if (_evaluationResult == null) { | 1838 if (_evaluationResult == null) { |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2662 * A cached copy of the calculated location for this element. | 2686 * A cached copy of the calculated location for this element. |
| 2663 */ | 2687 */ |
| 2664 ElementLocation _cachedLocation; | 2688 ElementLocation _cachedLocation; |
| 2665 | 2689 |
| 2666 /** | 2690 /** |
| 2667 * The documentation comment for this element. | 2691 * The documentation comment for this element. |
| 2668 */ | 2692 */ |
| 2669 String _docComment; | 2693 String _docComment; |
| 2670 | 2694 |
| 2671 /** | 2695 /** |
| 2696 * The offset to the beginning of the documentation comment, |
| 2697 * or `null` if this element does not have a documentation comment. |
| 2698 */ |
| 2699 int _docRangeOffset; |
| 2700 |
| 2701 /** |
| 2702 * The length of the documentation comment range for this element. |
| 2703 */ |
| 2704 int _docRangeLength; |
| 2705 |
| 2706 /** |
| 2672 * The offset of the beginning of the element's code in the file that contains | 2707 * The offset of the beginning of the element's code in the file that contains |
| 2673 * the element, or `null` if the element is synthetic. | 2708 * the element, or `null` if the element is synthetic. |
| 2674 */ | 2709 */ |
| 2675 int _codeOffset; | 2710 int _codeOffset; |
| 2676 | 2711 |
| 2677 /** | 2712 /** |
| 2678 * The length of the element's code, or `null` if the element is synthetic. | 2713 * The length of the element's code, or `null` if the element is synthetic. |
| 2679 */ | 2714 */ |
| 2680 int _codeLength; | 2715 int _codeLength; |
| 2681 | 2716 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2714 if (_enclosingElement == null) { | 2749 if (_enclosingElement == null) { |
| 2715 return null; | 2750 return null; |
| 2716 } | 2751 } |
| 2717 return _enclosingElement.context; | 2752 return _enclosingElement.context; |
| 2718 } | 2753 } |
| 2719 | 2754 |
| 2720 @override | 2755 @override |
| 2721 String get displayName => _name; | 2756 String get displayName => _name; |
| 2722 | 2757 |
| 2723 @override | 2758 @override |
| 2759 SourceRange get docRange { |
| 2760 if (_docRangeOffset != null && _docRangeLength != null) { |
| 2761 return new SourceRange(_docRangeOffset, _docRangeLength); |
| 2762 } |
| 2763 return null; |
| 2764 } |
| 2765 |
| 2766 @override |
| 2724 String get documentationComment => _docComment; | 2767 String get documentationComment => _docComment; |
| 2725 | 2768 |
| 2726 /** | 2769 /** |
| 2727 * The documentation comment source for this element. | 2770 * The documentation comment source for this element. |
| 2728 */ | 2771 */ |
| 2729 void set documentationComment(String doc) { | 2772 void set documentationComment(String doc) { |
| 2730 assert(!isResynthesized); | 2773 assert(!isResynthesized); |
| 2731 _docComment = doc?.replaceAll('\r\n', '\n'); | 2774 _docComment = doc?.replaceAll('\r\n', '\n'); |
| 2732 } | 2775 } |
| 2733 | 2776 |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3058 /** | 3101 /** |
| 3059 * Set the code range for this element. | 3102 * Set the code range for this element. |
| 3060 */ | 3103 */ |
| 3061 void setCodeRange(int offset, int length) { | 3104 void setCodeRange(int offset, int length) { |
| 3062 assert(!isResynthesized); | 3105 assert(!isResynthesized); |
| 3063 _codeOffset = offset; | 3106 _codeOffset = offset; |
| 3064 _codeLength = length; | 3107 _codeLength = length; |
| 3065 } | 3108 } |
| 3066 | 3109 |
| 3067 /** | 3110 /** |
| 3111 * Set the documentation comment source range for this element. |
| 3112 */ |
| 3113 void setDocRange(int offset, int length) { |
| 3114 assert(!isResynthesized); |
| 3115 _docRangeOffset = offset; |
| 3116 _docRangeLength = length; |
| 3117 } |
| 3118 |
| 3119 /** |
| 3068 * Set whether the given [modifier] is associated with this element to | 3120 * Set whether the given [modifier] is associated with this element to |
| 3069 * correspond to the given [value]. | 3121 * correspond to the given [value]. |
| 3070 */ | 3122 */ |
| 3071 void setModifier(Modifier modifier, bool value) { | 3123 void setModifier(Modifier modifier, bool value) { |
| 3072 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value); | 3124 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value); |
| 3073 } | 3125 } |
| 3074 | 3126 |
| 3075 @override | 3127 @override |
| 3076 String toString() { | 3128 String toString() { |
| 3077 StringBuffer buffer = new StringBuffer(); | 3129 StringBuffer buffer = new StringBuffer(); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3343 @override | 3395 @override |
| 3344 List<ConstructorElement> get constructors { | 3396 List<ConstructorElement> get constructors { |
| 3345 // The equivalent code for enums in the spec shows a single constructor, | 3397 // The equivalent code for enums in the spec shows a single constructor, |
| 3346 // but that constructor is not callable (since it is a compile-time error | 3398 // but that constructor is not callable (since it is a compile-time error |
| 3347 // to subclass, mix-in, implement, or explicitly instantiate an enum). | 3399 // to subclass, mix-in, implement, or explicitly instantiate an enum). |
| 3348 // So we represent this as having no constructors. | 3400 // So we represent this as having no constructors. |
| 3349 return const <ConstructorElement>[]; | 3401 return const <ConstructorElement>[]; |
| 3350 } | 3402 } |
| 3351 | 3403 |
| 3352 @override | 3404 @override |
| 3405 SourceRange get docRange { |
| 3406 if (_unlinkedEnum != null) { |
| 3407 UnlinkedDocumentationComment comment = _unlinkedEnum.documentationComment; |
| 3408 return comment != null |
| 3409 ? new SourceRange(comment.offset, comment.length) |
| 3410 : null; |
| 3411 } |
| 3412 return super.docRange; |
| 3413 } |
| 3414 |
| 3415 @override |
| 3353 String get documentationComment { | 3416 String get documentationComment { |
| 3354 if (_unlinkedEnum != null) { | 3417 if (_unlinkedEnum != null) { |
| 3355 return _unlinkedEnum?.documentationComment?.text; | 3418 return _unlinkedEnum?.documentationComment?.text; |
| 3356 } | 3419 } |
| 3357 return super.documentationComment; | 3420 return super.documentationComment; |
| 3358 } | 3421 } |
| 3359 | 3422 |
| 3360 @override | 3423 @override |
| 3361 List<FieldElement> get fields { | 3424 List<FieldElement> get fields { |
| 3362 if (_unlinkedEnum != null && _fields == null) { | 3425 if (_unlinkedEnum != null && _fields == null) { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3596 | 3659 |
| 3597 @override | 3660 @override |
| 3598 String get displayName { | 3661 String get displayName { |
| 3599 if (serializedExecutable != null) { | 3662 if (serializedExecutable != null) { |
| 3600 return serializedExecutable.name; | 3663 return serializedExecutable.name; |
| 3601 } | 3664 } |
| 3602 return super.displayName; | 3665 return super.displayName; |
| 3603 } | 3666 } |
| 3604 | 3667 |
| 3605 @override | 3668 @override |
| 3669 SourceRange get docRange { |
| 3670 if (serializedExecutable != null) { |
| 3671 UnlinkedDocumentationComment comment = |
| 3672 serializedExecutable.documentationComment; |
| 3673 return comment != null |
| 3674 ? new SourceRange(comment.offset, comment.length) |
| 3675 : null; |
| 3676 } |
| 3677 return super.docRange; |
| 3678 } |
| 3679 |
| 3680 @override |
| 3606 String get documentationComment { | 3681 String get documentationComment { |
| 3607 if (serializedExecutable != null) { | 3682 if (serializedExecutable != null) { |
| 3608 return serializedExecutable?.documentationComment?.text; | 3683 return serializedExecutable?.documentationComment?.text; |
| 3609 } | 3684 } |
| 3610 return super.documentationComment; | 3685 return super.documentationComment; |
| 3611 } | 3686 } |
| 3612 | 3687 |
| 3613 /** | 3688 /** |
| 3614 * Set whether this executable element is external. | 3689 * Set whether this executable element is external. |
| 3615 */ | 3690 */ |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4562 if (_unlinkedTypedef != null) { | 4637 if (_unlinkedTypedef != null) { |
| 4563 return _unlinkedTypedef.codeRange?.offset; | 4638 return _unlinkedTypedef.codeRange?.offset; |
| 4564 } | 4639 } |
| 4565 return super.codeOffset; | 4640 return super.codeOffset; |
| 4566 } | 4641 } |
| 4567 | 4642 |
| 4568 @override | 4643 @override |
| 4569 String get displayName => name; | 4644 String get displayName => name; |
| 4570 | 4645 |
| 4571 @override | 4646 @override |
| 4647 SourceRange get docRange { |
| 4648 if (_unlinkedTypedef != null) { |
| 4649 UnlinkedDocumentationComment comment = |
| 4650 _unlinkedTypedef.documentationComment; |
| 4651 return comment != null |
| 4652 ? new SourceRange(comment.offset, comment.length) |
| 4653 : null; |
| 4654 } |
| 4655 return super.docRange; |
| 4656 } |
| 4657 |
| 4658 @override |
| 4572 String get documentationComment { | 4659 String get documentationComment { |
| 4573 if (_unlinkedTypedef != null) { | 4660 if (_unlinkedTypedef != null) { |
| 4574 return _unlinkedTypedef?.documentationComment?.text; | 4661 return _unlinkedTypedef?.documentationComment?.text; |
| 4575 } | 4662 } |
| 4576 return super.documentationComment; | 4663 return super.documentationComment; |
| 4577 } | 4664 } |
| 4578 | 4665 |
| 4579 @override | 4666 @override |
| 4580 CompilationUnitElement get enclosingElement => | 4667 CompilationUnitElement get enclosingElement => |
| 4581 super.enclosingElement as CompilationUnitElement; | 4668 super.enclosingElement as CompilationUnitElement; |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5319 * Set the compilation unit that defines this library to the given compilation | 5406 * Set the compilation unit that defines this library to the given compilation |
| 5320 * [unit]. | 5407 * [unit]. |
| 5321 */ | 5408 */ |
| 5322 void set definingCompilationUnit(CompilationUnitElement unit) { | 5409 void set definingCompilationUnit(CompilationUnitElement unit) { |
| 5323 assert((unit as CompilationUnitElementImpl).librarySource == unit.source); | 5410 assert((unit as CompilationUnitElementImpl).librarySource == unit.source); |
| 5324 (unit as CompilationUnitElementImpl).enclosingElement = this; | 5411 (unit as CompilationUnitElementImpl).enclosingElement = this; |
| 5325 this._definingCompilationUnit = unit; | 5412 this._definingCompilationUnit = unit; |
| 5326 } | 5413 } |
| 5327 | 5414 |
| 5328 @override | 5415 @override |
| 5416 SourceRange get docRange { |
| 5417 if (_unlinkedDefiningUnit != null) { |
| 5418 UnlinkedDocumentationComment comment = |
| 5419 _unlinkedDefiningUnit.libraryDocumentationComment; |
| 5420 return comment != null |
| 5421 ? new SourceRange(comment.offset, comment.length) |
| 5422 : null; |
| 5423 } |
| 5424 return super.docRange; |
| 5425 } |
| 5426 |
| 5427 @override |
| 5329 String get documentationComment { | 5428 String get documentationComment { |
| 5330 if (_unlinkedDefiningUnit != null) { | 5429 if (_unlinkedDefiningUnit != null) { |
| 5331 return _unlinkedDefiningUnit?.libraryDocumentationComment?.text; | 5430 return _unlinkedDefiningUnit?.libraryDocumentationComment?.text; |
| 5332 } | 5431 } |
| 5333 return super.documentationComment; | 5432 return super.documentationComment; |
| 5334 } | 5433 } |
| 5335 | 5434 |
| 5336 FunctionElement get entryPoint { | 5435 FunctionElement get entryPoint { |
| 5337 if (resynthesizerContext != null) { | 5436 if (resynthesizerContext != null) { |
| 5338 _entryPoint ??= resynthesizerContext.findEntryPoint(); | 5437 _entryPoint ??= resynthesizerContext.findEntryPoint(); |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6352 * list of [conflictingElements]. | 6451 * list of [conflictingElements]. |
| 6353 */ | 6452 */ |
| 6354 MultiplyDefinedElementImpl(this.context, this.conflictingElements) { | 6453 MultiplyDefinedElementImpl(this.context, this.conflictingElements) { |
| 6355 _name = conflictingElements[0].name; | 6454 _name = conflictingElements[0].name; |
| 6356 } | 6455 } |
| 6357 | 6456 |
| 6358 @override | 6457 @override |
| 6359 String get displayName => _name; | 6458 String get displayName => _name; |
| 6360 | 6459 |
| 6361 @override | 6460 @override |
| 6461 SourceRange get docRange => null; |
| 6462 |
| 6463 @override |
| 6362 String get documentationComment => null; | 6464 String get documentationComment => null; |
| 6363 | 6465 |
| 6364 @override | 6466 @override |
| 6365 Element get enclosingElement => null; | 6467 Element get enclosingElement => null; |
| 6366 | 6468 |
| 6367 @override | 6469 @override |
| 6368 bool get isDeprecated => false; | 6470 bool get isDeprecated => false; |
| 6369 | 6471 |
| 6370 @override | 6472 @override |
| 6371 bool get isFactory => false; | 6473 bool get isFactory => false; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6635 return super.codeOffset; | 6737 return super.codeOffset; |
| 6636 } | 6738 } |
| 6637 | 6739 |
| 6638 @override | 6740 @override |
| 6639 void set const3(bool isConst) { | 6741 void set const3(bool isConst) { |
| 6640 assert(_unlinkedVariable == null); | 6742 assert(_unlinkedVariable == null); |
| 6641 super.const3 = isConst; | 6743 super.const3 = isConst; |
| 6642 } | 6744 } |
| 6643 | 6745 |
| 6644 @override | 6746 @override |
| 6747 SourceRange get docRange { |
| 6748 if (_unlinkedVariable != null) { |
| 6749 UnlinkedDocumentationComment comment = |
| 6750 _unlinkedVariable.documentationComment; |
| 6751 return comment != null |
| 6752 ? new SourceRange(comment.offset, comment.length) |
| 6753 : null; |
| 6754 } |
| 6755 return super.docRange; |
| 6756 } |
| 6757 |
| 6758 @override |
| 6645 String get documentationComment { | 6759 String get documentationComment { |
| 6646 if (_unlinkedVariable != null) { | 6760 if (_unlinkedVariable != null) { |
| 6647 return _unlinkedVariable?.documentationComment?.text; | 6761 return _unlinkedVariable?.documentationComment?.text; |
| 6648 } | 6762 } |
| 6649 return super.documentationComment; | 6763 return super.documentationComment; |
| 6650 } | 6764 } |
| 6651 | 6765 |
| 6652 @override | 6766 @override |
| 6653 void set final2(bool isFinal) { | 6767 void set final2(bool isFinal) { |
| 6654 assert(_unlinkedVariable == null); | 6768 assert(_unlinkedVariable == null); |
| (...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8365 | 8479 |
| 8366 @override | 8480 @override |
| 8367 void visitElement(Element element) { | 8481 void visitElement(Element element) { |
| 8368 int offset = element.nameOffset; | 8482 int offset = element.nameOffset; |
| 8369 if (offset != -1) { | 8483 if (offset != -1) { |
| 8370 map[offset] = element; | 8484 map[offset] = element; |
| 8371 } | 8485 } |
| 8372 super.visitElement(element); | 8486 super.visitElement(element); |
| 8373 } | 8487 } |
| 8374 } | 8488 } |
| OLD | NEW |