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

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

Issue 1522193002: Issue 25251. Fix for extracting string literal part with zero length. (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/edit/refactoring_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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 274 }
275 // we need enclosing block to add variable declaration statement 275 // we need enclosing block to add variable declaration statement
276 if (coveringNode == null || 276 if (coveringNode == null ||
277 coveringNode.getAncestor((node) => node is Block) == null) { 277 coveringNode.getAncestor((node) => node is Block) == null) {
278 return new RefactoringStatus.fatal( 278 return new RefactoringStatus.fatal(
279 'Expression inside of function must be selected ' 279 'Expression inside of function must be selected '
280 'to activate this refactoring.'); 280 'to activate this refactoring.');
281 } 281 }
282 // part of string literal 282 // part of string literal
283 if (coveringNode is StringLiteral) { 283 if (coveringNode is StringLiteral) {
284 if (selectionRange.offset > coveringNode.offset && 284 if (selectionRange.length != 0 &&
285 selectionRange.offset > coveringNode.offset &&
285 selectionRange.end < coveringNode.end) { 286 selectionRange.end < coveringNode.end) {
286 stringLiteralPart = selectionStr; 287 stringLiteralPart = selectionStr;
287 return new RefactoringStatus(); 288 return new RefactoringStatus();
288 } 289 }
289 } 290 }
290 // single node selected 291 // single node selected
291 if (rootExpression != null) { 292 if (rootExpression != null) {
292 singleExpression = rootExpression; 293 singleExpression = rootExpression;
293 selectionRange = rangeNode(singleExpression); 294 selectionRange = rangeNode(singleExpression);
294 wholeStatementExpression = singleExpression.parent is ExpressionStatement; 295 wholeStatementExpression = singleExpression.parent is ExpressionStatement;
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 661
661 _TokenLocalElementVisitor(this.map); 662 _TokenLocalElementVisitor(this.map);
662 663
663 visitSimpleIdentifier(SimpleIdentifier node) { 664 visitSimpleIdentifier(SimpleIdentifier node) {
664 Element element = node.staticElement; 665 Element element = node.staticElement;
665 if (element is LocalVariableElement) { 666 if (element is LocalVariableElement) {
666 map[node.token] = element; 667 map[node.token] = element;
667 } 668 }
668 } 669 }
669 } 670 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/edit/refactoring_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698