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

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

Issue 1528023002: Issue 25252. Stop collecting covering expressions at void invocations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/refactoring/extract_local_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library services.src.refactoring.extract_local; 5 library services.src.refactoring.extract_local;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/protocol_server.dart' hide Element; 10 import 'package:analysis_server/src/protocol_server.dart' hide Element;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 225 }
226 // get covering node 226 // get covering node
227 AstNode coveringNode = 227 AstNode coveringNode =
228 new NodeLocator(selectionRange.offset, selectionRange.end) 228 new NodeLocator(selectionRange.offset, selectionRange.end)
229 .searchWithin(unit); 229 .searchWithin(unit);
230 // compute covering expressions 230 // compute covering expressions
231 for (AstNode node = coveringNode; 231 for (AstNode node = coveringNode;
232 node is Expression || node is ArgumentList; 232 node is Expression || node is ArgumentList;
233 node = node.parent) { 233 node = node.parent) {
234 AstNode parent = node.parent; 234 AstNode parent = node.parent;
235 // stop at void method invocations
236 if (node is MethodInvocation) {
237 MethodInvocation invocation = node;
238 Element element = invocation.methodName.bestElement;
239 if (element is ExecutableElement &&
240 element.returnType != null &&
241 element.returnType.isVoid) {
242 if (rootExpression == null) {
243 return new RefactoringStatus.fatal(
244 'Cannot extract the void expression.',
245 newLocation_fromNode(node));
246 }
247 break;
248 }
249 }
235 // skip ArgumentList 250 // skip ArgumentList
236 if (node is ArgumentList) { 251 if (node is ArgumentList) {
237 continue; 252 continue;
238 } 253 }
239 // skip AssignmentExpression 254 // skip AssignmentExpression
240 if (node is AssignmentExpression) { 255 if (node is AssignmentExpression) {
241 continue; 256 continue;
242 } 257 }
243 // cannot extract the name part of a property access 258 // cannot extract the name part of a property access
244 if (parent is PrefixedIdentifier && parent.identifier == node || 259 if (parent is PrefixedIdentifier && parent.identifier == node ||
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 676
662 _TokenLocalElementVisitor(this.map); 677 _TokenLocalElementVisitor(this.map);
663 678
664 visitSimpleIdentifier(SimpleIdentifier node) { 679 visitSimpleIdentifier(SimpleIdentifier node) {
665 Element element = node.staticElement; 680 Element element = node.staticElement;
666 if (element is LocalVariableElement) { 681 if (element is LocalVariableElement) {
667 map[node.token] = element; 682 map[node.token] = element;
668 } 683 }
669 } 684 }
670 } 685 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/refactoring/extract_local_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698