| 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 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1863 addTestSource( | 1863 addTestSource( |
| 1864 ''' | 1864 ''' |
| 1865 library my.lib; | 1865 library my.lib; |
| 1866 part 'my_part.dart'; | 1866 part 'my_part.dart'; |
| 1867 ''', | 1867 ''', |
| 1868 Uri.parse('package:my/test.dart')); | 1868 Uri.parse('package:my/test.dart')); |
| 1869 // configure SourceFactory | 1869 // configure SourceFactory |
| 1870 UriResolver pkgResolver = new PackageMapUriResolver(provider, { | 1870 UriResolver pkgResolver = new PackageMapUriResolver(provider, { |
| 1871 'my': <Folder>[provider.getResource('/my/lib')], | 1871 'my': <Folder>[provider.getResource('/my/lib')], |
| 1872 }); | 1872 }); |
| 1873 context.sourceFactory = new SourceFactory( | 1873 SourceFactory sourceFactory = new SourceFactory( |
| 1874 [AbstractContextTest.SDK_RESOLVER, pkgResolver, resourceResolver]); | 1874 [AbstractContextTest.SDK_RESOLVER, pkgResolver, resourceResolver]); |
| 1875 if (enableNewAnalysisDriver) { |
| 1876 driver.configure(sourceFactory: sourceFactory); |
| 1877 testUnit = (await driver.getResult(testFile)).unit; |
| 1878 } else { |
| 1879 context.sourceFactory = sourceFactory; |
| 1880 testUnit = await resolveLibraryUnit(testSource); |
| 1881 } |
| 1875 // prepare fix | 1882 // prepare fix |
| 1876 testUnit = await resolveLibraryUnit(testSource); | |
| 1877 AnalysisError error = await _findErrorToFix(); | 1883 AnalysisError error = await _findErrorToFix(); |
| 1878 fix = await _assertHasFix(DartFixKind.CREATE_FILE, error); | 1884 fix = await _assertHasFix(DartFixKind.CREATE_FILE, error); |
| 1879 change = fix.change; | 1885 change = fix.change; |
| 1880 // validate change | 1886 // validate change |
| 1881 List<SourceFileEdit> fileEdits = change.edits; | 1887 List<SourceFileEdit> fileEdits = change.edits; |
| 1882 expect(fileEdits, hasLength(1)); | 1888 expect(fileEdits, hasLength(1)); |
| 1883 SourceFileEdit fileEdit = change.edits[0]; | 1889 SourceFileEdit fileEdit = change.edits[0]; |
| 1884 expect(fileEdit.file, '/my/lib/my_part.dart'); | 1890 expect(fileEdit.file, '/my/lib/my_part.dart'); |
| 1885 expect(fileEdit.fileStamp, -1); | 1891 expect(fileEdit.fileStamp, -1); |
| 1886 expect(fileEdit.edits, hasLength(1)); | 1892 expect(fileEdit.edits, hasLength(1)); |
| (...skipping 3426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5313 print(pref.PI); | 5319 print(pref.PI); |
| 5314 } | 5320 } |
| 5315 '''); | 5321 '''); |
| 5316 } | 5322 } |
| 5317 } | 5323 } |
| 5318 | 5324 |
| 5319 @reflectiveTest | 5325 @reflectiveTest |
| 5320 class FixProcessorTest_Driver extends FixProcessorTest { | 5326 class FixProcessorTest_Driver extends FixProcessorTest { |
| 5321 @override | 5327 @override |
| 5322 bool get enableNewAnalysisDriver => true; | 5328 bool get enableNewAnalysisDriver => true; |
| 5323 | |
| 5324 @failingTest | |
| 5325 @override | |
| 5326 test_createFile_forPart_inPackageLib() { | |
| 5327 return super.test_createFile_forPart_inPackageLib(); | |
| 5328 } | |
| 5329 } | 5329 } |
| 5330 | 5330 |
| 5331 @reflectiveTest | 5331 @reflectiveTest |
| 5332 class LintFixTest extends BaseFixProcessorTest { | 5332 class LintFixTest extends BaseFixProcessorTest { |
| 5333 AnalysisError error; | 5333 AnalysisError error; |
| 5334 | 5334 |
| 5335 Future applyFix(FixKind kind) async { | 5335 Future applyFix(FixKind kind) async { |
| 5336 fix = await _assertHasFix(kind, error); | 5336 fix = await _assertHasFix(kind, error); |
| 5337 change = fix.change; | 5337 change = fix.change; |
| 5338 // apply to "file" | 5338 // apply to "file" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5574 | 5574 |
| 5575 @override | 5575 @override |
| 5576 final CompilationUnit unit; | 5576 final CompilationUnit unit; |
| 5577 | 5577 |
| 5578 @override | 5578 @override |
| 5579 final AnalysisError error; | 5579 final AnalysisError error; |
| 5580 | 5580 |
| 5581 _DartFixContextImpl(this.resourceProvider, this.getTopLevelDeclarations, | 5581 _DartFixContextImpl(this.resourceProvider, this.getTopLevelDeclarations, |
| 5582 this.analysisContext, this.unit, this.error); | 5582 this.analysisContext, this.unit, this.error); |
| 5583 } | 5583 } |
| OLD | NEW |