| 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_import; | 5 library services.src.refactoring.rename_import; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol2.dart'; | 9 import 'package:analysis_server/src/protocol2.dart'; |
| 10 import 'package:analysis_server/src/services/correction/change.dart'; | |
| 11 import 'package:analysis_server/src/services/correction/status.dart'; | 10 import 'package:analysis_server/src/services/correction/status.dart'; |
| 12 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 11 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; |
| 13 import 'package:analysis_server/src/services/search/search_engine.dart'; | 12 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 14 import 'package:analysis_server/src/services/correction/source_range.dart'; | 13 import 'package:analysis_server/src/services/correction/source_range.dart'; |
| 15 import 'package:analysis_server/src/services/refactoring/naming_conventions.dart
'; | 14 import 'package:analysis_server/src/services/refactoring/naming_conventions.dart
'; |
| 16 import 'package:analysis_server/src/services/refactoring/rename.dart'; | 15 import 'package:analysis_server/src/services/refactoring/rename.dart'; |
| 17 import 'package:analyzer/src/generated/element.dart'; | 16 import 'package:analyzer/src/generated/element.dart'; |
| 18 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
| 19 | 18 |
| 20 | 19 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 40 } | 39 } |
| 41 | 40 |
| 42 @override | 41 @override |
| 43 RefactoringStatus checkNewName() { | 42 RefactoringStatus checkNewName() { |
| 44 RefactoringStatus result = super.checkNewName(); | 43 RefactoringStatus result = super.checkNewName(); |
| 45 result.addStatus(validateImportPrefixName(newName)); | 44 result.addStatus(validateImportPrefixName(newName)); |
| 46 return result; | 45 return result; |
| 47 } | 46 } |
| 48 | 47 |
| 49 @override | 48 @override |
| 50 Future<Change> createChange() { | 49 Future<SourceChange> createChange() { |
| 51 Change change = new Change(refactoringName); | 50 SourceChange change = new SourceChange(refactoringName); |
| 52 // update declaration | 51 // update declaration |
| 53 { | 52 { |
| 54 String file = getElementFile(element); | 53 String file = getElementFile(element); |
| 55 PrefixElement prefix = element.prefix; | 54 PrefixElement prefix = element.prefix; |
| 56 SourceEdit edit = null; | 55 SourceEdit edit = null; |
| 57 if (newName.isEmpty) { | 56 if (newName.isEmpty) { |
| 58 int uriEnd = element.uriEnd; | 57 int uriEnd = element.uriEnd; |
| 59 int prefixEnd = element.prefixOffset + prefix.displayName.length; | 58 int prefixEnd = element.prefixOffset + prefix.displayName.length; |
| 60 SourceRange range = rangeStartEnd(uriEnd, prefixEnd); | 59 SourceRange range = rangeStartEnd(uriEnd, prefixEnd); |
| 61 edit = new SourceEdit.range(range, ""); | 60 edit = new SourceEdit.range(range, ""); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 83 edit = createReferenceEdit(reference, newName); | 82 edit = createReferenceEdit(reference, newName); |
| 84 } else { | 83 } else { |
| 85 edit = createReferenceEdit(reference, "${newName}."); | 84 edit = createReferenceEdit(reference, "${newName}."); |
| 86 } | 85 } |
| 87 change.addEdit(reference.file, edit); | 86 change.addEdit(reference.file, edit); |
| 88 } | 87 } |
| 89 return change; | 88 return change; |
| 90 }); | 89 }); |
| 91 } | 90 } |
| 92 } | 91 } |
| OLD | NEW |