| 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 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 */ | 1613 */ |
| 1614 static String _DEPRECATED_CLASS_NAME = "Deprecated"; | 1614 static String _DEPRECATED_CLASS_NAME = "Deprecated"; |
| 1615 | 1615 |
| 1616 /** | 1616 /** |
| 1617 * The name of the top-level variable used to mark an element as being | 1617 * The name of the top-level variable used to mark an element as being |
| 1618 * deprecated. | 1618 * deprecated. |
| 1619 */ | 1619 */ |
| 1620 static String _DEPRECATED_VARIABLE_NAME = "deprecated"; | 1620 static String _DEPRECATED_VARIABLE_NAME = "deprecated"; |
| 1621 | 1621 |
| 1622 /** | 1622 /** |
| 1623 * The name of the class used to JS annotate an element. |
| 1624 */ |
| 1625 static String _JS_CLASS_NAME = "JS"; |
| 1626 |
| 1627 /** |
| 1628 * The name of `js` library, used to define JS annotations. |
| 1629 */ |
| 1630 static String _JS_LIB_NAME = "js"; |
| 1631 |
| 1632 /** |
| 1623 * The name of `meta` library, used to define analysis annotations. | 1633 * The name of `meta` library, used to define analysis annotations. |
| 1624 */ | 1634 */ |
| 1625 static String _META_LIB_NAME = "meta"; | 1635 static String _META_LIB_NAME = "meta"; |
| 1626 | 1636 |
| 1627 /** | 1637 /** |
| 1628 * The name of the top-level variable used to mark a method as requiring | 1638 * The name of the top-level variable used to mark a method as requiring |
| 1629 * overriders to call super. | 1639 * overriders to call super. |
| 1630 */ | 1640 */ |
| 1631 static String _MUST_CALL_SUPER_VARIABLE_NAME = "mustCallSuper"; | 1641 static String _MUST_CALL_SUPER_VARIABLE_NAME = "mustCallSuper"; |
| 1632 | 1642 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 if (element is ConstructorElement) { | 1711 if (element is ConstructorElement) { |
| 1702 return element.enclosingElement.name == _DEPRECATED_CLASS_NAME; | 1712 return element.enclosingElement.name == _DEPRECATED_CLASS_NAME; |
| 1703 } else if (element is PropertyAccessorElement) { | 1713 } else if (element is PropertyAccessorElement) { |
| 1704 return element.name == _DEPRECATED_VARIABLE_NAME; | 1714 return element.name == _DEPRECATED_VARIABLE_NAME; |
| 1705 } | 1715 } |
| 1706 } | 1716 } |
| 1707 return false; | 1717 return false; |
| 1708 } | 1718 } |
| 1709 | 1719 |
| 1710 @override | 1720 @override |
| 1721 bool get isJS => element is ConstructorElement && |
| 1722 element.enclosingElement.name == _JS_CLASS_NAME && |
| 1723 element.library?.name == _JS_LIB_NAME; |
| 1724 |
| 1725 @override |
| 1711 bool get isMustCallSuper => | 1726 bool get isMustCallSuper => |
| 1712 element is PropertyAccessorElement && | 1727 element is PropertyAccessorElement && |
| 1713 element.name == _MUST_CALL_SUPER_VARIABLE_NAME && | 1728 element.name == _MUST_CALL_SUPER_VARIABLE_NAME && |
| 1714 element.library?.name == _META_LIB_NAME; | 1729 element.library?.name == _META_LIB_NAME; |
| 1715 | 1730 |
| 1716 @override | 1731 @override |
| 1717 bool get isOverride => | 1732 bool get isOverride => |
| 1718 element is PropertyAccessorElement && | 1733 element is PropertyAccessorElement && |
| 1719 element.name == _OVERRIDE_VARIABLE_NAME && | 1734 element.name == _OVERRIDE_VARIABLE_NAME && |
| 1720 element.library?.isDartCore == true; | 1735 element.library?.isDartCore == true; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1916 bool get isDeprecated { | 1931 bool get isDeprecated { |
| 1917 for (ElementAnnotation annotation in metadata) { | 1932 for (ElementAnnotation annotation in metadata) { |
| 1918 if (annotation.isDeprecated) { | 1933 if (annotation.isDeprecated) { |
| 1919 return true; | 1934 return true; |
| 1920 } | 1935 } |
| 1921 } | 1936 } |
| 1922 return false; | 1937 return false; |
| 1923 } | 1938 } |
| 1924 | 1939 |
| 1925 @override | 1940 @override |
| 1941 bool get isJS { |
| 1942 for (ElementAnnotation annotation in metadata) { |
| 1943 if (annotation.isJS) { |
| 1944 return true; |
| 1945 } |
| 1946 } |
| 1947 return false; |
| 1948 } |
| 1949 |
| 1950 @override |
| 1926 bool get isOverride { | 1951 bool get isOverride { |
| 1927 for (ElementAnnotation annotation in metadata) { | 1952 for (ElementAnnotation annotation in metadata) { |
| 1928 if (annotation.isOverride) { | 1953 if (annotation.isOverride) { |
| 1929 return true; | 1954 return true; |
| 1930 } | 1955 } |
| 1931 } | 1956 } |
| 1932 return false; | 1957 return false; |
| 1933 } | 1958 } |
| 1934 | 1959 |
| 1935 @override | 1960 @override |
| (...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4098 @override | 4123 @override |
| 4099 String get documentationComment => null; | 4124 String get documentationComment => null; |
| 4100 | 4125 |
| 4101 @override | 4126 @override |
| 4102 Element get enclosingElement => null; | 4127 Element get enclosingElement => null; |
| 4103 | 4128 |
| 4104 @override | 4129 @override |
| 4105 bool get isDeprecated => false; | 4130 bool get isDeprecated => false; |
| 4106 | 4131 |
| 4107 @override | 4132 @override |
| 4133 bool get isJS => false; |
| 4134 |
| 4135 @override |
| 4108 bool get isOverride => false; | 4136 bool get isOverride => false; |
| 4109 | 4137 |
| 4110 @override | 4138 @override |
| 4111 bool get isPrivate { | 4139 bool get isPrivate { |
| 4112 String name = displayName; | 4140 String name = displayName; |
| 4113 if (name == null) { | 4141 if (name == null) { |
| 4114 return false; | 4142 return false; |
| 4115 } | 4143 } |
| 4116 return Identifier.isPrivateName(name); | 4144 return Identifier.isPrivateName(name); |
| 4117 } | 4145 } |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4998 | 5026 |
| 4999 @override | 5027 @override |
| 5000 void visitElement(Element element) { | 5028 void visitElement(Element element) { |
| 5001 int offset = element.nameOffset; | 5029 int offset = element.nameOffset; |
| 5002 if (offset != -1) { | 5030 if (offset != -1) { |
| 5003 map[offset] = element; | 5031 map[offset] = element; |
| 5004 } | 5032 } |
| 5005 super.visitElement(element); | 5033 super.visitElement(element); |
| 5006 } | 5034 } |
| 5007 } | 5035 } |
| OLD | NEW |