| 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 engine.resolver; | 5 library engine.resolver; |
| 6 | 6 |
| 7 import "dart:math" as math; | 7 import "dart:math" as math; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/utilities_collection.dart'; | 10 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| (...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 * Check for the passed as expression for the [HintCode.UNNECESSARY_CAST] hint
code. | 1292 * Check for the passed as expression for the [HintCode.UNNECESSARY_CAST] hint
code. |
| 1293 * | 1293 * |
| 1294 * @param node the as expression to check | 1294 * @param node the as expression to check |
| 1295 * @return `true` if and only if a hint code is generated on the passed node | 1295 * @return `true` if and only if a hint code is generated on the passed node |
| 1296 * See [HintCode.UNNECESSARY_CAST]. | 1296 * See [HintCode.UNNECESSARY_CAST]. |
| 1297 */ | 1297 */ |
| 1298 bool _checkForUnnecessaryCast(AsExpression node) { | 1298 bool _checkForUnnecessaryCast(AsExpression node) { |
| 1299 // TODO(jwren) After dartbug.com/13732, revisit this, we should be able to | 1299 // TODO(jwren) After dartbug.com/13732, revisit this, we should be able to |
| 1300 // remove the (x is! TypeParameterType) checks. | 1300 // remove the (x is! TypeParameterType) checks. |
| 1301 AstNode parent = node.parent; | 1301 AstNode parent = node.parent; |
| 1302 if (parent is ConditionalExpression && (node == parent.thenExpression || nod
e == parent.elseExpression)) { | 1302 if (parent is ConditionalExpression && |
| 1303 (node == parent.thenExpression || node == parent.elseExpression)) { |
| 1303 Expression thenExpression = parent.thenExpression; | 1304 Expression thenExpression = parent.thenExpression; |
| 1304 DartType thenType; | 1305 DartType thenType; |
| 1305 if (thenExpression is AsExpression) { | 1306 if (thenExpression is AsExpression) { |
| 1306 thenType = thenExpression.expression.staticType; | 1307 thenType = thenExpression.expression.staticType; |
| 1307 } else { | 1308 } else { |
| 1308 thenType = thenExpression.staticType; | 1309 thenType = thenExpression.staticType; |
| 1309 } | 1310 } |
| 1310 Expression elseExpression = parent.elseExpression; | 1311 Expression elseExpression = parent.elseExpression; |
| 1311 DartType elseType; | 1312 DartType elseType; |
| 1312 if (elseExpression is AsExpression) { | 1313 if (elseExpression is AsExpression) { |
| (...skipping 3818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5131 unit.accept(new OverrideVerifier(_manager, errorReporter)); | 5132 unit.accept(new OverrideVerifier(_manager, errorReporter)); |
| 5132 // Find to-do comments | 5133 // Find to-do comments |
| 5133 new ToDoFinder(errorReporter).findIn(unit); | 5134 new ToDoFinder(errorReporter).findIn(unit); |
| 5134 // pub analysis | 5135 // pub analysis |
| 5135 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are | 5136 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are |
| 5136 // fixed | 5137 // fixed |
| 5137 // unit.accept(new PubVerifier(context, errorReporter)); | 5138 // unit.accept(new PubVerifier(context, errorReporter)); |
| 5138 } | 5139 } |
| 5139 } | 5140 } |
| 5140 | 5141 |
| 5142 |
| 5143 /** |
| 5144 * Traverses a library's worth of dart code at a time to generate lint warnings |
| 5145 * over the set of sources. |
| 5146 * |
| 5147 * See [LintCode]. |
| 5148 */ |
| 5149 class LintGenerator { |
| 5150 |
| 5151 final List<CompilationUnit> _compilationUnits; |
| 5152 final AnalysisErrorListener _errorListener; |
| 5153 |
| 5154 LintGenerator(this._compilationUnits, this._errorListener); |
| 5155 |
| 5156 void generate() { |
| 5157 TimeCounter_TimeCounterHandle timeCounter = |
| 5158 PerformanceStatistics.lint.start(); |
| 5159 try { |
| 5160 _compilationUnits.forEach((cu) { |
| 5161 if (cu.element != null) { |
| 5162 _generate(cu, cu.element.source); |
| 5163 } |
| 5164 }); |
| 5165 } finally { |
| 5166 timeCounter.stop(); |
| 5167 } |
| 5168 } |
| 5169 |
| 5170 void _generate(CompilationUnit unit, Source source) { |
| 5171 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); |
| 5172 unit.accept(new LintVerifier(errorReporter)); |
| 5173 } |
| 5174 } |
| 5175 |
| 5176 class LintVerifier extends RecursiveAstVisitor<Object> { |
| 5177 |
| 5178 final ErrorReporter _reporter; |
| 5179 |
| 5180 LintVerifier(this._reporter); |
| 5181 } |
| 5182 |
| 5183 |
| 5141 /** | 5184 /** |
| 5142 * Instances of the class {@code HtmlTagInfo} record information about the tags
used in an HTML | 5185 * Instances of the class {@code HtmlTagInfo} record information about the tags
used in an HTML |
| 5143 * file. | 5186 * file. |
| 5144 */ | 5187 */ |
| 5145 class HtmlTagInfo { | 5188 class HtmlTagInfo { |
| 5146 /** | 5189 /** |
| 5147 * An array containing all of the tags used in the HTML file. | 5190 * An array containing all of the tags used in the HTML file. |
| 5148 */ | 5191 */ |
| 5149 List<String> allTags; | 5192 List<String> allTags; |
| 5150 | 5193 |
| (...skipping 11258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16409 * library. | 16452 * library. |
| 16410 */ | 16453 */ |
| 16411 final HashSet<String> members = new HashSet<String>(); | 16454 final HashSet<String> members = new HashSet<String>(); |
| 16412 | 16455 |
| 16413 /** | 16456 /** |
| 16414 * Names of resolved or unresolved class members that are read in the | 16457 * Names of resolved or unresolved class members that are read in the |
| 16415 * library. | 16458 * library. |
| 16416 */ | 16459 */ |
| 16417 final HashSet<String> readMembers = new HashSet<String>(); | 16460 final HashSet<String> readMembers = new HashSet<String>(); |
| 16418 } | 16461 } |
| OLD | NEW |