| 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.refactoring.move_files; | 5 library test.services.refactoring.move_files; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 9 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 String pubspecPath = '/testName/pubspec.yaml'; | 186 String pubspecPath = '/testName/pubspec.yaml'; |
| 187 String appPath = '/testName/bin/myApp.dart'; | 187 String appPath = '/testName/bin/myApp.dart'; |
| 188 provider.newFile(pubspecPath, ''' | 188 provider.newFile(pubspecPath, ''' |
| 189 name: testName | 189 name: testName |
| 190 version: 0.0.1 | 190 version: 0.0.1 |
| 191 description: My pubspec file. | 191 description: My pubspec file. |
| 192 '''); | 192 '''); |
| 193 addSource('/testName/lib/myLib.dart', ''); | 193 addSource('/testName/lib/myLib.dart', ''); |
| 194 addSource(appPath, ''' | 194 addSource(appPath, ''' |
| 195 import 'package:testName/myLib.dart'; | 195 import 'package:testName/myLib.dart'; |
| 196 export 'package:testName/myLib.dart'; |
| 196 '''); | 197 '''); |
| 197 addTestSource(''); | 198 // configure Uri resolves |
| 199 context.sourceFactory = new SourceFactory([ |
| 200 AbstractContextTest.SDK_RESOLVER, |
| 201 new PackageMapUriResolver(provider, <String, List<Folder>>{ |
| 202 'testName': [provider.getResource('/testName/lib')] |
| 203 }), |
| 204 resourceResolver, |
| 205 ]); |
| 206 // analyze |
| 198 _performAnalysis(); | 207 _performAnalysis(); |
| 199 // perform refactoring | 208 // perform refactoring |
| 200 refactoring = new MoveFileRefactoring( | 209 refactoring = new MoveFileRefactoring( |
| 201 provider, searchEngine, context, null, '/testName'); | 210 provider, searchEngine, context, null, '/testName'); |
| 202 refactoring.newFile = '/newName'; | 211 refactoring.newFile = '/newName'; |
| 203 await _assertSuccessfulRefactoring(); | 212 await _assertSuccessfulRefactoring(); |
| 204 // print(refactoringChange); | |
| 205 assertFileChangeResult(pubspecPath, ''' | 213 assertFileChangeResult(pubspecPath, ''' |
| 206 name: newName | 214 name: newName |
| 207 version: 0.0.1 | 215 version: 0.0.1 |
| 208 description: My pubspec file. | 216 description: My pubspec file. |
| 209 '''); | 217 '''); |
| 210 // TODO(scheglov) update self references | 218 assertFileChangeResult(appPath, ''' |
| 211 // assertFileChangeResult(appPath, ''' | 219 import 'package:newName/myLib.dart'; |
| 212 //import 'package:newName/myLib.dart'; | 220 export 'package:newName/myLib.dart'; |
| 213 //'''); | 221 '''); |
| 214 } | 222 } |
| 215 | 223 |
| 216 /** | 224 /** |
| 217 * Checks that all conditions are OK. | 225 * Checks that all conditions are OK. |
| 218 */ | 226 */ |
| 219 Future _assertSuccessfulRefactoring() async { | 227 Future _assertSuccessfulRefactoring() async { |
| 220 await assertRefactoringConditionsOK(); | 228 await assertRefactoringConditionsOK(); |
| 221 refactoringChange = await refactoring.createChange(); | 229 refactoringChange = await refactoring.createChange(); |
| 222 } | 230 } |
| 223 | 231 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 234 break; | 242 break; |
| 235 } | 243 } |
| 236 for (ChangeNotice notice in result.changeNotices) { | 244 for (ChangeNotice notice in result.changeNotices) { |
| 237 if (notice.source.fullName.startsWith('/project/')) { | 245 if (notice.source.fullName.startsWith('/project/')) { |
| 238 index.indexUnit(context, notice.resolvedDartUnit); | 246 index.indexUnit(context, notice.resolvedDartUnit); |
| 239 } | 247 } |
| 240 } | 248 } |
| 241 } | 249 } |
| 242 } | 250 } |
| 243 } | 251 } |
| OLD | NEW |