| 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 services.src.refactoring.move_file; | 5 library services.src.refactoring.move_file; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol_server.dart' hide Element; | 9 import 'package:analysis_server/src/protocol_server.dart' hide Element; |
| 10 import 'package:analysis_server/src/services/correction/status.dart'; | 10 import 'package:analysis_server/src/services/correction/status.dart'; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 @override | 85 @override |
| 86 bool requiresPreview() => false; | 86 bool requiresPreview() => false; |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * Computes the URI to use to reference [newFile] from [reference]. | 89 * Computes the URI to use to reference [newFile] from [reference]. |
| 90 */ | 90 */ |
| 91 String _computeNewUri(SourceReference reference) { | 91 String _computeNewUri(SourceReference reference) { |
| 92 String refDir = pathContext.dirname(reference.file); | 92 String refDir = pathContext.dirname(reference.file); |
| 93 // try to keep package: URI | 93 // try to keep package: URI |
| 94 if (_isPackageReference(reference)) { | 94 if (_isPackageReference(reference)) { |
| 95 Source newSource = new NonExistingSource(newFile, UriKind.FILE_URI); | 95 Source newSource = new NonExistingSource( |
| 96 newFile, pathos.toUri(newFile), UriKind.FILE_URI); |
| 96 Uri restoredUri = context.sourceFactory.restoreUri(newSource); | 97 Uri restoredUri = context.sourceFactory.restoreUri(newSource); |
| 97 if (restoredUri != null) { | 98 if (restoredUri != null) { |
| 98 return restoredUri.toString(); | 99 return restoredUri.toString(); |
| 99 } | 100 } |
| 100 } | 101 } |
| 101 // if no package: URI, prepare relative | 102 // if no package: URI, prepare relative |
| 102 return _getRelativeUri(newFile, refDir); | 103 return _getRelativeUri(newFile, refDir); |
| 103 } | 104 } |
| 104 | 105 |
| 105 Future<SourceChange> _createFileChange() async { | 106 Future<SourceChange> _createFileChange() async { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 231 } |
| 231 } | 232 } |
| 232 } | 233 } |
| 233 | 234 |
| 234 void _updateUriReferences(List<UriReferencedElement> elements) { | 235 void _updateUriReferences(List<UriReferencedElement> elements) { |
| 235 for (UriReferencedElement element in elements) { | 236 for (UriReferencedElement element in elements) { |
| 236 _updateUriReference(element); | 237 _updateUriReference(element); |
| 237 } | 238 } |
| 238 } | 239 } |
| 239 } | 240 } |
| OLD | NEW |