| 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'; | 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; |
| (...skipping 4041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4052 } | 4052 } |
| 4053 '''); | 4053 '''); |
| 4054 await assertHasFix( | 4054 await assertHasFix( |
| 4055 DartFixKind.REMOVE_UNUSED_IMPORT, | 4055 DartFixKind.REMOVE_UNUSED_IMPORT, |
| 4056 ''' | 4056 ''' |
| 4057 main() { | 4057 main() { |
| 4058 } | 4058 } |
| 4059 '''); | 4059 '''); |
| 4060 } | 4060 } |
| 4061 | 4061 |
| 4062 test_replaceImportUri_inProject() async { | |
| 4063 testFile = '/project/bin/test.dart'; | |
| 4064 addSource('/project/foo/bar/lib.dart', ''); | |
| 4065 await resolveTestUnit(''' | |
| 4066 import 'no/matter/lib.dart'; | |
| 4067 '''); | |
| 4068 performAllAnalysisTasks(); | |
| 4069 await assertHasFix( | |
| 4070 DartFixKind.REPLACE_IMPORT_URI, | |
| 4071 ''' | |
| 4072 import '../foo/bar/lib.dart'; | |
| 4073 '''); | |
| 4074 } | |
| 4075 | |
| 4076 test_replaceImportUri_package() async { | |
| 4077 _configureMyPkg({'my_lib.dart': ''}); | |
| 4078 await resolveTestUnit(''' | |
| 4079 import 'no/matter/my_lib.dart'; | |
| 4080 '''); | |
| 4081 performAllAnalysisTasks(); | |
| 4082 await assertHasFix( | |
| 4083 DartFixKind.REPLACE_IMPORT_URI, | |
| 4084 ''' | |
| 4085 import 'package:my_pkg/my_lib.dart'; | |
| 4086 '''); | |
| 4087 } | |
| 4088 | |
| 4089 test_replaceVarWithDynamic() async { | 4062 test_replaceVarWithDynamic() async { |
| 4090 errorFilter = (AnalysisError error) { | 4063 errorFilter = (AnalysisError error) { |
| 4091 return error.errorCode == ParserErrorCode.VAR_AS_TYPE_NAME; | 4064 return error.errorCode == ParserErrorCode.VAR_AS_TYPE_NAME; |
| 4092 }; | 4065 }; |
| 4093 await resolveTestUnit(''' | 4066 await resolveTestUnit(''' |
| 4094 class A { | 4067 class A { |
| 4095 Map<String, var> m; | 4068 Map<String, var> m; |
| 4096 } | 4069 } |
| 4097 '''); | 4070 '''); |
| 4098 await assertHasFix( | 4071 await assertHasFix( |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5385 @override | 5358 @override |
| 5386 test_addPartOfDirective() { | 5359 test_addPartOfDirective() { |
| 5387 return super.test_addPartOfDirective(); | 5360 return super.test_addPartOfDirective(); |
| 5388 } | 5361 } |
| 5389 | 5362 |
| 5390 @failingTest | 5363 @failingTest |
| 5391 @override | 5364 @override |
| 5392 test_createFile_forPart_inPackageLib() { | 5365 test_createFile_forPart_inPackageLib() { |
| 5393 return super.test_createFile_forPart_inPackageLib(); | 5366 return super.test_createFile_forPart_inPackageLib(); |
| 5394 } | 5367 } |
| 5395 | |
| 5396 @failingTest | |
| 5397 @override | |
| 5398 test_replaceImportUri_inProject() { | |
| 5399 return super.test_replaceImportUri_inProject(); | |
| 5400 } | |
| 5401 | |
| 5402 @failingTest | |
| 5403 @override | |
| 5404 test_replaceImportUri_package() { | |
| 5405 return super.test_replaceImportUri_package(); | |
| 5406 } | |
| 5407 } | 5368 } |
| 5408 | 5369 |
| 5409 @reflectiveTest | 5370 @reflectiveTest |
| 5410 class LintFixTest extends BaseFixProcessorTest { | 5371 class LintFixTest extends BaseFixProcessorTest { |
| 5411 AnalysisError error; | 5372 AnalysisError error; |
| 5412 | 5373 |
| 5413 Future applyFix(FixKind kind) async { | 5374 Future applyFix(FixKind kind) async { |
| 5414 fix = await _assertHasFix(kind, error); | 5375 fix = await _assertHasFix(kind, error); |
| 5415 change = fix.change; | 5376 change = fix.change; |
| 5416 // apply to "file" | 5377 // apply to "file" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5652 | 5613 |
| 5653 @override | 5614 @override |
| 5654 final CompilationUnit unit; | 5615 final CompilationUnit unit; |
| 5655 | 5616 |
| 5656 @override | 5617 @override |
| 5657 final AnalysisError error; | 5618 final AnalysisError error; |
| 5658 | 5619 |
| 5659 _DartFixContextImpl(this.resourceProvider, this.getTopLevelDeclarations, | 5620 _DartFixContextImpl(this.resourceProvider, this.getTopLevelDeclarations, |
| 5660 this.analysisContext, this.unit, this.error); | 5621 this.analysisContext, this.unit, this.error); |
| 5661 } | 5622 } |
| OLD | NEW |