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

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

Issue 913903002: Use async/await in refactorings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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.rename; 5 library services.src.refactoring.rename;
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/source_range.dart'; 10 import 'package:analysis_server/src/services/correction/source_range.dart';
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 RefactoringStatus checkNewName() { 150 RefactoringStatus checkNewName() {
151 RefactoringStatus result = new RefactoringStatus(); 151 RefactoringStatus result = new RefactoringStatus();
152 if (newName == oldName) { 152 if (newName == oldName) {
153 result.addFatalError( 153 result.addFatalError(
154 "The new name must be different than the current name."); 154 "The new name must be different than the current name.");
155 } 155 }
156 return result; 156 return result;
157 } 157 }
158 158
159 @override 159 @override
160 Future<SourceChange> createChange() { 160 Future<SourceChange> createChange() async {
161 change = new SourceChange(refactoringName); 161 change = new SourceChange(refactoringName);
162 return fillChange().then((_) => change); 162 await fillChange();
163 return change;
163 } 164 }
164 165
165 /** 166 /**
166 * Adds individual edits to [change]. 167 * Adds individual edits to [change].
167 */ 168 */
168 Future fillChange(); 169 Future fillChange();
169 170
170 @override 171 @override
171 bool requiresPreview() { 172 bool requiresPreview() {
172 return false; 173 return false;
173 } 174 }
174 175
175 static String _getDisplayName(Element element) { 176 static String _getDisplayName(Element element) {
176 if (element is ImportElement) { 177 if (element is ImportElement) {
177 PrefixElement prefix = element.prefix; 178 PrefixElement prefix = element.prefix;
178 if (prefix != null) { 179 if (prefix != null) {
179 return prefix.displayName; 180 return prefix.displayName;
180 } 181 }
181 return ''; 182 return '';
182 } 183 }
183 return element.displayName; 184 return element.displayName;
184 } 185 }
185 } 186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698