Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2270903002: Remove 'Element.docRange'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 */ 1795 */
1808 class ConstFieldElementImpl_EnumValue extends ConstFieldElementImpl_ofEnum { 1796 class ConstFieldElementImpl_EnumValue extends ConstFieldElementImpl_ofEnum {
1809 final UnlinkedEnumValue _unlinkedEnumValue; 1797 final UnlinkedEnumValue _unlinkedEnumValue;
1810 final int _index; 1798 final int _index;
1811 1799
1812 ConstFieldElementImpl_EnumValue( 1800 ConstFieldElementImpl_EnumValue(
1813 EnumElementImpl enumElement, this._unlinkedEnumValue, this._index) 1801 EnumElementImpl enumElement, this._unlinkedEnumValue, this._index)
1814 : super(enumElement); 1802 : super(enumElement);
1815 1803
1816 @override 1804 @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
1829 String get documentationComment { 1805 String get documentationComment {
1830 if (_unlinkedEnumValue != null) { 1806 if (_unlinkedEnumValue != null) {
1831 return _unlinkedEnumValue?.documentationComment?.text; 1807 return _unlinkedEnumValue?.documentationComment?.text;
1832 } 1808 }
1833 return super.documentationComment; 1809 return super.documentationComment;
1834 } 1810 }
1835 1811
1836 @override 1812 @override
1837 EvaluationResultImpl get evaluationResult { 1813 EvaluationResultImpl get evaluationResult {
1838 if (_evaluationResult == null) { 1814 if (_evaluationResult == null) {
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
2686 * A cached copy of the calculated location for this element. 2662 * A cached copy of the calculated location for this element.
2687 */ 2663 */
2688 ElementLocation _cachedLocation; 2664 ElementLocation _cachedLocation;
2689 2665
2690 /** 2666 /**
2691 * The documentation comment for this element. 2667 * The documentation comment for this element.
2692 */ 2668 */
2693 String _docComment; 2669 String _docComment;
2694 2670
2695 /** 2671 /**
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 /**
2707 * The offset of the beginning of the element's code in the file that contains 2672 * The offset of the beginning of the element's code in the file that contains
2708 * the element, or `null` if the element is synthetic. 2673 * the element, or `null` if the element is synthetic.
2709 */ 2674 */
2710 int _codeOffset; 2675 int _codeOffset;
2711 2676
2712 /** 2677 /**
2713 * The length of the element's code, or `null` if the element is synthetic. 2678 * The length of the element's code, or `null` if the element is synthetic.
2714 */ 2679 */
2715 int _codeLength; 2680 int _codeLength;
2716 2681
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2749 if (_enclosingElement == null) { 2714 if (_enclosingElement == null) {
2750 return null; 2715 return null;
2751 } 2716 }
2752 return _enclosingElement.context; 2717 return _enclosingElement.context;
2753 } 2718 }
2754 2719
2755 @override 2720 @override
2756 String get displayName => _name; 2721 String get displayName => _name;
2757 2722
2758 @override 2723 @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
2767 String get documentationComment => _docComment; 2724 String get documentationComment => _docComment;
2768 2725
2769 /** 2726 /**
2770 * The documentation comment source for this element. 2727 * The documentation comment source for this element.
2771 */ 2728 */
2772 void set documentationComment(String doc) { 2729 void set documentationComment(String doc) {
2773 assert(!isResynthesized); 2730 assert(!isResynthesized);
2774 _docComment = doc?.replaceAll('\r\n', '\n'); 2731 _docComment = doc?.replaceAll('\r\n', '\n');
2775 } 2732 }
2776 2733
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
3101 /** 3058 /**
3102 * Set the code range for this element. 3059 * Set the code range for this element.
3103 */ 3060 */
3104 void setCodeRange(int offset, int length) { 3061 void setCodeRange(int offset, int length) {
3105 assert(!isResynthesized); 3062 assert(!isResynthesized);
3106 _codeOffset = offset; 3063 _codeOffset = offset;
3107 _codeLength = length; 3064 _codeLength = length;
3108 } 3065 }
3109 3066
3110 /** 3067 /**
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 /**
3120 * Set whether the given [modifier] is associated with this element to 3068 * Set whether the given [modifier] is associated with this element to
3121 * correspond to the given [value]. 3069 * correspond to the given [value].
3122 */ 3070 */
3123 void setModifier(Modifier modifier, bool value) { 3071 void setModifier(Modifier modifier, bool value) {
3124 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value); 3072 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value);
3125 } 3073 }
3126 3074
3127 @override 3075 @override
3128 String toString() { 3076 String toString() {
3129 StringBuffer buffer = new StringBuffer(); 3077 StringBuffer buffer = new StringBuffer();
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
3395 @override 3343 @override
3396 List<ConstructorElement> get constructors { 3344 List<ConstructorElement> get constructors {
3397 // The equivalent code for enums in the spec shows a single constructor, 3345 // The equivalent code for enums in the spec shows a single constructor,
3398 // but that constructor is not callable (since it is a compile-time error 3346 // but that constructor is not callable (since it is a compile-time error
3399 // to subclass, mix-in, implement, or explicitly instantiate an enum). 3347 // to subclass, mix-in, implement, or explicitly instantiate an enum).
3400 // So we represent this as having no constructors. 3348 // So we represent this as having no constructors.
3401 return const <ConstructorElement>[]; 3349 return const <ConstructorElement>[];
3402 } 3350 }
3403 3351
3404 @override 3352 @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
3416 String get documentationComment { 3353 String get documentationComment {
3417 if (_unlinkedEnum != null) { 3354 if (_unlinkedEnum != null) {
3418 return _unlinkedEnum?.documentationComment?.text; 3355 return _unlinkedEnum?.documentationComment?.text;
3419 } 3356 }
3420 return super.documentationComment; 3357 return super.documentationComment;
3421 } 3358 }
3422 3359
3423 @override 3360 @override
3424 List<FieldElement> get fields { 3361 List<FieldElement> get fields {
3425 if (_unlinkedEnum != null && _fields == null) { 3362 if (_unlinkedEnum != null && _fields == null) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
3659 3596
3660 @override 3597 @override
3661 String get displayName { 3598 String get displayName {
3662 if (serializedExecutable != null) { 3599 if (serializedExecutable != null) {
3663 return serializedExecutable.name; 3600 return serializedExecutable.name;
3664 } 3601 }
3665 return super.displayName; 3602 return super.displayName;
3666 } 3603 }
3667 3604
3668 @override 3605 @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
3681 String get documentationComment { 3606 String get documentationComment {
3682 if (serializedExecutable != null) { 3607 if (serializedExecutable != null) {
3683 return serializedExecutable?.documentationComment?.text; 3608 return serializedExecutable?.documentationComment?.text;
3684 } 3609 }
3685 return super.documentationComment; 3610 return super.documentationComment;
3686 } 3611 }
3687 3612
3688 /** 3613 /**
3689 * Set whether this executable element is external. 3614 * Set whether this executable element is external.
3690 */ 3615 */
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
4637 if (_unlinkedTypedef != null) { 4562 if (_unlinkedTypedef != null) {
4638 return _unlinkedTypedef.codeRange?.offset; 4563 return _unlinkedTypedef.codeRange?.offset;
4639 } 4564 }
4640 return super.codeOffset; 4565 return super.codeOffset;
4641 } 4566 }
4642 4567
4643 @override 4568 @override
4644 String get displayName => name; 4569 String get displayName => name;
4645 4570
4646 @override 4571 @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
4659 String get documentationComment { 4572 String get documentationComment {
4660 if (_unlinkedTypedef != null) { 4573 if (_unlinkedTypedef != null) {
4661 return _unlinkedTypedef?.documentationComment?.text; 4574 return _unlinkedTypedef?.documentationComment?.text;
4662 } 4575 }
4663 return super.documentationComment; 4576 return super.documentationComment;
4664 } 4577 }
4665 4578
4666 @override 4579 @override
4667 CompilationUnitElement get enclosingElement => 4580 CompilationUnitElement get enclosingElement =>
4668 super.enclosingElement as CompilationUnitElement; 4581 super.enclosingElement as CompilationUnitElement;
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
5406 * Set the compilation unit that defines this library to the given compilation 5319 * Set the compilation unit that defines this library to the given compilation
5407 * [unit]. 5320 * [unit].
5408 */ 5321 */
5409 void set definingCompilationUnit(CompilationUnitElement unit) { 5322 void set definingCompilationUnit(CompilationUnitElement unit) {
5410 assert((unit as CompilationUnitElementImpl).librarySource == unit.source); 5323 assert((unit as CompilationUnitElementImpl).librarySource == unit.source);
5411 (unit as CompilationUnitElementImpl).enclosingElement = this; 5324 (unit as CompilationUnitElementImpl).enclosingElement = this;
5412 this._definingCompilationUnit = unit; 5325 this._definingCompilationUnit = unit;
5413 } 5326 }
5414 5327
5415 @override 5328 @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
5428 String get documentationComment { 5329 String get documentationComment {
5429 if (_unlinkedDefiningUnit != null) { 5330 if (_unlinkedDefiningUnit != null) {
5430 return _unlinkedDefiningUnit?.libraryDocumentationComment?.text; 5331 return _unlinkedDefiningUnit?.libraryDocumentationComment?.text;
5431 } 5332 }
5432 return super.documentationComment; 5333 return super.documentationComment;
5433 } 5334 }
5434 5335
5435 FunctionElement get entryPoint { 5336 FunctionElement get entryPoint {
5436 if (resynthesizerContext != null) { 5337 if (resynthesizerContext != null) {
5437 _entryPoint ??= resynthesizerContext.findEntryPoint(); 5338 _entryPoint ??= resynthesizerContext.findEntryPoint();
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
6451 * list of [conflictingElements]. 6352 * list of [conflictingElements].
6452 */ 6353 */
6453 MultiplyDefinedElementImpl(this.context, this.conflictingElements) { 6354 MultiplyDefinedElementImpl(this.context, this.conflictingElements) {
6454 _name = conflictingElements[0].name; 6355 _name = conflictingElements[0].name;
6455 } 6356 }
6456 6357
6457 @override 6358 @override
6458 String get displayName => _name; 6359 String get displayName => _name;
6459 6360
6460 @override 6361 @override
6461 SourceRange get docRange => null;
6462
6463 @override
6464 String get documentationComment => null; 6362 String get documentationComment => null;
6465 6363
6466 @override 6364 @override
6467 Element get enclosingElement => null; 6365 Element get enclosingElement => null;
6468 6366
6469 @override 6367 @override
6470 bool get isDeprecated => false; 6368 bool get isDeprecated => false;
6471 6369
6472 @override 6370 @override
6473 bool get isFactory => false; 6371 bool get isFactory => false;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
6737 return super.codeOffset; 6635 return super.codeOffset;
6738 } 6636 }
6739 6637
6740 @override 6638 @override
6741 void set const3(bool isConst) { 6639 void set const3(bool isConst) {
6742 assert(_unlinkedVariable == null); 6640 assert(_unlinkedVariable == null);
6743 super.const3 = isConst; 6641 super.const3 = isConst;
6744 } 6642 }
6745 6643
6746 @override 6644 @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
6759 String get documentationComment { 6645 String get documentationComment {
6760 if (_unlinkedVariable != null) { 6646 if (_unlinkedVariable != null) {
6761 return _unlinkedVariable?.documentationComment?.text; 6647 return _unlinkedVariable?.documentationComment?.text;
6762 } 6648 }
6763 return super.documentationComment; 6649 return super.documentationComment;
6764 } 6650 }
6765 6651
6766 @override 6652 @override
6767 void set final2(bool isFinal) { 6653 void set final2(bool isFinal) {
6768 assert(_unlinkedVariable == null); 6654 assert(_unlinkedVariable == null);
(...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after
8479 8365
8480 @override 8366 @override
8481 void visitElement(Element element) { 8367 void visitElement(Element element) {
8482 int offset = element.nameOffset; 8368 int offset = element.nameOffset;
8483 if (offset != -1) { 8369 if (offset != -1) {
8484 map[offset] = element; 8370 map[offset] = element;
8485 } 8371 }
8486 super.visitElement(element); 8372 super.visitElement(element);
8487 } 8373 }
8488 } 8374 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/dart/element/element.dart ('k') | pkg/analyzer/lib/src/dart/element/handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698