Chromium Code Reviews| 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 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1584 */ | 1584 */ |
| 1585 static String PROXY_VARIABLE_NAME = "proxy"; | 1585 static String PROXY_VARIABLE_NAME = "proxy"; |
| 1586 | 1586 |
| 1587 /** | 1587 /** |
| 1588 * The element representing the field, variable, or constructor being used as | 1588 * The element representing the field, variable, or constructor being used as |
| 1589 * an annotation. | 1589 * an annotation. |
| 1590 */ | 1590 */ |
| 1591 Element element; | 1591 Element element; |
| 1592 | 1592 |
| 1593 /** | 1593 /** |
| 1594 * The compliation unit in which this annotation appears. | 1594 * The compilation unit in which this annotation appears. |
| 1595 */ | 1595 */ |
| 1596 final CompilationUnitElementImpl compilationUnit; | 1596 final CompilationUnitElementImpl compilationUnit; |
| 1597 | 1597 |
| 1598 /** | 1598 /** |
| 1599 * The AST of the annotation itself, cloned from the resolved AST for the | 1599 * The AST of the annotation itself, cloned from the resolved AST for the |
| 1600 * source code. | 1600 * source code. |
| 1601 */ | 1601 */ |
| 1602 Annotation annotationAst; | 1602 Annotation annotationAst; |
| 1603 | 1603 |
| 1604 /** | 1604 /** |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1615 ElementAnnotationImpl(this.compilationUnit); | 1615 ElementAnnotationImpl(this.compilationUnit); |
| 1616 | 1616 |
| 1617 @override | 1617 @override |
| 1618 DartObject get constantValue => evaluationResult?.value; | 1618 DartObject get constantValue => evaluationResult?.value; |
| 1619 | 1619 |
| 1620 @override | 1620 @override |
| 1621 AnalysisContext get context => compilationUnit.library.context; | 1621 AnalysisContext get context => compilationUnit.library.context; |
| 1622 | 1622 |
| 1623 @override | 1623 @override |
| 1624 bool get isDeprecated { | 1624 bool get isDeprecated { |
| 1625 if (element != null) { | 1625 if (element?.library?.isDartCore == true) { |
|
Brian Wilkerson
2016/02/25 17:02:12
I'm obviously not used to the null-aware operators
| |
| 1626 LibraryElement library = element.library; | 1626 if (element is ConstructorElement) { |
| 1627 if (library != null && library.isDartCore) { | 1627 return element.enclosingElement.name == _DEPRECATED_CLASS_NAME; |
| 1628 if (element is ConstructorElement) { | 1628 } else if (element is PropertyAccessorElement) { |
| 1629 ConstructorElement constructorElement = element as ConstructorElement; | 1629 return element.name == _DEPRECATED_VARIABLE_NAME; |
| 1630 if (constructorElement.enclosingElement.name == | |
| 1631 _DEPRECATED_CLASS_NAME) { | |
| 1632 return true; | |
| 1633 } | |
| 1634 } else if (element is PropertyAccessorElement && | |
| 1635 element.name == _DEPRECATED_VARIABLE_NAME) { | |
| 1636 return true; | |
| 1637 } | |
| 1638 } | 1630 } |
| 1639 } | 1631 } |
| 1640 return false; | 1632 return false; |
| 1641 } | 1633 } |
| 1642 | 1634 |
| 1643 @override | 1635 @override |
| 1644 bool get isOverride { | 1636 bool get isOverride => |
| 1645 if (element != null) { | 1637 element is PropertyAccessorElement && |
| 1646 LibraryElement library = element.library; | 1638 element.name == _OVERRIDE_VARIABLE_NAME && |
| 1647 if (library != null && library.isDartCore) { | 1639 element.library?.isDartCore == true; |
| 1648 if (element is PropertyAccessorElement && | |
| 1649 element.name == _OVERRIDE_VARIABLE_NAME) { | |
| 1650 return true; | |
| 1651 } | |
| 1652 } | |
| 1653 } | |
| 1654 return false; | |
| 1655 } | |
| 1656 | 1640 |
| 1657 @override | 1641 @override |
| 1658 bool get isProtected { | 1642 bool get isProtected => |
| 1659 if (element != null) { | 1643 element is PropertyAccessorElement && |
| 1660 LibraryElement library = element.library; | 1644 element.name == _PROTECTED_VARIABLE_NAME && |
| 1661 if (library != null && library.name == _META_LIB_NAME) { | 1645 element.library?.name == _META_LIB_NAME; |
| 1662 if (element is PropertyAccessorElement && | |
| 1663 element.name == _PROTECTED_VARIABLE_NAME) { | |
| 1664 return true; | |
| 1665 } | |
| 1666 } | |
| 1667 } | |
| 1668 return false; | |
| 1669 } | |
| 1670 | 1646 |
| 1671 @override | 1647 @override |
| 1672 bool get isProxy { | 1648 bool get isProxy => |
| 1673 if (element != null) { | 1649 element is PropertyAccessorElement && |
| 1674 LibraryElement library = element.library; | 1650 element.name == PROXY_VARIABLE_NAME && |
| 1675 if (library != null && library.isDartCore) { | 1651 element.library?.isDartCore == true; |
| 1676 if (element is PropertyAccessorElement && | |
| 1677 element.name == PROXY_VARIABLE_NAME) { | |
| 1678 return true; | |
| 1679 } | |
| 1680 } | |
| 1681 } | |
| 1682 return false; | |
| 1683 } | |
| 1684 | 1652 |
| 1685 /** | 1653 /** |
| 1686 * Get the library containing this annotation. | 1654 * Get the library containing this annotation. |
| 1687 */ | 1655 */ |
| 1688 Source get librarySource => compilationUnit.librarySource; | 1656 Source get librarySource => compilationUnit.librarySource; |
| 1689 | 1657 |
| 1690 @override | 1658 @override |
| 1691 Source get source => compilationUnit.source; | 1659 Source get source => compilationUnit.source; |
| 1692 | 1660 |
| 1693 @override | 1661 @override |
| (...skipping 3140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4834 | 4802 |
| 4835 @override | 4803 @override |
| 4836 void visitElement(Element element) { | 4804 void visitElement(Element element) { |
| 4837 int offset = element.nameOffset; | 4805 int offset = element.nameOffset; |
| 4838 if (offset != -1) { | 4806 if (offset != -1) { |
| 4839 map[offset] = element; | 4807 map[offset] = element; |
| 4840 } | 4808 } |
| 4841 super.visitElement(element); | 4809 super.visitElement(element); |
| 4842 } | 4810 } |
| 4843 } | 4811 } |
| OLD | NEW |