| 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.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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 RefactoringStatus result = new RefactoringStatus(); | 144 RefactoringStatus result = new RefactoringStatus(); |
| 145 if (newName == oldName) { | 145 if (newName == oldName) { |
| 146 result.addFatalError( | 146 result.addFatalError( |
| 147 "The new name must be different than the current name."); | 147 "The new name must be different than the current name."); |
| 148 } | 148 } |
| 149 return result; | 149 return result; |
| 150 } | 150 } |
| 151 | 151 |
| 152 @override | 152 @override |
| 153 Future<SourceChange> createChange() async { | 153 Future<SourceChange> createChange() async { |
| 154 change = new SourceChange(refactoringName); | 154 String changeName = "$refactoringName '$oldName' to '$newName'"; |
| 155 change = new SourceChange(changeName); |
| 155 await fillChange(); | 156 await fillChange(); |
| 156 return change; | 157 return change; |
| 157 } | 158 } |
| 158 | 159 |
| 159 /** | 160 /** |
| 160 * Adds individual edits to [change]. | 161 * Adds individual edits to [change]. |
| 161 */ | 162 */ |
| 162 Future fillChange(); | 163 Future fillChange(); |
| 163 | 164 |
| 164 @override | 165 @override |
| 165 bool requiresPreview() { | 166 bool requiresPreview() { |
| 166 return false; | 167 return false; |
| 167 } | 168 } |
| 168 | 169 |
| 169 static String _getDisplayName(Element element) { | 170 static String _getDisplayName(Element element) { |
| 170 if (element is ImportElement) { | 171 if (element is ImportElement) { |
| 171 PrefixElement prefix = element.prefix; | 172 PrefixElement prefix = element.prefix; |
| 172 if (prefix != null) { | 173 if (prefix != null) { |
| 173 return prefix.displayName; | 174 return prefix.displayName; |
| 174 } | 175 } |
| 175 return ''; | 176 return ''; |
| 176 } | 177 } |
| 177 return element.displayName; | 178 return element.displayName; |
| 178 } | 179 } |
| 179 } | 180 } |
| OLD | NEW |