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 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 */ | 1555 */ |
1556 static String _DEPRECATED_CLASS_NAME = "Deprecated"; | 1556 static String _DEPRECATED_CLASS_NAME = "Deprecated"; |
1557 | 1557 |
1558 /** | 1558 /** |
1559 * The name of the top-level variable used to mark an element as being | 1559 * The name of the top-level variable used to mark an element as being |
1560 * deprecated. | 1560 * deprecated. |
1561 */ | 1561 */ |
1562 static String _DEPRECATED_VARIABLE_NAME = "deprecated"; | 1562 static String _DEPRECATED_VARIABLE_NAME = "deprecated"; |
1563 | 1563 |
1564 /** | 1564 /** |
| 1565 * The name of `meta` library, used to define analysis annotations. |
| 1566 */ |
| 1567 static String _META_LIB_NAME = "meta"; |
| 1568 |
| 1569 /** |
1565 * The name of the top-level variable used to mark a method as being expected | 1570 * The name of the top-level variable used to mark a method as being expected |
1566 * to override an inherited method. | 1571 * to override an inherited method. |
1567 */ | 1572 */ |
1568 static String _OVERRIDE_VARIABLE_NAME = "override"; | 1573 static String _OVERRIDE_VARIABLE_NAME = "override"; |
1569 | 1574 |
1570 /** | 1575 /** |
| 1576 * The name of the top-level variable used to mark a method as being |
| 1577 * protected. |
| 1578 */ |
| 1579 static String _PROTECTED_VARIABLE_NAME = "protected"; |
| 1580 |
| 1581 /** |
1571 * The name of the top-level variable used to mark a class as implementing a | 1582 * The name of the top-level variable used to mark a class as implementing a |
1572 * proxy object. | 1583 * proxy object. |
1573 */ | 1584 */ |
1574 static String PROXY_VARIABLE_NAME = "proxy"; | 1585 static String PROXY_VARIABLE_NAME = "proxy"; |
1575 | 1586 |
1576 /** | 1587 /** |
1577 * The element representing the field, variable, or constructor being used as | 1588 * The element representing the field, variable, or constructor being used as |
1578 * an annotation. | 1589 * an annotation. |
1579 */ | 1590 */ |
1580 Element element; | 1591 Element element; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 if (element is PropertyAccessorElement && | 1648 if (element is PropertyAccessorElement && |
1638 element.name == _OVERRIDE_VARIABLE_NAME) { | 1649 element.name == _OVERRIDE_VARIABLE_NAME) { |
1639 return true; | 1650 return true; |
1640 } | 1651 } |
1641 } | 1652 } |
1642 } | 1653 } |
1643 return false; | 1654 return false; |
1644 } | 1655 } |
1645 | 1656 |
1646 @override | 1657 @override |
| 1658 bool get isProtected { |
| 1659 if (element != null) { |
| 1660 LibraryElement library = element.library; |
| 1661 if (library != null && 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 |
| 1671 @override |
1647 bool get isProxy { | 1672 bool get isProxy { |
1648 if (element != null) { | 1673 if (element != null) { |
1649 LibraryElement library = element.library; | 1674 LibraryElement library = element.library; |
1650 if (library != null && library.isDartCore) { | 1675 if (library != null && library.isDartCore) { |
1651 if (element is PropertyAccessorElement && | 1676 if (element is PropertyAccessorElement && |
1652 element.name == PROXY_VARIABLE_NAME) { | 1677 element.name == PROXY_VARIABLE_NAME) { |
1653 return true; | 1678 return true; |
1654 } | 1679 } |
1655 } | 1680 } |
1656 } | 1681 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 @override | 1855 @override |
1831 bool get isPrivate { | 1856 bool get isPrivate { |
1832 String name = displayName; | 1857 String name = displayName; |
1833 if (name == null) { | 1858 if (name == null) { |
1834 return true; | 1859 return true; |
1835 } | 1860 } |
1836 return Identifier.isPrivateName(name); | 1861 return Identifier.isPrivateName(name); |
1837 } | 1862 } |
1838 | 1863 |
1839 @override | 1864 @override |
| 1865 bool get isProtected { |
| 1866 for (ElementAnnotation annotation in metadata) { |
| 1867 if (annotation.isProtected) { |
| 1868 return true; |
| 1869 } |
| 1870 } |
| 1871 return false; |
| 1872 } |
| 1873 |
| 1874 @override |
1840 bool get isPublic => !isPrivate; | 1875 bool get isPublic => !isPrivate; |
1841 | 1876 |
1842 @override | 1877 @override |
1843 bool get isSynthetic => hasModifier(Modifier.SYNTHETIC); | 1878 bool get isSynthetic => hasModifier(Modifier.SYNTHETIC); |
1844 | 1879 |
1845 @override | 1880 @override |
1846 LibraryElement get library => | 1881 LibraryElement get library => |
1847 getAncestor((element) => element is LibraryElement); | 1882 getAncestor((element) => element is LibraryElement); |
1848 | 1883 |
1849 @override | 1884 @override |
(...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3922 @override | 3957 @override |
3923 bool get isPrivate { | 3958 bool get isPrivate { |
3924 String name = displayName; | 3959 String name = displayName; |
3925 if (name == null) { | 3960 if (name == null) { |
3926 return false; | 3961 return false; |
3927 } | 3962 } |
3928 return Identifier.isPrivateName(name); | 3963 return Identifier.isPrivateName(name); |
3929 } | 3964 } |
3930 | 3965 |
3931 @override | 3966 @override |
| 3967 bool get isProtected => false; |
| 3968 |
| 3969 @override |
3932 bool get isPublic => !isPrivate; | 3970 bool get isPublic => !isPrivate; |
3933 | 3971 |
3934 @override | 3972 @override |
3935 bool get isSynthetic => true; | 3973 bool get isSynthetic => true; |
3936 | 3974 |
3937 @override | 3975 @override |
3938 ElementKind get kind => ElementKind.ERROR; | 3976 ElementKind get kind => ElementKind.ERROR; |
3939 | 3977 |
3940 @override | 3978 @override |
3941 LibraryElement get library => null; | 3979 LibraryElement get library => null; |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4804 | 4842 |
4805 @override | 4843 @override |
4806 void visitElement(Element element) { | 4844 void visitElement(Element element) { |
4807 int offset = element.nameOffset; | 4845 int offset = element.nameOffset; |
4808 if (offset != -1) { | 4846 if (offset != -1) { |
4809 map[offset] = element; | 4847 map[offset] = element; |
4810 } | 4848 } |
4811 super.visitElement(element); | 4849 super.visitElement(element); |
4812 } | 4850 } |
4813 } | 4851 } |
OLD | NEW |