Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(705)

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 1773803002: Validation of `@mustCallSuper` overrides. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 * deprecated. 1594 * deprecated.
1595 */ 1595 */
1596 static String _DEPRECATED_VARIABLE_NAME = "deprecated"; 1596 static String _DEPRECATED_VARIABLE_NAME = "deprecated";
1597 1597
1598 /** 1598 /**
1599 * The name of `meta` library, used to define analysis annotations. 1599 * The name of `meta` library, used to define analysis annotations.
1600 */ 1600 */
1601 static String _META_LIB_NAME = "meta"; 1601 static String _META_LIB_NAME = "meta";
1602 1602
1603 /** 1603 /**
1604 * The name of the top-level variable used to mark a method as requiring
1605 * overriders to call super.
1606 */
1607 static String _MUST_CALL_SUPER_VARIABLE_NAME = "mustCallSuper";
1608
1609 /**
1604 * The name of the top-level variable used to mark a method as being expected 1610 * The name of the top-level variable used to mark a method as being expected
1605 * to override an inherited method. 1611 * to override an inherited method.
1606 */ 1612 */
1607 static String _OVERRIDE_VARIABLE_NAME = "override"; 1613 static String _OVERRIDE_VARIABLE_NAME = "override";
1608 1614
1609 /** 1615 /**
1610 * The name of the top-level variable used to mark a method as being 1616 * The name of the top-level variable used to mark a method as being
1611 * protected. 1617 * protected.
1612 */ 1618 */
1613 static String _PROTECTED_VARIABLE_NAME = "protected"; 1619 static String _PROTECTED_VARIABLE_NAME = "protected";
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 if (element is ConstructorElement) { 1666 if (element is ConstructorElement) {
1661 return element.enclosingElement.name == _DEPRECATED_CLASS_NAME; 1667 return element.enclosingElement.name == _DEPRECATED_CLASS_NAME;
1662 } else if (element is PropertyAccessorElement) { 1668 } else if (element is PropertyAccessorElement) {
1663 return element.name == _DEPRECATED_VARIABLE_NAME; 1669 return element.name == _DEPRECATED_VARIABLE_NAME;
1664 } 1670 }
1665 } 1671 }
1666 return false; 1672 return false;
1667 } 1673 }
1668 1674
1669 @override 1675 @override
1676 bool get isMustCallSuper =>
1677 element is PropertyAccessorElement &&
1678 element.name == _MUST_CALL_SUPER_VARIABLE_NAME &&
1679 element.library?.name == _META_LIB_NAME;
1680
1681 @override
1670 bool get isOverride => 1682 bool get isOverride =>
1671 element is PropertyAccessorElement && 1683 element is PropertyAccessorElement &&
1672 element.name == _OVERRIDE_VARIABLE_NAME && 1684 element.name == _OVERRIDE_VARIABLE_NAME &&
1673 element.library?.isDartCore == true; 1685 element.library?.isDartCore == true;
1674 1686
1675 @override 1687 @override
1676 bool get isProtected => 1688 bool get isProtected =>
1677 element is PropertyAccessorElement && 1689 element is PropertyAccessorElement &&
1678 element.name == _PROTECTED_VARIABLE_NAME && 1690 element.name == _PROTECTED_VARIABLE_NAME &&
1679 element.library?.name == _META_LIB_NAME; 1691 element.library?.name == _META_LIB_NAME;
(...skipping 3218 matching lines...) Expand 10 before | Expand all | Expand 10 after
4898 4910
4899 @override 4911 @override
4900 void visitElement(Element element) { 4912 void visitElement(Element element) {
4901 int offset = element.nameOffset; 4913 int offset = element.nameOffset;
4902 if (offset != -1) { 4914 if (offset != -1) {
4903 map[offset] = element; 4915 map[offset] = element;
4904 } 4916 }
4905 super.visitElement(element); 4917 super.visitElement(element);
4906 } 4918 }
4907 } 4919 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698