| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 7 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; |
| 8 import 'package:analyzer/file_system/file_system.dart'; | 8 import 'package:analyzer/file_system/file_system.dart'; |
| 9 import 'package:analyzer/source/package_map_resolver.dart'; | 9 import 'package:analyzer/source/package_map_resolver.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| 11 import 'package:analyzer/src/generated/source.dart'; | 11 import 'package:analyzer/src/generated/source.dart'; |
| 12 import 'package:test/test.dart'; |
| 12 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 13 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 13 | 14 |
| 14 import 'abstract_refactoring.dart'; | 15 import 'abstract_refactoring.dart'; |
| 15 | 16 |
| 16 main() { | 17 main() { |
| 17 defineReflectiveSuite(() { | 18 defineReflectiveSuite(() { |
| 18 defineReflectiveTests(MoveFileTest); | 19 defineReflectiveTests(MoveFileTest); |
| 19 }); | 20 }); |
| 20 } | 21 } |
| 21 | 22 |
| 22 @reflectiveTest | 23 @reflectiveTest |
| 23 class MoveFileTest extends RefactoringTest { | 24 class MoveFileTest extends RefactoringTest { |
| 24 MoveFileRefactoring refactoring; | 25 MoveFileRefactoring refactoring; |
| 25 | 26 |
| 26 @override | 27 @failingTest |
| 27 bool get enableNewAnalysisDriver => false; | |
| 28 | |
| 29 test_file_definingUnit() async { | 28 test_file_definingUnit() async { |
| 29 fail('The move file refactoring is not supported under the new driver'); |
| 30 String pathA = '/project/000/1111/a.dart'; | 30 String pathA = '/project/000/1111/a.dart'; |
| 31 String pathB = '/project/000/1111/b.dart'; | 31 String pathB = '/project/000/1111/b.dart'; |
| 32 String pathC = '/project/000/1111/22/c.dart'; | 32 String pathC = '/project/000/1111/22/c.dart'; |
| 33 String pathD = '/project/000/1111/333/d.dart'; | 33 String pathD = '/project/000/1111/333/d.dart'; |
| 34 testFile = '/project/000/1111/test.dart'; | 34 testFile = '/project/000/1111/test.dart'; |
| 35 addSource('/absolute/uri.dart', ''); | 35 addSource('/absolute/uri.dart', ''); |
| 36 addSource(pathA, 'part of lib;'); | 36 addSource(pathA, 'part of lib;'); |
| 37 addSource(pathB, "import 'test.dart';"); | 37 addSource(pathB, "import 'test.dart';"); |
| 38 addSource(pathC, ''); | 38 addSource(pathC, ''); |
| 39 addSource(pathD, ''); | 39 addSource(pathD, ''); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 57 ''' | 57 ''' |
| 58 library lib; | 58 library lib; |
| 59 import 'dart:math'; | 59 import 'dart:math'; |
| 60 import 'c.dart'; | 60 import 'c.dart'; |
| 61 export '../333/d.dart'; | 61 export '../333/d.dart'; |
| 62 part '../a.dart'; | 62 part '../a.dart'; |
| 63 part '/absolute/uri.dart'; | 63 part '/absolute/uri.dart'; |
| 64 '''); | 64 '''); |
| 65 } | 65 } |
| 66 | 66 |
| 67 @failingTest |
| 67 test_file_importedLibrary() async { | 68 test_file_importedLibrary() async { |
| 69 fail('The move file refactoring is not supported under the new driver'); |
| 68 String pathA = '/project/000/1111/a.dart'; | 70 String pathA = '/project/000/1111/a.dart'; |
| 69 testFile = '/project/000/1111/sub/folder/test.dart'; | 71 testFile = '/project/000/1111/sub/folder/test.dart'; |
| 70 addSource( | 72 addSource( |
| 71 pathA, | 73 pathA, |
| 72 ''' | 74 ''' |
| 73 import 'sub/folder/test.dart'; | 75 import 'sub/folder/test.dart'; |
| 74 '''); | 76 '''); |
| 75 addTestSource(''); | 77 addTestSource(''); |
| 76 _performAnalysis(); | 78 _performAnalysis(); |
| 77 // perform refactoring | 79 // perform refactoring |
| 78 _createRefactoring('/project/000/new/folder/name/new_name.dart'); | 80 _createRefactoring('/project/000/new/folder/name/new_name.dart'); |
| 79 await _assertSuccessfulRefactoring(); | 81 await _assertSuccessfulRefactoring(); |
| 80 assertFileChangeResult( | 82 assertFileChangeResult( |
| 81 pathA, | 83 pathA, |
| 82 ''' | 84 ''' |
| 83 import '../new/folder/name/new_name.dart'; | 85 import '../new/folder/name/new_name.dart'; |
| 84 '''); | 86 '''); |
| 85 assertNoFileChange(testFile); | 87 assertNoFileChange(testFile); |
| 86 } | 88 } |
| 87 | 89 |
| 90 @failingTest |
| 88 test_file_importedLibrary_down() async { | 91 test_file_importedLibrary_down() async { |
| 92 fail('The move file refactoring is not supported under the new driver'); |
| 89 String pathA = '/project/000/1111/a.dart'; | 93 String pathA = '/project/000/1111/a.dart'; |
| 90 testFile = '/project/000/1111/test.dart'; | 94 testFile = '/project/000/1111/test.dart'; |
| 91 addSource( | 95 addSource( |
| 92 pathA, | 96 pathA, |
| 93 ''' | 97 ''' |
| 94 import 'test.dart'; | 98 import 'test.dart'; |
| 95 '''); | 99 '''); |
| 96 addTestSource(''); | 100 addTestSource(''); |
| 97 _performAnalysis(); | 101 _performAnalysis(); |
| 98 // perform refactoring | 102 // perform refactoring |
| 99 _createRefactoring('/project/000/1111/22/new_name.dart'); | 103 _createRefactoring('/project/000/1111/22/new_name.dart'); |
| 100 await _assertSuccessfulRefactoring(); | 104 await _assertSuccessfulRefactoring(); |
| 101 assertFileChangeResult( | 105 assertFileChangeResult( |
| 102 pathA, | 106 pathA, |
| 103 ''' | 107 ''' |
| 104 import '22/new_name.dart'; | 108 import '22/new_name.dart'; |
| 105 '''); | 109 '''); |
| 106 assertNoFileChange(testFile); | 110 assertNoFileChange(testFile); |
| 107 } | 111 } |
| 108 | 112 |
| 113 @failingTest |
| 109 test_file_importedLibrary_package() async { | 114 test_file_importedLibrary_package() async { |
| 115 fail('The move file refactoring is not supported under the new driver'); |
| 110 // configure packages | 116 // configure packages |
| 111 testFile = '/packages/my_pkg/lib/aaa/test.dart'; | 117 testFile = '/packages/my_pkg/lib/aaa/test.dart'; |
| 112 provider.newFile(testFile, ''); | 118 provider.newFile(testFile, ''); |
| 113 Map<String, List<Folder>> packageMap = { | 119 Map<String, List<Folder>> packageMap = { |
| 114 'my_pkg': <Folder>[provider.getResource('/packages/my_pkg/lib')] | 120 'my_pkg': <Folder>[provider.getResource('/packages/my_pkg/lib')] |
| 115 }; | 121 }; |
| 116 context.sourceFactory = new SourceFactory([ | 122 context.sourceFactory = new SourceFactory([ |
| 117 new DartUriResolver(sdk), | 123 new DartUriResolver(sdk), |
| 118 new PackageMapUriResolver(provider, packageMap), | 124 new PackageMapUriResolver(provider, packageMap), |
| 119 resourceResolver | 125 resourceResolver |
| (...skipping 11 matching lines...) Expand all Loading... |
| 131 _createRefactoring('/packages/my_pkg/lib/bbb/ccc/new_name.dart'); | 137 _createRefactoring('/packages/my_pkg/lib/bbb/ccc/new_name.dart'); |
| 132 await _assertSuccessfulRefactoring(); | 138 await _assertSuccessfulRefactoring(); |
| 133 assertFileChangeResult( | 139 assertFileChangeResult( |
| 134 pathA, | 140 pathA, |
| 135 ''' | 141 ''' |
| 136 import 'package:my_pkg/bbb/ccc/new_name.dart'; | 142 import 'package:my_pkg/bbb/ccc/new_name.dart'; |
| 137 '''); | 143 '''); |
| 138 assertNoFileChange(testFile); | 144 assertNoFileChange(testFile); |
| 139 } | 145 } |
| 140 | 146 |
| 147 @failingTest |
| 141 test_file_importedLibrary_up() async { | 148 test_file_importedLibrary_up() async { |
| 149 fail('The move file refactoring is not supported under the new driver'); |
| 142 String pathA = '/project/000/1111/a.dart'; | 150 String pathA = '/project/000/1111/a.dart'; |
| 143 testFile = '/project/000/1111/22/test.dart'; | 151 testFile = '/project/000/1111/22/test.dart'; |
| 144 addSource( | 152 addSource( |
| 145 pathA, | 153 pathA, |
| 146 ''' | 154 ''' |
| 147 import '22/test.dart'; | 155 import '22/test.dart'; |
| 148 '''); | 156 '''); |
| 149 addTestSource(''); | 157 addTestSource(''); |
| 150 _performAnalysis(); | 158 _performAnalysis(); |
| 151 // perform refactoring | 159 // perform refactoring |
| 152 _createRefactoring('/project/000/1111/new_name.dart'); | 160 _createRefactoring('/project/000/1111/new_name.dart'); |
| 153 await _assertSuccessfulRefactoring(); | 161 await _assertSuccessfulRefactoring(); |
| 154 assertFileChangeResult( | 162 assertFileChangeResult( |
| 155 pathA, | 163 pathA, |
| 156 ''' | 164 ''' |
| 157 import 'new_name.dart'; | 165 import 'new_name.dart'; |
| 158 '''); | 166 '''); |
| 159 assertNoFileChange(testFile); | 167 assertNoFileChange(testFile); |
| 160 } | 168 } |
| 161 | 169 |
| 170 @failingTest |
| 162 test_file_sourcedUnit() async { | 171 test_file_sourcedUnit() async { |
| 172 fail('The move file refactoring is not supported under the new driver'); |
| 163 String pathA = '/project/000/1111/a.dart'; | 173 String pathA = '/project/000/1111/a.dart'; |
| 164 testFile = '/project/000/1111/22/test.dart'; | 174 testFile = '/project/000/1111/22/test.dart'; |
| 165 addSource( | 175 addSource( |
| 166 pathA, | 176 pathA, |
| 167 ''' | 177 ''' |
| 168 library lib; | 178 library lib; |
| 169 part '22/test.dart'; | 179 part '22/test.dart'; |
| 170 '''); | 180 '''); |
| 171 addTestSource(''' | 181 addTestSource(''' |
| 172 part of lib; | 182 part of lib; |
| 173 '''); | 183 '''); |
| 174 _performAnalysis(); | 184 _performAnalysis(); |
| 175 // perform refactoring | 185 // perform refactoring |
| 176 _createRefactoring('/project/000/1111/22/new_name.dart'); | 186 _createRefactoring('/project/000/1111/22/new_name.dart'); |
| 177 await _assertSuccessfulRefactoring(); | 187 await _assertSuccessfulRefactoring(); |
| 178 assertFileChangeResult( | 188 assertFileChangeResult( |
| 179 pathA, | 189 pathA, |
| 180 ''' | 190 ''' |
| 181 library lib; | 191 library lib; |
| 182 part '22/new_name.dart'; | 192 part '22/new_name.dart'; |
| 183 '''); | 193 '''); |
| 184 assertNoFileChange(testFile); | 194 assertNoFileChange(testFile); |
| 185 } | 195 } |
| 186 | 196 |
| 197 @failingTest |
| 187 test_file_sourcedUnit_multipleLibraries() async { | 198 test_file_sourcedUnit_multipleLibraries() async { |
| 199 fail('The move file refactoring is not supported under the new driver'); |
| 188 String pathA = '/project/000/1111/a.dart'; | 200 String pathA = '/project/000/1111/a.dart'; |
| 189 String pathB = '/project/000/b.dart'; | 201 String pathB = '/project/000/b.dart'; |
| 190 testFile = '/project/000/1111/22/test.dart'; | 202 testFile = '/project/000/1111/22/test.dart'; |
| 191 addSource( | 203 addSource( |
| 192 pathA, | 204 pathA, |
| 193 ''' | 205 ''' |
| 194 library lib; | 206 library lib; |
| 195 part '22/test.dart'; | 207 part '22/test.dart'; |
| 196 '''); | 208 '''); |
| 197 addSource( | 209 addSource( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 215 '''); | 227 '''); |
| 216 assertFileChangeResult( | 228 assertFileChangeResult( |
| 217 pathB, | 229 pathB, |
| 218 ''' | 230 ''' |
| 219 library lib; | 231 library lib; |
| 220 part '1111/22/new_name.dart'; | 232 part '1111/22/new_name.dart'; |
| 221 '''); | 233 '''); |
| 222 assertNoFileChange(testFile); | 234 assertNoFileChange(testFile); |
| 223 } | 235 } |
| 224 | 236 |
| 237 @failingTest |
| 225 test_project() async { | 238 test_project() async { |
| 239 fail('The move file refactoring is not supported under the new driver'); |
| 226 String pubspecPath = '/testName/pubspec.yaml'; | 240 String pubspecPath = '/testName/pubspec.yaml'; |
| 227 String appPath = '/testName/bin/myApp.dart'; | 241 String appPath = '/testName/bin/myApp.dart'; |
| 228 provider.newFile( | 242 provider.newFile( |
| 229 pubspecPath, | 243 pubspecPath, |
| 230 ''' | 244 ''' |
| 231 name: testName | 245 name: testName |
| 232 version: 0.0.1 | 246 version: 0.0.1 |
| 233 description: My pubspec file. | 247 description: My pubspec file. |
| 234 '''); | 248 '''); |
| 235 addSource('/testName/lib/myLib.dart', ''); | 249 addSource('/testName/lib/myLib.dart', ''); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 break; | 304 break; |
| 291 } | 305 } |
| 292 for (ChangeNotice notice in result.changeNotices) { | 306 for (ChangeNotice notice in result.changeNotices) { |
| 293 if (notice.source.fullName.startsWith('/project/')) { | 307 if (notice.source.fullName.startsWith('/project/')) { |
| 294 index.indexUnit(notice.resolvedDartUnit); | 308 index.indexUnit(notice.resolvedDartUnit); |
| 295 } | 309 } |
| 296 } | 310 } |
| 297 } | 311 } |
| 298 } | 312 } |
| 299 } | 313 } |
| OLD | NEW |