| 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/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1666 * A cached copy of the calculated hashCode for this element. | 1666 * A cached copy of the calculated hashCode for this element. |
| 1667 */ | 1667 */ |
| 1668 int _cachedHashCode; | 1668 int _cachedHashCode; |
| 1669 | 1669 |
| 1670 /** | 1670 /** |
| 1671 * A cached copy of the calculated location for this element. | 1671 * A cached copy of the calculated location for this element. |
| 1672 */ | 1672 */ |
| 1673 ElementLocation _cachedLocation; | 1673 ElementLocation _cachedLocation; |
| 1674 | 1674 |
| 1675 /** | 1675 /** |
| 1676 * The documentation comment for this element. |
| 1677 */ |
| 1678 String _docComment; |
| 1679 |
| 1680 /** |
| 1676 * The offset to the beginning of the documentation comment, | 1681 * The offset to the beginning of the documentation comment, |
| 1677 * or `null` if this element does not have a documentation comment. | 1682 * or `null` if this element does not have a documentation comment. |
| 1678 */ | 1683 */ |
| 1679 int _docRangeOffset; | 1684 int _docRangeOffset; |
| 1680 | 1685 |
| 1681 /** | 1686 /** |
| 1682 * The length of the documentation comment range for this element. | 1687 * The length of the documentation comment range for this element. |
| 1683 */ | 1688 */ |
| 1684 int _docRangeLength; | 1689 int _docRangeLength; |
| 1685 | 1690 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1710 | 1715 |
| 1711 @override | 1716 @override |
| 1712 SourceRange get docRange { | 1717 SourceRange get docRange { |
| 1713 if (_docRangeOffset != null && _docRangeLength != null) { | 1718 if (_docRangeOffset != null && _docRangeLength != null) { |
| 1714 return new SourceRange(_docRangeOffset, _docRangeLength); | 1719 return new SourceRange(_docRangeOffset, _docRangeLength); |
| 1715 } | 1720 } |
| 1716 return null; | 1721 return null; |
| 1717 } | 1722 } |
| 1718 | 1723 |
| 1719 @override | 1724 @override |
| 1725 String get documentationComment => _docComment; |
| 1726 |
| 1727 /** |
| 1728 * The documentation comment source for this element. |
| 1729 */ |
| 1730 void set documentationComment(String doc) { |
| 1731 _docComment = doc?.replaceAll('\r\n', '\n'); |
| 1732 } |
| 1733 |
| 1734 @override |
| 1720 Element get enclosingElement => _enclosingElement; | 1735 Element get enclosingElement => _enclosingElement; |
| 1721 | 1736 |
| 1722 /** | 1737 /** |
| 1723 * Set the enclosing element of this element to the given [element]. | 1738 * Set the enclosing element of this element to the given [element]. |
| 1724 */ | 1739 */ |
| 1725 void set enclosingElement(Element element) { | 1740 void set enclosingElement(Element element) { |
| 1726 _enclosingElement = element as ElementImpl; | 1741 _enclosingElement = element as ElementImpl; |
| 1727 _cachedLocation = null; | 1742 _cachedLocation = null; |
| 1728 _cachedHashCode = null; | 1743 _cachedHashCode = null; |
| 1729 } | 1744 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 if (_name == null) { | 1874 if (_name == null) { |
| 1860 buffer.write("<unnamed "); | 1875 buffer.write("<unnamed "); |
| 1861 buffer.write(runtimeType.toString()); | 1876 buffer.write(runtimeType.toString()); |
| 1862 buffer.write(">"); | 1877 buffer.write(">"); |
| 1863 } else { | 1878 } else { |
| 1864 buffer.write(_name); | 1879 buffer.write(_name); |
| 1865 } | 1880 } |
| 1866 } | 1881 } |
| 1867 | 1882 |
| 1868 @override | 1883 @override |
| 1869 String computeDocumentationComment() { | 1884 String computeDocumentationComment() => documentationComment; |
| 1870 AnalysisContext context = this.context; | |
| 1871 if (context == null) { | |
| 1872 return null; | |
| 1873 } | |
| 1874 return context.computeDocumentationComment(this); | |
| 1875 } | |
| 1876 | 1885 |
| 1877 @override | 1886 @override |
| 1878 AstNode computeNode() => getNodeMatching((node) => node is AstNode); | 1887 AstNode computeNode() => getNodeMatching((node) => node is AstNode); |
| 1879 | 1888 |
| 1880 /** | 1889 /** |
| 1881 * Set this element as the enclosing element for given [element]. | 1890 * Set this element as the enclosing element for given [element]. |
| 1882 */ | 1891 */ |
| 1883 void encloseElement(ElementImpl element) { | 1892 void encloseElement(ElementImpl element) { |
| 1884 element.enclosingElement = this; | 1893 element.enclosingElement = this; |
| 1885 } | 1894 } |
| (...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3229 } | 3238 } |
| 3230 | 3239 |
| 3231 @override | 3240 @override |
| 3232 List<LibraryElement> get visibleLibraries { | 3241 List<LibraryElement> get visibleLibraries { |
| 3233 Set<LibraryElement> visibleLibraries = new Set(); | 3242 Set<LibraryElement> visibleLibraries = new Set(); |
| 3234 _addVisibleLibraries(visibleLibraries, false); | 3243 _addVisibleLibraries(visibleLibraries, false); |
| 3235 return new List.from(visibleLibraries); | 3244 return new List.from(visibleLibraries); |
| 3236 } | 3245 } |
| 3237 | 3246 |
| 3238 @override | 3247 @override |
| 3239 bool operator ==(Object object) => object is LibraryElementImpl && | 3248 bool operator ==(Object object) => |
| 3249 object is LibraryElementImpl && |
| 3240 _definingCompilationUnit == object.definingCompilationUnit; | 3250 _definingCompilationUnit == object.definingCompilationUnit; |
| 3241 | 3251 |
| 3242 @override | 3252 @override |
| 3243 accept(ElementVisitor visitor) => visitor.visitLibraryElement(this); | 3253 accept(ElementVisitor visitor) => visitor.visitLibraryElement(this); |
| 3244 | 3254 |
| 3245 /** | 3255 /** |
| 3246 * Create the [FunctionElement] to be returned by [loadLibraryFunction], | 3256 * Create the [FunctionElement] to be returned by [loadLibraryFunction], |
| 3247 * using types provided by [typeProvider]. | 3257 * using types provided by [typeProvider]. |
| 3248 */ | 3258 */ |
| 3249 void createLoadLibraryFunction(TypeProvider typeProvider) { | 3259 void createLoadLibraryFunction(TypeProvider typeProvider) { |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3651 _name = conflictingElements[0].name; | 3661 _name = conflictingElements[0].name; |
| 3652 } | 3662 } |
| 3653 | 3663 |
| 3654 @override | 3664 @override |
| 3655 String get displayName => _name; | 3665 String get displayName => _name; |
| 3656 | 3666 |
| 3657 @override | 3667 @override |
| 3658 SourceRange get docRange => null; | 3668 SourceRange get docRange => null; |
| 3659 | 3669 |
| 3660 @override | 3670 @override |
| 3671 String get documentationComment => null; |
| 3672 |
| 3673 @override |
| 3661 Element get enclosingElement => null; | 3674 Element get enclosingElement => null; |
| 3662 | 3675 |
| 3663 @override | 3676 @override |
| 3664 bool get isDeprecated => false; | 3677 bool get isDeprecated => false; |
| 3665 | 3678 |
| 3666 @override | 3679 @override |
| 3667 bool get isOverride => false; | 3680 bool get isOverride => false; |
| 3668 | 3681 |
| 3669 @override | 3682 @override |
| 3670 bool get isPrivate { | 3683 bool get isPrivate { |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4219 } | 4232 } |
| 4220 | 4233 |
| 4221 /** | 4234 /** |
| 4222 * Set whether this accessor is static. | 4235 * Set whether this accessor is static. |
| 4223 */ | 4236 */ |
| 4224 void set static(bool isStatic) { | 4237 void set static(bool isStatic) { |
| 4225 setModifier(Modifier.STATIC, isStatic); | 4238 setModifier(Modifier.STATIC, isStatic); |
| 4226 } | 4239 } |
| 4227 | 4240 |
| 4228 @override | 4241 @override |
| 4229 bool operator ==(Object object) => super == object && | 4242 bool operator ==(Object object) => |
| 4243 super == object && |
| 4230 isGetter == (object as PropertyAccessorElement).isGetter; | 4244 isGetter == (object as PropertyAccessorElement).isGetter; |
| 4231 | 4245 |
| 4232 @override | 4246 @override |
| 4233 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this); | 4247 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this); |
| 4234 | 4248 |
| 4235 @override | 4249 @override |
| 4236 void appendTo(StringBuffer buffer) { | 4250 void appendTo(StringBuffer buffer) { |
| 4237 buffer.write(isGetter ? "get " : "set "); | 4251 buffer.write(isGetter ? "get " : "set "); |
| 4238 buffer.write(variable.displayName); | 4252 buffer.write(variable.displayName); |
| 4239 super.appendTo(buffer); | 4253 super.appendTo(buffer); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4562 | 4576 |
| 4563 @override | 4577 @override |
| 4564 void visitElement(Element element) { | 4578 void visitElement(Element element) { |
| 4565 int offset = element.nameOffset; | 4579 int offset = element.nameOffset; |
| 4566 if (offset != -1) { | 4580 if (offset != -1) { |
| 4567 map[offset] = element; | 4581 map[offset] = element; |
| 4568 } | 4582 } |
| 4569 super.visitElement(element); | 4583 super.visitElement(element); |
| 4570 } | 4584 } |
| 4571 } | 4585 } |
| OLD | NEW |