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

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

Issue 1547113002: Issue 25313. Skip constructor names and named expressions. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: node != null 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ca90fd2616e48535ddfecbfbd667af387c618e33..a17bfda010712819c7bacb63d97ea40b9d3b77d2 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
@@ -230,10 +230,30 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
new NodeLocator(selectionRange.offset, selectionRange.end)
.searchWithin(unit);
// compute covering expressions
- for (AstNode node = coveringNode;
- node is Expression || node is ArgumentList;
- node = node.parent) {
+ for (AstNode node = coveringNode; node != null; node = node.parent) {
AstNode parent = node.parent;
+ // skip some nodes
+ if (node is ArgumentList ||
+ node is AssignmentExpression ||
+ node is NamedExpression ||
+ node is TypeArgumentList) {
+ continue;
+ }
+ if (node is ConstructorName || node is Label || node is TypeName) {
+ rootExpression = null;
+ coveringExpressionOffsets.clear();
+ coveringExpressionLengths.clear();
+ continue;
+ }
+ // cannot extract the name part of a property access
+ if (parent is PrefixedIdentifier && parent.identifier == node ||
+ parent is PropertyAccess && parent.propertyName == node) {
+ continue;
+ }
+ // stop if not an Expression
+ if (node is! Expression) {
+ break;
+ }
// stop at void method invocations
if (node is MethodInvocation) {
MethodInvocation invocation = node;
@@ -249,19 +269,6 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
break;
}
}
- // skip ArgumentList
- if (node is ArgumentList) {
- continue;
- }
- // skip AssignmentExpression
- if (node is AssignmentExpression) {
- continue;
- }
- // cannot extract the name part of a property access
- if (parent is PrefixedIdentifier && parent.identifier == node ||
- parent is PropertyAccess && parent.propertyName == node) {
- continue;
- }
// fatal selection problems
if (coveringExpressionOffsets.isEmpty) {
if (node is SimpleIdentifier) {
« 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