| 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_method; | 5 library services.src.refactoring.extract_method; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol_server.dart' hide Element; | 9 import 'package:analysis_server/src/protocol_server.dart' hide Element; |
| 10 import 'package:analysis_server/src/services/correction/name_suggestion.dart'; | 10 import 'package:analysis_server/src/services/correction/name_suggestion.dart'; |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 } | 724 } |
| 725 return true; | 725 return true; |
| 726 }); | 726 }); |
| 727 } | 727 } |
| 728 } | 728 } |
| 729 | 729 |
| 730 void _prepareNames() { | 730 void _prepareNames() { |
| 731 names.clear(); | 731 names.clear(); |
| 732 if (_selectionExpression != null) { | 732 if (_selectionExpression != null) { |
| 733 names.addAll(getVariableNameSuggestionsForExpression( | 733 names.addAll(getVariableNameSuggestionsForExpression( |
| 734 _selectionExpression.staticType, _selectionExpression, | 734 _selectionExpression.staticType, |
| 735 _selectionExpression, |
| 735 _excludedNames)); | 736 _excludedNames)); |
| 736 } | 737 } |
| 737 } | 738 } |
| 738 | 739 |
| 739 void _prepareOffsetsLengths() { | 740 void _prepareOffsetsLengths() { |
| 740 offsets.clear(); | 741 offsets.clear(); |
| 741 lengths.clear(); | 742 lengths.clear(); |
| 742 for (_Occurrence occurrence in _occurrences) { | 743 for (_Occurrence occurrence in _occurrences) { |
| 743 offsets.add(occurrence.range.offset); | 744 offsets.add(occurrence.range.offset); |
| 744 lengths.add(occurrence.range.length); | 745 lengths.add(occurrence.range.length); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 invalidSelection('Cannot extract the left-hand side of an assignment.', | 811 invalidSelection('Cannot extract the left-hand side of an assignment.', |
| 811 newLocation_fromNode(lhs)); | 812 newLocation_fromNode(lhs)); |
| 812 } | 813 } |
| 813 return null; | 814 return null; |
| 814 } | 815 } |
| 815 | 816 |
| 816 @override | 817 @override |
| 817 Object visitConstructorInitializer(ConstructorInitializer node) { | 818 Object visitConstructorInitializer(ConstructorInitializer node) { |
| 818 super.visitConstructorInitializer(node); | 819 super.visitConstructorInitializer(node); |
| 819 if (_isFirstSelectedNode(node)) { | 820 if (_isFirstSelectedNode(node)) { |
| 820 invalidSelection('Cannot extract a constructor initializer. ' | 821 invalidSelection( |
| 821 'Select expression part of initializer.', newLocation_fromNode(node)); | 822 'Cannot extract a constructor initializer. ' |
| 823 'Select expression part of initializer.', |
| 824 newLocation_fromNode(node)); |
| 822 } | 825 } |
| 823 return null; | 826 return null; |
| 824 } | 827 } |
| 825 | 828 |
| 826 @override | 829 @override |
| 827 Object visitForStatement(ForStatement node) { | 830 Object visitForStatement(ForStatement node) { |
| 828 super.visitForStatement(node); | 831 super.visitForStatement(node); |
| 829 if (identical(node.variables, firstSelectedNode)) { | 832 if (identical(node.variables, firstSelectedNode)) { |
| 830 invalidSelection( | 833 invalidSelection( |
| 831 "Cannot extract initialization part of a 'for' statement."); | 834 "Cannot extract initialization part of a 'for' statement."); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 if (_isFirstSelectedNode(node)) { | 866 if (_isFirstSelectedNode(node)) { |
| 864 invalidSelection('Cannot extract a single type reference.'); | 867 invalidSelection('Cannot extract a single type reference.'); |
| 865 } | 868 } |
| 866 return null; | 869 return null; |
| 867 } | 870 } |
| 868 | 871 |
| 869 @override | 872 @override |
| 870 Object visitVariableDeclaration(VariableDeclaration node) { | 873 Object visitVariableDeclaration(VariableDeclaration node) { |
| 871 super.visitVariableDeclaration(node); | 874 super.visitVariableDeclaration(node); |
| 872 if (_isFirstSelectedNode(node)) { | 875 if (_isFirstSelectedNode(node)) { |
| 873 invalidSelection('Cannot extract a variable declaration fragment. ' | 876 invalidSelection( |
| 874 'Select whole declaration statement.', newLocation_fromNode(node)); | 877 'Cannot extract a variable declaration fragment. ' |
| 878 'Select whole declaration statement.', |
| 879 newLocation_fromNode(node)); |
| 875 } | 880 } |
| 876 return null; | 881 return null; |
| 877 } | 882 } |
| 878 | 883 |
| 879 void _checkParent(AstNode node) { | 884 void _checkParent(AstNode node) { |
| 880 AstNode firstParent = firstSelectedNode.parent; | 885 AstNode firstParent = firstSelectedNode.parent; |
| 881 do { | 886 do { |
| 882 node = node.parent; | 887 node = node.parent; |
| 883 if (identical(node, firstParent)) { | 888 if (identical(node, firstParent)) { |
| 884 return; | 889 return; |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 return false; | 1206 return false; |
| 1202 } | 1207 } |
| 1203 for (int i = 0; i < parameterTypes.length; i++) { | 1208 for (int i = 0; i < parameterTypes.length; i++) { |
| 1204 if (other.parameterTypes[i] != parameterTypes[i]) { | 1209 if (other.parameterTypes[i] != parameterTypes[i]) { |
| 1205 return false; | 1210 return false; |
| 1206 } | 1211 } |
| 1207 } | 1212 } |
| 1208 return true; | 1213 return true; |
| 1209 } | 1214 } |
| 1210 } | 1215 } |
| OLD | NEW |