| 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/edit/fix/fix_core.dart'; | 7 import 'package:analysis_server/edit/fix/fix_core.dart'; |
| 8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; | 8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; |
| 9 import 'package:analysis_server/src/services/correction/fix.dart'; | 9 import 'package:analysis_server/src/services/correction/fix.dart'; |
| 10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; | 10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; |
| (...skipping 4388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4399 * `/packages/my_pkg/lib` folder. | 4399 * `/packages/my_pkg/lib` folder. |
| 4400 */ | 4400 */ |
| 4401 void _configureMyPkg(String myLibCode) { | 4401 void _configureMyPkg(String myLibCode) { |
| 4402 provider.newFile('/packages/my_pkg/lib/my_lib.dart', myLibCode); | 4402 provider.newFile('/packages/my_pkg/lib/my_lib.dart', myLibCode); |
| 4403 // configure SourceFactory | 4403 // configure SourceFactory |
| 4404 Folder myPkgFolder = provider.getResource('/packages/my_pkg/lib'); | 4404 Folder myPkgFolder = provider.getResource('/packages/my_pkg/lib'); |
| 4405 UriResolver pkgResolver = new PackageMapUriResolver(provider, { | 4405 UriResolver pkgResolver = new PackageMapUriResolver(provider, { |
| 4406 'my_pkg': [myPkgFolder] | 4406 'my_pkg': [myPkgFolder] |
| 4407 }); | 4407 }); |
| 4408 context.sourceFactory = new SourceFactory( | 4408 context.sourceFactory = new SourceFactory( |
| 4409 [AbstractContextTest.SDK_RESOLVER, resourceResolver, pkgResolver]); | 4409 [AbstractContextTest.SDK_RESOLVER, pkgResolver, resourceResolver]); |
| 4410 // force 'my_pkg' resolution | 4410 // force 'my_pkg' resolution |
| 4411 addSource('/tmp/other.dart', "import 'package:my_pkg/my_lib.dart';"); | 4411 addSource('/tmp/other.dart', "import 'package:my_pkg/my_lib.dart';"); |
| 4412 } | 4412 } |
| 4413 | 4413 |
| 4414 AnalysisError _findErrorToFix() { | 4414 AnalysisError _findErrorToFix() { |
| 4415 List<AnalysisError> errors = context.computeErrors(testSource); | 4415 List<AnalysisError> errors = context.computeErrors(testSource); |
| 4416 if (errorFilter != null) { | 4416 if (errorFilter != null) { |
| 4417 errors = errors.where(errorFilter).toList(); | 4417 errors = errors.where(errorFilter).toList(); |
| 4418 } | 4418 } |
| 4419 expect(errors, hasLength(1)); | 4419 expect(errors, hasLength(1)); |
| 4420 return errors[0]; | 4420 return errors[0]; |
| 4421 } | 4421 } |
| 4422 | 4422 |
| 4423 List<Position> _findResultPositions(List<String> searchStrings) { | 4423 List<Position> _findResultPositions(List<String> searchStrings) { |
| 4424 List<Position> positions = <Position>[]; | 4424 List<Position> positions = <Position>[]; |
| 4425 for (String search in searchStrings) { | 4425 for (String search in searchStrings) { |
| 4426 int offset = resultCode.indexOf(search); | 4426 int offset = resultCode.indexOf(search); |
| 4427 positions.add(new Position(testFile, offset)); | 4427 positions.add(new Position(testFile, offset)); |
| 4428 } | 4428 } |
| 4429 return positions; | 4429 return positions; |
| 4430 } | 4430 } |
| 4431 | 4431 |
| 4432 void _performAnalysis() { | 4432 void _performAnalysis() { |
| 4433 while (context.performAnalysisTask().hasMoreWork); | 4433 while (context.performAnalysisTask().hasMoreWork); |
| 4434 } | 4434 } |
| 4435 } | 4435 } |
| OLD | NEW |