Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1047)

Side by Side Diff: pkg/analysis_server/lib/src/services/refactoring/move_file.dart

Issue 583193005: Integration of MOVE_FILE into the server and a couple of fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.dart' hide Element; 9 import 'package:analysis_server/src/protocol.dart' hide Element;
10 import 'package:analysis_server/src/services/correction/status.dart'; 10 import 'package:analysis_server/src/services/correction/status.dart';
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 return change; 91 return change;
92 }); 92 });
93 } 93 }
94 94
95 @override 95 @override
96 bool requiresPreview() => false; 96 bool requiresPreview() => false;
97 97
98 void _updateUriReference(UriReferencedElement element) { 98 void _updateUriReference(UriReferencedElement element) {
99 if (!element.isSynthetic) { 99 if (!element.isSynthetic) {
100 String elementUri = element.uri; 100 String elementUri = element.uri;
101 if (pathos.isRelative(elementUri)) { 101 if (_isRelativeUri(elementUri)) {
102 String elementPath = pathos.join(oldLibraryDir, elementUri); 102 String elementPath = pathos.join(oldLibraryDir, elementUri);
103 String newUri = pathos.relative(elementPath, from: newLibraryDir); 103 String newUri = pathos.relative(elementPath, from: newLibraryDir);
104 int uriOffset = element.uriOffset; 104 int uriOffset = element.uriOffset;
105 int uriLength = element.uriEnd - uriOffset; 105 int uriLength = element.uriEnd - uriOffset;
106 change.addElementEdit( 106 change.addElementEdit(
107 library, 107 library,
108 new SourceEdit(uriOffset, uriLength, "'$newUri'")); 108 new SourceEdit(uriOffset, uriLength, "'$newUri'"));
109 } 109 }
110 } 110 }
111 } 111 }
112 112
113 void _updateUriReferences(List<UriReferencedElement> elements) { 113 void _updateUriReferences(List<UriReferencedElement> elements) {
114 for (UriReferencedElement element in elements) { 114 for (UriReferencedElement element in elements) {
115 _updateUriReference(element); 115 _updateUriReference(element);
116 } 116 }
117 } 117 }
118
119 /**
120 * Checks if the given [path] represents a relative URI.
121 *
122 * The following URI's are not relative:
123 * `/absolute/path/file.dart`
124 * `dart:math`
125 */
126 static bool _isRelativeUri(String path) {
127 // absolute path
128 if (pathos.isAbsolute(path)) {
129 return false;
130 }
131 // absolute URI
132 if (Uri.parse(path).isAbsolute) {
133 return false;
134 }
135 // OK
136 return true;
137 }
118 } 138 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/protocol.dart ('k') | pkg/analysis_server/test/edit/refactoring_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698