| 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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 542 |
| 543 @override | 543 @override |
| 544 Object visitExpression(Expression node) { | 544 Object visitExpression(Expression node) { |
| 545 if (ref._isExtractable(rangeNode(node))) { | 545 if (ref._isExtractable(rangeNode(node))) { |
| 546 _tryToFindOccurrence(node); | 546 _tryToFindOccurrence(node); |
| 547 } | 547 } |
| 548 return super.visitExpression(node); | 548 return super.visitExpression(node); |
| 549 } | 549 } |
| 550 | 550 |
| 551 @override | 551 @override |
| 552 Object visitSimpleStringLiteral(SimpleStringLiteral node) { | 552 Object visitStringLiteral(StringLiteral node) { |
| 553 if (ref.stringLiteralPart != null) { | 553 if (ref.stringLiteralPart != null) { |
| 554 int occuLength = ref.stringLiteralPart.length; | 554 int occuLength = ref.stringLiteralPart.length; |
| 555 String value = node.value; | 555 String value = ref.utils.getNodeText(node); |
| 556 int valueOffset = node.offset + (node.isMultiline ? 3 : 1); | |
| 557 int lastIndex = 0; | 556 int lastIndex = 0; |
| 558 while (true) { | 557 while (true) { |
| 559 int index = value.indexOf(ref.stringLiteralPart, lastIndex); | 558 int index = value.indexOf(ref.stringLiteralPart, lastIndex); |
| 560 if (index == -1) { | 559 if (index == -1) { |
| 561 break; | 560 break; |
| 562 } | 561 } |
| 563 lastIndex = index + occuLength; | 562 lastIndex = index + occuLength; |
| 564 int occuStart = valueOffset + index; | 563 int occuStart = node.offset + index; |
| 565 SourceRange occuRange = rangeStartLength(occuStart, occuLength); | 564 SourceRange occuRange = rangeStartLength(occuStart, occuLength); |
| 566 occurrences.add(occuRange); | 565 occurrences.add(occuRange); |
| 567 } | 566 } |
| 568 return null; | 567 return null; |
| 569 } | 568 } |
| 570 return visitExpression(node); | 569 return visitExpression(node); |
| 571 } | 570 } |
| 572 | 571 |
| 573 void _addOccurrence(SourceRange range) { | 572 void _addOccurrence(SourceRange range) { |
| 574 if (range.intersects(ref.selectionRange)) { | 573 if (range.intersects(ref.selectionRange)) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 | 629 |
| 631 _TokenLocalElementVisitor(this.map); | 630 _TokenLocalElementVisitor(this.map); |
| 632 | 631 |
| 633 visitSimpleIdentifier(SimpleIdentifier node) { | 632 visitSimpleIdentifier(SimpleIdentifier node) { |
| 634 Element element = node.staticElement; | 633 Element element = node.staticElement; |
| 635 if (element is LocalVariableElement) { | 634 if (element is LocalVariableElement) { |
| 636 map[node.token] = element; | 635 map[node.token] = element; |
| 637 } | 636 } |
| 638 } | 637 } |
| 639 } | 638 } |
| OLD | NEW |