| 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 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; | 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; |
| 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; | |
| 11 import 'package:analysis_server/plugin/protocol/protocol.dart' | 10 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| 12 hide AnalysisError; | 11 hide AnalysisError; |
| 13 import 'package:analysis_server/src/services/correction/fix.dart'; | 12 import 'package:analysis_server/src/services/correction/fix.dart'; |
| 14 import 'package:analysis_server/src/services/correction/fix_internal.dart'; | 13 import 'package:analysis_server/src/services/correction/fix_internal.dart'; |
| 15 import 'package:analyzer/error/error.dart'; | 14 import 'package:analyzer/error/error.dart'; |
| 16 import 'package:analyzer/file_system/file_system.dart'; | 15 import 'package:analyzer/file_system/file_system.dart'; |
| 17 import 'package:analyzer/source/package_map_resolver.dart'; | 16 import 'package:analyzer/source/package_map_resolver.dart'; |
| 18 import 'package:analyzer/src/error/codes.dart'; | 17 import 'package:analyzer/src/error/codes.dart'; |
| 19 import 'package:analyzer/src/generated/parser.dart'; | 18 import 'package:analyzer/src/generated/parser.dart'; |
| 20 import 'package:analyzer/src/generated/source.dart'; | 19 import 'package:analyzer/src/generated/source.dart'; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 expect(group.positions, unorderedEquals(expectedPositions)); | 134 expect(group.positions, unorderedEquals(expectedPositions)); |
| 136 if (expectedSuggestions != null) { | 135 if (expectedSuggestions != null) { |
| 137 expect(group.suggestions, unorderedEquals(expectedSuggestions)); | 136 expect(group.suggestions, unorderedEquals(expectedSuggestions)); |
| 138 } | 137 } |
| 139 } | 138 } |
| 140 | 139 |
| 141 /** | 140 /** |
| 142 * Computes fixes for the given [error] in [testUnit]. | 141 * Computes fixes for the given [error] in [testUnit]. |
| 143 */ | 142 */ |
| 144 Future<List<Fix>> _computeFixes(AnalysisError error) async { | 143 Future<List<Fix>> _computeFixes(AnalysisError error) async { |
| 145 DartFixContext dartContext = new DartFixContextImpl( | 144 FixContextImpl fixContext = new FixContextImpl(provider, context, error); |
| 146 new FixContextImpl(provider, context, error), testUnit); | 145 DefaultFixContributor contributor = new DefaultFixContributor(); |
| 147 FixProcessor processor = new FixProcessor(dartContext); | 146 return contributor.computeFixes(fixContext); |
| 148 return processor.compute(); | |
| 149 } | 147 } |
| 150 | 148 |
| 151 /** | 149 /** |
| 152 * Configures the [SourceFactory] to have the `my_pkg` package in | 150 * Configures the [SourceFactory] to have the `my_pkg` package in |
| 153 * `/packages/my_pkg/lib` folder. | 151 * `/packages/my_pkg/lib` folder. |
| 154 */ | 152 */ |
| 155 void _configureMyPkg(Map<String, String> pathToCode) { | 153 void _configureMyPkg(Map<String, String> pathToCode) { |
| 156 pathToCode.forEach((path, code) { | 154 pathToCode.forEach((path, code) { |
| 157 provider.newFile('/packages/my_pkg/lib/$path', code); | 155 provider.newFile('/packages/my_pkg/lib/$path', code); |
| 158 }); | 156 }); |
| (...skipping 5344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5503 var v = 42; | 5501 var v = 42; |
| 5504 print('v: $v'); | 5502 print('v: $v'); |
| 5505 } | 5503 } |
| 5506 '''); | 5504 '''); |
| 5507 } | 5505 } |
| 5508 | 5506 |
| 5509 void verifyResult(String expectedResult) { | 5507 void verifyResult(String expectedResult) { |
| 5510 expect(resultCode, expectedResult); | 5508 expect(resultCode, expectedResult); |
| 5511 } | 5509 } |
| 5512 } | 5510 } |
| OLD | NEW |