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

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

Issue 1498523005: Extract Local refactoring: skip method names in 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 for (AstNode node = coveringNode; node is Expression; node = node.parent) { 200 for (AstNode node = coveringNode; node is Expression; node = node.parent) {
201 AstNode parent = node.parent; 201 AstNode parent = node.parent;
202 // cannot extract the name part of a property access 202 // cannot extract the name part of a property access
203 if (parent is PrefixedIdentifier && parent.identifier == node || 203 if (parent is PrefixedIdentifier && parent.identifier == node ||
204 parent is PropertyAccess && parent.propertyName == node) { 204 parent is PropertyAccess && parent.propertyName == node) {
205 continue; 205 continue;
206 } 206 }
207 // fatal selection problems 207 // fatal selection problems
208 if (coveringExpressionOffsets.isEmpty) { 208 if (coveringExpressionOffsets.isEmpty) {
209 if (node is SimpleIdentifier) { 209 if (node is SimpleIdentifier) {
210 Element element = node.bestElement;
211 if (element is FunctionElement || element is MethodElement) {
212 return new RefactoringStatus.fatal(
213 'Cannot extract a single method name.',
214 newLocation_fromNode(node));
215 }
216 if (node.inDeclarationContext()) { 210 if (node.inDeclarationContext()) {
217 return new RefactoringStatus.fatal( 211 return new RefactoringStatus.fatal(
218 'Cannot extract the name part of a declaration.', 212 'Cannot extract the name part of a declaration.',
219 newLocation_fromNode(node)); 213 newLocation_fromNode(node));
220 } 214 }
215 Element element = node.bestElement;
216 if (element is FunctionElement || element is MethodElement) {
217 continue;
218 }
221 } 219 }
222 if (parent is AssignmentExpression && parent.leftHandSide == node) { 220 if (parent is AssignmentExpression && parent.leftHandSide == node) {
223 return new RefactoringStatus.fatal( 221 return new RefactoringStatus.fatal(
224 'Cannot extract the left-hand side of an assignment.', 222 'Cannot extract the left-hand side of an assignment.',
225 newLocation_fromNode(node)); 223 newLocation_fromNode(node));
226 } 224 }
227 } 225 }
228 // set selected expression 226 // set selected expression
229 if (coveringExpressionOffsets.isEmpty) { 227 if (coveringExpressionOffsets.isEmpty) {
230 rootExpression = node; 228 rootExpression = node;
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 619
622 _TokenLocalElementVisitor(this.map); 620 _TokenLocalElementVisitor(this.map);
623 621
624 visitSimpleIdentifier(SimpleIdentifier node) { 622 visitSimpleIdentifier(SimpleIdentifier node) {
625 Element element = node.staticElement; 623 Element element = node.staticElement;
626 if (element is LocalVariableElement) { 624 if (element is LocalVariableElement) {
627 map[node.token] = element; 625 map[node.token] = element;
628 } 626 }
629 } 627 }
630 } 628 }
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