| 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 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2072       } | 2072       } | 
| 2073       if (element == null) { | 2073       if (element == null) { | 
| 2074         _errorReporter | 2074         _errorReporter | 
| 2075             .reportErrorForNode(hintCode, name, [library.identifier, nameStr]); | 2075             .reportErrorForNode(hintCode, name, [library.identifier, nameStr]); | 
| 2076       } | 2076       } | 
| 2077     } | 2077     } | 
| 2078   } | 2078   } | 
| 2079 | 2079 | 
| 2080   /** | 2080   /** | 
| 2081    * Given some [NodeList] of [Statement]s, from either a [Block] or | 2081    * Given some [NodeList] of [Statement]s, from either a [Block] or | 
| 2082    * [SwitchMember], this loops through the list in reverse order searching for 
       statements | 2082    * [SwitchMember], this loops through the list searching for dead statements. | 
| 2083    * after a return, unlabeled break or unlabeled continue statement to mark the
       m as dead code. |  | 
| 2084    * | 2083    * | 
| 2085    * @param statements some ordered list of statements in a [Block] or [SwitchMe
       mber] | 2084    * @param statements some ordered list of statements in a [Block] or [SwitchMe
       mber] | 
| 2086    */ | 2085    */ | 
| 2087   void _checkForDeadStatementsInNodeList(NodeList<Statement> statements) { | 2086   void _checkForDeadStatementsInNodeList(NodeList<Statement> statements) { | 
|  | 2087     bool statementExits(Statement statement) { | 
|  | 2088       if (statement is BreakStatement) { | 
|  | 2089         return statement.label == null; | 
|  | 2090       } else if (statement is ContinueStatement) { | 
|  | 2091         return statement.label == null; | 
|  | 2092       } | 
|  | 2093       return ExitDetector.exits(statement); | 
|  | 2094     } | 
|  | 2095 | 
| 2088     int size = statements.length; | 2096     int size = statements.length; | 
| 2089     for (int i = 0; i < size; i++) { | 2097     for (int i = 0; i < size; i++) { | 
| 2090       Statement currentStatement = statements[i]; | 2098       Statement currentStatement = statements[i]; | 
| 2091       currentStatement?.accept(this); | 2099       currentStatement?.accept(this); | 
| 2092       bool returnOrBreakingStatement = currentStatement is ReturnStatement || | 2100       if (statementExits(currentStatement) && i != size - 1) { | 
| 2093           (currentStatement is BreakStatement && |  | 
| 2094               currentStatement.label == null) || |  | 
| 2095           (currentStatement is ContinueStatement && |  | 
| 2096               currentStatement.label == null); |  | 
| 2097       if (returnOrBreakingStatement && i != size - 1) { |  | 
| 2098         Statement nextStatement = statements[i + 1]; | 2101         Statement nextStatement = statements[i + 1]; | 
| 2099         Statement lastStatement = statements[size - 1]; | 2102         Statement lastStatement = statements[size - 1]; | 
| 2100         int offset = nextStatement.offset; | 2103         int offset = nextStatement.offset; | 
| 2101         int length = lastStatement.end - offset; | 2104         int length = lastStatement.end - offset; | 
| 2102         _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE, offset, length); | 2105         _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE, offset, length); | 
| 2103         return; | 2106         return; | 
| 2104       } | 2107       } | 
| 2105     } | 2108     } | 
| 2106   } | 2109   } | 
| 2107 | 2110 | 
| (...skipping 8863 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 10971       return null; | 10974       return null; | 
| 10972     } | 10975     } | 
| 10973     if (identical(node.staticElement, variable)) { | 10976     if (identical(node.staticElement, variable)) { | 
| 10974       if (node.inSetterContext()) { | 10977       if (node.inSetterContext()) { | 
| 10975         result = true; | 10978         result = true; | 
| 10976       } | 10979       } | 
| 10977     } | 10980     } | 
| 10978     return null; | 10981     return null; | 
| 10979   } | 10982   } | 
| 10980 } | 10983 } | 
| OLD | NEW | 
|---|