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

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

Issue 592123002: Move SourceReference, extract duplicate code. (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';
11 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; 11 import 'package:analysis_server/src/services/refactoring/refactoring.dart';
12 import 'package:analysis_server/src/services/refactoring/refactoring_internal.da rt'; 12 import 'package:analysis_server/src/services/refactoring/refactoring_internal.da rt';
13 import 'package:analysis_server/src/services/refactoring/rename.dart';
14 import 'package:analysis_server/src/services/search/search_engine.dart'; 13 import 'package:analysis_server/src/services/search/search_engine.dart';
15 import 'package:analyzer/src/generated/element.dart'; 14 import 'package:analyzer/src/generated/element.dart';
16 import 'package:analyzer/src/generated/engine.dart'; 15 import 'package:analyzer/src/generated/engine.dart';
17 import 'package:analyzer/src/generated/source.dart'; 16 import 'package:analyzer/src/generated/source.dart';
18 import 'package:path/path.dart' as pathos; 17 import 'package:path/path.dart' as pathos;
19 18
20 19
21 /** 20 /**
22 * [ExtractLocalRefactoring] implementation. 21 * [ExtractLocalRefactoring] implementation.
23 */ 22 */
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 newLibraryDir = pathos.dirname(newFile); 68 newLibraryDir = pathos.dirname(newFile);
70 _updateUriReferences(library.imports); 69 _updateUriReferences(library.imports);
71 _updateUriReferences(library.exports); 70 _updateUriReferences(library.exports);
72 _updateUriReferences(library.parts); 71 _updateUriReferences(library.parts);
73 } 72 }
74 // update reference to the unit 73 // update reference to the unit
75 return searchEngine.searchReferences(unitElement).then((matches) { 74 return searchEngine.searchReferences(unitElement).then((matches) {
76 List<SourceReference> references = getSourceReferences(matches); 75 List<SourceReference> references = getSourceReferences(matches);
77 for (SourceReference reference in references) { 76 for (SourceReference reference in references) {
78 String newUri = _computeNewUri(reference); 77 String newUri = _computeNewUri(reference);
79 SourceEdit edit = createReferenceEdit(reference, "'$newUri'"); 78 reference.addEdit(change, "'$newUri'");
80 change.addElementEdit(reference.element, edit);
81 } 79 }
82 }); 80 });
83 } 81 }
84 }).then((_) { 82 }).then((_) {
85 return change; 83 return change;
86 }); 84 });
87 } 85 }
88 86
89 @override 87 @override
90 bool requiresPreview() => false; 88 bool requiresPreview() => false;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return false; 145 return false;
148 } 146 }
149 // absolute URI 147 // absolute URI
150 if (Uri.parse(path).isAbsolute) { 148 if (Uri.parse(path).isAbsolute) {
151 return false; 149 return false;
152 } 150 }
153 // OK 151 // OK
154 return true; 152 return true;
155 } 153 }
156 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698