| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |