| 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 4397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4408 // dead code analysis | 4408 // dead code analysis |
| 4409 unit.accept(new DeadCodeVerifier(errorReporter)); | 4409 unit.accept(new DeadCodeVerifier(errorReporter)); |
| 4410 unit.accept(_usedElementsVisitor); | 4410 unit.accept(_usedElementsVisitor); |
| 4411 // dart2js analysis | 4411 // dart2js analysis |
| 4412 if (_enableDart2JSHints) { | 4412 if (_enableDart2JSHints) { |
| 4413 unit.accept(new Dart2JSVerifier(errorReporter)); | 4413 unit.accept(new Dart2JSVerifier(errorReporter)); |
| 4414 } | 4414 } |
| 4415 // Dart best practices | 4415 // Dart best practices |
| 4416 unit.accept( | 4416 unit.accept( |
| 4417 new BestPracticesVerifier(errorReporter, _context.typeProvider)); | 4417 new BestPracticesVerifier(errorReporter, _context.typeProvider)); |
| 4418 unit.accept(new OverrideVerifier(_manager, errorReporter)); | 4418 unit.accept(new OverrideVerifier(errorReporter, _manager)); |
| 4419 // Find to-do comments | 4419 // Find to-do comments |
| 4420 new ToDoFinder(errorReporter).findIn(unit); | 4420 new ToDoFinder(errorReporter).findIn(unit); |
| 4421 // pub analysis | 4421 // pub analysis |
| 4422 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are | 4422 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are |
| 4423 // fixed | 4423 // fixed |
| 4424 // unit.accept(new PubVerifier(context, errorReporter)); | 4424 // unit.accept(new PubVerifier(context, errorReporter)); |
| 4425 } | 4425 } |
| 4426 } | 4426 } |
| 4427 | 4427 |
| 4428 /** | 4428 /** |
| (...skipping 5058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9487 return newNames; | 9487 return newNames; |
| 9488 } | 9488 } |
| 9489 } | 9489 } |
| 9490 | 9490 |
| 9491 /** | 9491 /** |
| 9492 * Instances of the class `OverrideVerifier` visit all of the declarations in a
compilation | 9492 * Instances of the class `OverrideVerifier` visit all of the declarations in a
compilation |
| 9493 * unit to verify that if they have an override annotation it is being used corr
ectly. | 9493 * unit to verify that if they have an override annotation it is being used corr
ectly. |
| 9494 */ | 9494 */ |
| 9495 class OverrideVerifier extends RecursiveAstVisitor<Object> { | 9495 class OverrideVerifier extends RecursiveAstVisitor<Object> { |
| 9496 /** | 9496 /** |
| 9497 * The error reporter used to report errors. |
| 9498 */ |
| 9499 final ErrorReporter _errorReporter; |
| 9500 |
| 9501 /** |
| 9497 * The inheritance manager used to find overridden methods. | 9502 * The inheritance manager used to find overridden methods. |
| 9498 */ | 9503 */ |
| 9499 final InheritanceManager _manager; | 9504 final InheritanceManager _manager; |
| 9500 | 9505 |
| 9501 /** | 9506 /** |
| 9502 * The error reporter used to report errors. | |
| 9503 */ | |
| 9504 final ErrorReporter _errorReporter; | |
| 9505 | |
| 9506 /** | |
| 9507 * Initialize a newly created verifier to look for inappropriate uses of the o
verride annotation. | 9507 * Initialize a newly created verifier to look for inappropriate uses of the o
verride annotation. |
| 9508 * | 9508 * |
| 9509 * @param errorReporter the error reporter used to report errors |
| 9509 * @param manager the inheritance manager used to find overridden methods | 9510 * @param manager the inheritance manager used to find overridden methods |
| 9510 * @param errorReporter the error reporter used to report errors | |
| 9511 */ | 9511 */ |
| 9512 OverrideVerifier(this._manager, this._errorReporter); | 9512 OverrideVerifier(this._errorReporter, this._manager); |
| 9513 | 9513 |
| 9514 @override | 9514 @override |
| 9515 Object visitMethodDeclaration(MethodDeclaration node) { | 9515 Object visitMethodDeclaration(MethodDeclaration node) { |
| 9516 ExecutableElement element = node.element; | 9516 ExecutableElement element = node.element; |
| 9517 if (_isOverride(element)) { | 9517 if (_isOverride(element)) { |
| 9518 if (_getOverriddenMember(element) == null) { | 9518 if (_getOverriddenMember(element) == null) { |
| 9519 if (element is MethodElement) { | 9519 if (element is MethodElement) { |
| 9520 _errorReporter.reportErrorForNode( | 9520 _errorReporter.reportErrorForNode( |
| 9521 HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD, node.name); | 9521 HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD, node.name); |
| 9522 } else if (element is PropertyAccessorElement) { | 9522 } else if (element is PropertyAccessorElement) { |
| (...skipping 5882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15405 } | 15405 } |
| 15406 | 15406 |
| 15407 bool isCatchException(LocalVariableElement element) { | 15407 bool isCatchException(LocalVariableElement element) { |
| 15408 return catchExceptionElements.contains(element); | 15408 return catchExceptionElements.contains(element); |
| 15409 } | 15409 } |
| 15410 | 15410 |
| 15411 bool isCatchStackTrace(LocalVariableElement element) { | 15411 bool isCatchStackTrace(LocalVariableElement element) { |
| 15412 return catchStackTraceElements.contains(element); | 15412 return catchStackTraceElements.contains(element); |
| 15413 } | 15413 } |
| 15414 } | 15414 } |
| OLD | NEW |