| 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 test.services.correction.fix; | 5 library test.services.correction.fix; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; | 7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; |
| 8 import 'package:analysis_server/src/services/correction/fix.dart'; | 8 import 'package:analysis_server/src/services/correction/fix.dart'; |
| 9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
| 10 import 'package:analyzer/source/package_map_resolver.dart'; | 10 import 'package:analyzer/source/package_map_resolver.dart'; |
| (...skipping 3423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3434 new PackageMapUriResolver(provider, {'my_pkg': [myPkgFolder]}); | 3434 new PackageMapUriResolver(provider, {'my_pkg': [myPkgFolder]}); |
| 3435 context.sourceFactory = new SourceFactory( | 3435 context.sourceFactory = new SourceFactory( |
| 3436 [AbstractContextTest.SDK_RESOLVER, resourceResolver, pkgResolver]); | 3436 [AbstractContextTest.SDK_RESOLVER, resourceResolver, pkgResolver]); |
| 3437 // force 'my_pkg' resolution | 3437 // force 'my_pkg' resolution |
| 3438 addSource('/tmp/other.dart', "import 'package:my_pkg/my_lib.dart';"); | 3438 addSource('/tmp/other.dart', "import 'package:my_pkg/my_lib.dart';"); |
| 3439 } | 3439 } |
| 3440 | 3440 |
| 3441 AnalysisError _findErrorToFix() { | 3441 AnalysisError _findErrorToFix() { |
| 3442 List<AnalysisError> errors = context.computeErrors(testSource); | 3442 List<AnalysisError> errors = context.computeErrors(testSource); |
| 3443 errors.removeWhere((error) { | 3443 errors.removeWhere((error) { |
| 3444 return error.errorCode == HintCode.UNUSED_ELEMENT || | 3444 return error.errorCode == HintCode.UNUSED_CATCH_CLAUSE || |
| 3445 error.errorCode == HintCode.UNUSED_CATCH_STACK || |
| 3446 error.errorCode == HintCode.UNUSED_ELEMENT || |
| 3445 error.errorCode == HintCode.UNUSED_FIELD || | 3447 error.errorCode == HintCode.UNUSED_FIELD || |
| 3446 error.errorCode == HintCode.UNUSED_LOCAL_VARIABLE; | 3448 error.errorCode == HintCode.UNUSED_LOCAL_VARIABLE; |
| 3447 }); | 3449 }); |
| 3448 if (errorFilter != null) { | 3450 if (errorFilter != null) { |
| 3449 errors = errors.where(errorFilter).toList(); | 3451 errors = errors.where(errorFilter).toList(); |
| 3450 } | 3452 } |
| 3451 expect(errors, hasLength(1)); | 3453 expect(errors, hasLength(1)); |
| 3452 return errors[0]; | 3454 return errors[0]; |
| 3453 } | 3455 } |
| 3454 | 3456 |
| 3455 List<Position> _findResultPositions(List<String> searchStrings) { | 3457 List<Position> _findResultPositions(List<String> searchStrings) { |
| 3456 List<Position> positions = <Position>[]; | 3458 List<Position> positions = <Position>[]; |
| 3457 for (String search in searchStrings) { | 3459 for (String search in searchStrings) { |
| 3458 int offset = resultCode.indexOf(search); | 3460 int offset = resultCode.indexOf(search); |
| 3459 positions.add(new Position(testFile, offset)); | 3461 positions.add(new Position(testFile, offset)); |
| 3460 } | 3462 } |
| 3461 return positions; | 3463 return positions; |
| 3462 } | 3464 } |
| 3463 } | 3465 } |
| OLD | NEW |