| 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.generated.resolver; | 5 library analyzer.src.generated.resolver; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 return true; | 690 return true; |
| 691 } | 691 } |
| 692 if (element is MethodElement && | 692 if (element is MethodElement && |
| 693 element.enclosingElement is ClassElement && | 693 element.enclosingElement is ClassElement && |
| 694 element.isProtected) { | 694 element.isProtected) { |
| 695 return true; | 695 return true; |
| 696 } | 696 } |
| 697 return false; | 697 return false; |
| 698 } | 698 } |
| 699 | 699 |
| 700 bool inCommentReference(SimpleIdentifier identifier) => |
| 701 identifier.getAncestor((AstNode node) => node is CommentReference) != |
| 702 null; |
| 703 |
| 700 Element element = identifier.bestElement; | 704 Element element = identifier.bestElement; |
| 701 if (isProtected(element)) { | 705 if (isProtected(element) && !inCommentReference(identifier)) { |
| 702 ClassElement definingClass = element.enclosingElement; | 706 ClassElement definingClass = element.enclosingElement; |
| 703 ClassDeclaration accessingClass = | 707 ClassDeclaration accessingClass = |
| 704 identifier.getAncestor((AstNode node) => node is ClassDeclaration); | 708 identifier.getAncestor((AstNode node) => node is ClassDeclaration); |
| 705 if (accessingClass == null || | 709 if (accessingClass == null || |
| 706 !_hasTypeOrSuperType(accessingClass.element, definingClass.type)) { | 710 !_hasTypeOrSuperType(accessingClass.element, definingClass.type)) { |
| 707 _errorReporter.reportErrorForNode( | 711 _errorReporter.reportErrorForNode( |
| 708 HintCode.INVALID_USE_OF_PROTECTED_MEMBER, | 712 HintCode.INVALID_USE_OF_PROTECTED_MEMBER, |
| 709 identifier, | 713 identifier, |
| 710 [identifier.name.toString(), definingClass.name]); | 714 [identifier.name.toString(), definingClass.name]); |
| 711 } | 715 } |
| (...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2042 | 2046 |
| 2043 /** | 2047 /** |
| 2044 * Given some [NodeList] of [Statement]s, from either a [Block] or | 2048 * Given some [NodeList] of [Statement]s, from either a [Block] or |
| 2045 * [SwitchMember], this loops through the list searching for dead statements. | 2049 * [SwitchMember], this loops through the list searching for dead statements. |
| 2046 * | 2050 * |
| 2047 * @param statements some ordered list of statements in a [Block] or [SwitchMe
mber] | 2051 * @param statements some ordered list of statements in a [Block] or [SwitchMe
mber] |
| 2048 * @param allowMandated allow dead statements mandated by the language spec. | 2052 * @param allowMandated allow dead statements mandated by the language spec. |
| 2049 * This allows for a final break, continue, return, or throw statem
ent | 2053 * This allows for a final break, continue, return, or throw statem
ent |
| 2050 * at the end of a switch case, that are mandated by the language s
pec. | 2054 * at the end of a switch case, that are mandated by the language s
pec. |
| 2051 */ | 2055 */ |
| 2052 void _checkForDeadStatementsInNodeList( | 2056 void _checkForDeadStatementsInNodeList(NodeList<Statement> statements, |
| 2053 NodeList<Statement> statements, {bool allowMandated: false}) { | 2057 {bool allowMandated: false}) { |
| 2054 bool statementExits(Statement statement) { | 2058 bool statementExits(Statement statement) { |
| 2055 if (statement is BreakStatement) { | 2059 if (statement is BreakStatement) { |
| 2056 return statement.label == null; | 2060 return statement.label == null; |
| 2057 } else if (statement is ContinueStatement) { | 2061 } else if (statement is ContinueStatement) { |
| 2058 return statement.label == null; | 2062 return statement.label == null; |
| 2059 } | 2063 } |
| 2060 return ExitDetector.exits(statement); | 2064 return ExitDetector.exits(statement); |
| 2061 } | 2065 } |
| 2062 | 2066 |
| 2063 int size = statements.length; | 2067 int size = statements.length; |
| (...skipping 8891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10955 return null; | 10959 return null; |
| 10956 } | 10960 } |
| 10957 if (identical(node.staticElement, variable)) { | 10961 if (identical(node.staticElement, variable)) { |
| 10958 if (node.inSetterContext()) { | 10962 if (node.inSetterContext()) { |
| 10959 result = true; | 10963 result = true; |
| 10960 } | 10964 } |
| 10961 } | 10965 } |
| 10962 return null; | 10966 return null; |
| 10963 } | 10967 } |
| 10964 } | 10968 } |
| OLD | NEW |