| 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/protocol_server.dart'; | 9 import 'package:analysis_server/src/protocol_server.dart'; |
| 10 import 'package:analysis_server/src/services/correction/source_range.dart'; | 10 import 'package:analysis_server/src/services/correction/source_range.dart'; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 PrefixElement prefix = element.prefix; | 53 PrefixElement prefix = element.prefix; |
| 54 SourceEdit edit = null; | 54 SourceEdit edit = null; |
| 55 if (newName.isEmpty) { | 55 if (newName.isEmpty) { |
| 56 int uriEnd = element.uriEnd; | 56 int uriEnd = element.uriEnd; |
| 57 int prefixEnd = element.prefixOffset + prefix.nameLength; | 57 int prefixEnd = element.prefixOffset + prefix.nameLength; |
| 58 SourceRange range = rangeStartEnd(uriEnd, prefixEnd); | 58 SourceRange range = rangeStartEnd(uriEnd, prefixEnd); |
| 59 edit = newSourceEdit_range(range, ""); | 59 edit = newSourceEdit_range(range, ""); |
| 60 } else { | 60 } else { |
| 61 if (prefix == null) { | 61 if (prefix == null) { |
| 62 SourceRange range = rangeStartLength(element.uriEnd, 0); | 62 SourceRange range = rangeStartLength(element.uriEnd, 0); |
| 63 edit = newSourceEdit_range(range, " as ${newName}"); | 63 edit = newSourceEdit_range(range, " as $newName"); |
| 64 } else { | 64 } else { |
| 65 int offset = element.prefixOffset; | 65 int offset = element.prefixOffset; |
| 66 int length = prefix.nameLength; | 66 int length = prefix.nameLength; |
| 67 SourceRange range = rangeStartLength(offset, length); | 67 SourceRange range = rangeStartLength(offset, length); |
| 68 edit = newSourceEdit_range(range, newName); | 68 edit = newSourceEdit_range(range, newName); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 if (edit != null) { | 71 if (edit != null) { |
| 72 doSourceChange_addElementEdit(change, element, edit); | 72 doSourceChange_addElementEdit(change, element, edit); |
| 73 } | 73 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 AstNode node = nodeLocator.searchWithin(unit); | 108 AstNode node = nodeLocator.searchWithin(unit); |
| 109 if (node is SimpleIdentifier) { | 109 if (node is SimpleIdentifier) { |
| 110 AstNode parent = node.parent; | 110 AstNode parent = node.parent; |
| 111 if (parent is InterpolationExpression && parent.rightBracket == null) { | 111 if (parent is InterpolationExpression && parent.rightBracket == null) { |
| 112 return node; | 112 return node; |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 return null; | 115 return null; |
| 116 } | 116 } |
| 117 } | 117 } |
| OLD | NEW |