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

Side by Side Diff: pkg/analysis_server/lib/src/services/refactoring/rename_constructor.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_constructor; 5 library services.src.refactoring.rename_constructor;
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 @override 45 @override
46 RefactoringStatus checkNewName() { 46 RefactoringStatus checkNewName() {
47 RefactoringStatus result = super.checkNewName(); 47 RefactoringStatus result = super.checkNewName();
48 result.addStatus(validateConstructorName(newName)); 48 result.addStatus(validateConstructorName(newName));
49 return result; 49 return result;
50 } 50 }
51 51
52 @override 52 @override
53 Future fillChange() { 53 Future fillChange() async {
54 String replacement = newName.isEmpty ? '' : '.${newName}'; 54 String replacement = newName.isEmpty ? '' : '.${newName}';
55 // update references 55 // update references
56 return searchEngine.searchReferences(element).then((matches) { 56 List<SearchMatch> matches = await searchEngine.searchReferences(element);
57 List<SourceReference> references = getSourceReferences(matches); 57 List<SourceReference> references = getSourceReferences(matches);
58 if (!element.isSynthetic) { 58 if (!element.isSynthetic) {
59 for (SourceReference reference in references) { 59 for (SourceReference reference in references) {
60 reference.addEdit(change, replacement); 60 reference.addEdit(change, replacement);
61 }
62 } 61 }
63 }); 62 }
64 } 63 }
65 64
66 void _analyzePossibleConflicts(RefactoringStatus result) { 65 void _analyzePossibleConflicts(RefactoringStatus result) {
67 // check if there are members with "newName" in the same ClassElement 66 // check if there are members with "newName" in the same ClassElement
68 ClassElement parentClass = element.enclosingElement; 67 ClassElement parentClass = element.enclosingElement;
69 for (Element newNameMember in getChildren(parentClass, newName)) { 68 for (Element newNameMember in getChildren(parentClass, newName)) {
70 String message = format( 69 String message = format(
71 "Class '{0}' already declares {1} with name '{2}'.", 70 "Class '{0}' already declares {1} with name '{2}'.",
72 parentClass.displayName, 71 parentClass.displayName,
73 getElementKindName(newNameMember), 72 getElementKindName(newNameMember),
74 newName); 73 newName);
75 result.addError(message, newLocation_fromElement(newNameMember)); 74 result.addError(message, newLocation_fromElement(newNameMember));
76 } 75 }
77 } 76 }
78 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698