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

Side by Side Diff: pkg/analysis_server/lib/src/services/refactoring/inline_method.dart

Issue 2969343002: Stop depending of visiting LocalVariableElement(s) in Executableelement.visitChildren(). (Closed)
Patch Set: Created 3 years, 5 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
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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analysis_server/src/protocol_server.dart' hide Element; 7 import 'package:analysis_server/src/protocol_server.dart' hide Element;
8 import 'package:analysis_server/src/services/correction/status.dart'; 8 import 'package:analysis_server/src/services/correction/status.dart';
9 import 'package:analysis_server/src/services/correction/strings.dart'; 9 import 'package:analysis_server/src/services/correction/strings.dart';
10 import 'package:analysis_server/src/services/correction/util.dart'; 10 import 'package:analysis_server/src/services/correction/util.dart';
11 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; 11 import 'package:analysis_server/src/services/refactoring/refactoring.dart';
12 import 'package:analysis_server/src/services/refactoring/refactoring_internal.da rt'; 12 import 'package:analysis_server/src/services/refactoring/refactoring_internal.da rt';
13 import 'package:analysis_server/src/services/search/element_visitors.dart';
14 import 'package:analysis_server/src/services/search/hierarchy.dart'; 13 import 'package:analysis_server/src/services/search/hierarchy.dart';
15 import 'package:analysis_server/src/services/search/search_engine.dart'; 14 import 'package:analysis_server/src/services/search/search_engine.dart';
16 import 'package:analyzer/dart/ast/ast.dart'; 15 import 'package:analyzer/dart/ast/ast.dart';
17 import 'package:analyzer/dart/ast/visitor.dart'; 16 import 'package:analyzer/dart/ast/visitor.dart';
18 import 'package:analyzer/dart/element/element.dart'; 17 import 'package:analyzer/dart/element/element.dart';
19 import 'package:analyzer/src/dart/ast/utilities.dart'; 18 import 'package:analyzer/src/dart/ast/utilities.dart';
20 import 'package:analyzer/src/dart/element/ast_provider.dart'; 19 import 'package:analyzer/src/dart/element/ast_provider.dart';
21 import 'package:analyzer/src/generated/source.dart'; 20 import 'package:analyzer/src/generated/source.dart';
22 import 'package:analyzer/src/generated/utilities_dart.dart'; 21 import 'package:analyzer/src/generated/utilities_dart.dart';
23 import 'package:analyzer_plugin/utilities/range_factory.dart'; 22 import 'package:analyzer_plugin/utilities/range_factory.dart';
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 147
149 /** 148 /**
150 * Returns the names which will shadow or will be shadowed by any declaration 149 * Returns the names which will shadow or will be shadowed by any declaration
151 * at [node]. 150 * at [node].
152 */ 151 */
153 Set<String> _getNamesConflictingAt(AstNode node) { 152 Set<String> _getNamesConflictingAt(AstNode node) {
154 Set<String> result = new Set<String>(); 153 Set<String> result = new Set<String>();
155 // local variables and functions 154 // local variables and functions
156 { 155 {
157 SourceRange localsRange = _getLocalsConflictingRange(node); 156 SourceRange localsRange = _getLocalsConflictingRange(node);
158 ExecutableElement enclosingExecutable = getEnclosingExecutableElement(node); 157 AstNode enclosingExecutable = getEnclosingExecutableNode(node);
159 if (enclosingExecutable != null) { 158 List<LocalElement> elements = getDefinedLocalElements(enclosingExecutable);
160 visitChildren(enclosingExecutable, (element) { 159 for (LocalElement element in elements) {
161 if (element is LocalElement) { 160 SourceRange elementRange = element.visibleRange;
162 SourceRange elementRange = element.visibleRange; 161 if (elementRange != null && elementRange.intersects(localsRange)) {
163 if (elementRange != null && elementRange.intersects(localsRange)) { 162 result.add(element.displayName);
164 result.add(element.displayName); 163 }
165 }
166 }
167 return true;
168 });
169 } 164 }
170 } 165 }
171 // fields 166 // fields
172 { 167 {
173 ClassElement enclosingClassElement = getEnclosingClassElement(node); 168 ClassElement enclosingClassElement = getEnclosingClassElement(node);
174 if (enclosingClassElement != null) { 169 if (enclosingClassElement != null) {
175 Set<ClassElement> elements = new Set<ClassElement>(); 170 Set<ClassElement> elements = new Set<ClassElement>();
176 elements.add(enclosingClassElement); 171 elements.add(enclosingClassElement);
177 elements.addAll(getSuperClasses(enclosingClassElement)); 172 elements.addAll(getSuperClasses(enclosingClassElement));
178 for (ClassElement classElement in elements) { 173 for (ClassElement classElement in elements) {
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 } 871 }
877 872
878 void _addVariable(SimpleIdentifier node) { 873 void _addVariable(SimpleIdentifier node) {
879 VariableElement variableElement = getLocalVariableElement(node); 874 VariableElement variableElement = getLocalVariableElement(node);
880 if (variableElement != null) { 875 if (variableElement != null) {
881 SourceRange nodeRange = range.node(node); 876 SourceRange nodeRange = range.node(node);
882 result.addVariable(variableElement, nodeRange); 877 result.addVariable(variableElement, nodeRange);
883 } 878 }
884 } 879 }
885 } 880 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698