| Index: pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart b/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
|
| index e01942c8e05de8777498f49b48d66eb2a912d35c..81676c1e6ab0ead1c62cb912f3bce55e2c983748 100644
|
| --- a/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
|
| +++ b/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
|
| @@ -51,7 +51,7 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
|
| String stringLiteralPart;
|
| final List<SourceRange> occurrences = <SourceRange>[];
|
| final Map<Element, int> elementIds = <Element, int>{};
|
| - final Set<String> excludedVariableNames = new Set<String>();
|
| + Set<String> excludedVariableNames = new Set<String>();
|
|
|
| ExtractLocalRefactoringImpl(
|
| this.unit, this.selectionOffset, this.selectionLength) {
|
| @@ -94,7 +94,8 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
|
| _prepareOccurrences();
|
| _prepareOffsetsLengths();
|
| // names
|
| - _prepareExcludedNames();
|
| + excludedVariableNames =
|
| + utils.findPossibleLocalVariableConflicts(selectionOffset);
|
| _prepareNames();
|
| // done
|
| return new Future.value(result);
|
| @@ -371,31 +372,6 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
|
| return false;
|
| }
|
|
|
| - void _prepareExcludedNames() {
|
| - excludedVariableNames.clear();
|
| - AstNode enclosingNode =
|
| - new NodeLocator.con1(selectionOffset).searchWithin(unit);
|
| - Block enclosingBlock = enclosingNode.getAncestor((node) => node is Block);
|
| - if (enclosingBlock != null) {
|
| - SourceRange newVariableVisibleRange =
|
| - rangeStartEnd(selectionRange, enclosingBlock.end);
|
| - ExecutableElement enclosingExecutable =
|
| - getEnclosingExecutableElement(enclosingNode);
|
| - if (enclosingExecutable != null) {
|
| - visitChildren(enclosingExecutable, (Element element) {
|
| - if (element is LocalElement) {
|
| - SourceRange elementRange = element.visibleRange;
|
| - if (elementRange != null &&
|
| - elementRange.intersects(newVariableVisibleRange)) {
|
| - excludedVariableNames.add(element.displayName);
|
| - }
|
| - }
|
| - return true;
|
| - });
|
| - }
|
| - }
|
| - }
|
| -
|
| void _prepareNames() {
|
| names.clear();
|
| if (stringLiteralPart != null) {
|
|
|