| 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 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1723 * or `null` if this element does not have a documentation comment. | 1723 * or `null` if this element does not have a documentation comment. |
| 1724 */ | 1724 */ |
| 1725 int _docRangeOffset; | 1725 int _docRangeOffset; |
| 1726 | 1726 |
| 1727 /** | 1727 /** |
| 1728 * The length of the documentation comment range for this element. | 1728 * The length of the documentation comment range for this element. |
| 1729 */ | 1729 */ |
| 1730 int _docRangeLength; | 1730 int _docRangeLength; |
| 1731 | 1731 |
| 1732 /** | 1732 /** |
| 1733 * The offset of the beginning of the element's code in the file that contains |
| 1734 * the element, or `null` if the element is synthetic. |
| 1735 */ |
| 1736 int _codeOffset; |
| 1737 |
| 1738 /** |
| 1739 * The length of the element's code, or `null` if the element is synthetic. |
| 1740 */ |
| 1741 int _codeLength; |
| 1742 |
| 1743 /** |
| 1733 * Initialize a newly created element to have the given [name] at the given | 1744 * Initialize a newly created element to have the given [name] at the given |
| 1734 * [_nameOffset]. | 1745 * [_nameOffset]. |
| 1735 */ | 1746 */ |
| 1736 ElementImpl(String name, this._nameOffset) { | 1747 ElementImpl(String name, this._nameOffset) { |
| 1737 this._name = StringUtilities.intern(name); | 1748 this._name = StringUtilities.intern(name); |
| 1738 } | 1749 } |
| 1739 | 1750 |
| 1740 /** | 1751 /** |
| 1741 * Initialize a newly created element to have the given [name]. | 1752 * Initialize a newly created element to have the given [name]. |
| 1742 */ | 1753 */ |
| 1743 ElementImpl.forNode(Identifier name) | 1754 ElementImpl.forNode(Identifier name) |
| 1744 : this(name == null ? "" : name.name, name == null ? -1 : name.offset); | 1755 : this(name == null ? "" : name.name, name == null ? -1 : name.offset); |
| 1745 | 1756 |
| 1757 /** |
| 1758 * The length of the element's code, or `null` if the element is synthetic. |
| 1759 */ |
| 1760 int get codeLength => _codeLength; |
| 1761 |
| 1762 /** |
| 1763 * The offset of the beginning of the element's code in the file that contains |
| 1764 * the element, or `null` if the element is synthetic. |
| 1765 */ |
| 1766 int get codeOffset => _codeOffset; |
| 1767 |
| 1746 @override | 1768 @override |
| 1747 AnalysisContext get context { | 1769 AnalysisContext get context { |
| 1748 if (_enclosingElement == null) { | 1770 if (_enclosingElement == null) { |
| 1749 return null; | 1771 return null; |
| 1750 } | 1772 } |
| 1751 return _enclosingElement.context; | 1773 return _enclosingElement.context; |
| 1752 } | 1774 } |
| 1753 | 1775 |
| 1754 @override | 1776 @override |
| 1755 String get displayName => _name; | 1777 String get displayName => _name; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 */ | 2038 */ |
| 2017 void safelyVisitChildren(List<Element> children, ElementVisitor visitor) { | 2039 void safelyVisitChildren(List<Element> children, ElementVisitor visitor) { |
| 2018 if (children != null) { | 2040 if (children != null) { |
| 2019 for (Element child in children) { | 2041 for (Element child in children) { |
| 2020 child.accept(visitor); | 2042 child.accept(visitor); |
| 2021 } | 2043 } |
| 2022 } | 2044 } |
| 2023 } | 2045 } |
| 2024 | 2046 |
| 2025 /** | 2047 /** |
| 2048 * Set the code range for this element. |
| 2049 */ |
| 2050 void setCodeRange(int offset, int length) { |
| 2051 _codeOffset = offset; |
| 2052 _codeLength = length; |
| 2053 } |
| 2054 |
| 2055 /** |
| 2026 * Set the documentation comment source range for this element. | 2056 * Set the documentation comment source range for this element. |
| 2027 */ | 2057 */ |
| 2028 void setDocRange(int offset, int length) { | 2058 void setDocRange(int offset, int length) { |
| 2029 _docRangeOffset = offset; | 2059 _docRangeOffset = offset; |
| 2030 _docRangeLength = length; | 2060 _docRangeLength = length; |
| 2031 } | 2061 } |
| 2032 | 2062 |
| 2033 /** | 2063 /** |
| 2034 * Set whether the given [modifier] is associated with this element to | 2064 * Set whether the given [modifier] is associated with this element to |
| 2035 * correspond to the given [value]. | 2065 * correspond to the given [value]. |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3095 | 3125 |
| 3096 /** | 3126 /** |
| 3097 * Initialize a newly created library element in the given [context] to have | 3127 * Initialize a newly created library element in the given [context] to have |
| 3098 * the given [name]. | 3128 * the given [name]. |
| 3099 */ | 3129 */ |
| 3100 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) | 3130 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) |
| 3101 : super.forNode(name), | 3131 : super.forNode(name), |
| 3102 nameLength = name != null ? name.length : 0; | 3132 nameLength = name != null ? name.length : 0; |
| 3103 | 3133 |
| 3104 @override | 3134 @override |
| 3135 int get codeLength { |
| 3136 if (_definingCompilationUnit is CompilationUnitElementImpl) { |
| 3137 return (_definingCompilationUnit as CompilationUnitElementImpl) |
| 3138 .codeLength; |
| 3139 } |
| 3140 return null; |
| 3141 } |
| 3142 |
| 3143 @override |
| 3144 int get codeOffset { |
| 3145 if (_definingCompilationUnit is CompilationUnitElementImpl) { |
| 3146 return (_definingCompilationUnit as CompilationUnitElementImpl) |
| 3147 .codeOffset; |
| 3148 } |
| 3149 return null; |
| 3150 } |
| 3151 |
| 3152 @override |
| 3105 CompilationUnitElement get definingCompilationUnit => | 3153 CompilationUnitElement get definingCompilationUnit => |
| 3106 _definingCompilationUnit; | 3154 _definingCompilationUnit; |
| 3107 | 3155 |
| 3108 /** | 3156 /** |
| 3109 * Set the compilation unit that defines this library to the given compilation | 3157 * Set the compilation unit that defines this library to the given compilation |
| 3110 * [unit]. | 3158 * [unit]. |
| 3111 */ | 3159 */ |
| 3112 void set definingCompilationUnit(CompilationUnitElement unit) { | 3160 void set definingCompilationUnit(CompilationUnitElement unit) { |
| 3113 assert((unit as CompilationUnitElementImpl).librarySource == unit.source); | 3161 assert((unit as CompilationUnitElementImpl).librarySource == unit.source); |
| 3114 (unit as CompilationUnitElementImpl).enclosingElement = this; | 3162 (unit as CompilationUnitElementImpl).enclosingElement = this; |
| (...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4817 | 4865 |
| 4818 @override | 4866 @override |
| 4819 void visitElement(Element element) { | 4867 void visitElement(Element element) { |
| 4820 int offset = element.nameOffset; | 4868 int offset = element.nameOffset; |
| 4821 if (offset != -1) { | 4869 if (offset != -1) { |
| 4822 map[offset] = element; | 4870 map[offset] = element; |
| 4823 } | 4871 } |
| 4824 super.visitElement(element); | 4872 super.visitElement(element); |
| 4825 } | 4873 } |
| 4826 } | 4874 } |
| OLD | NEW |