Index: pkg/analysis_server/test/services/refactoring/extract_local_test.dart |
diff --git a/pkg/analysis_server/test/services/refactoring/extract_local_test.dart b/pkg/analysis_server/test/services/refactoring/extract_local_test.dart |
index 1cb626f0071248e2c17056b98d71bb71e8766137..46a6e670122794d2646f24eb83b74b4b9a7dc137 100644 |
--- a/pkg/analysis_server/test/services/refactoring/extract_local_test.dart |
+++ b/pkg/analysis_server/test/services/refactoring/extract_local_test.dart |
@@ -332,16 +332,40 @@ main() { |
_createRefactoring(testCode.indexOf('bb * 2'), 0); |
// check conditions |
await refactoring.checkInitialConditions(); |
- List<String> subExpressions = <String>[]; |
- for (int i = 0; i < refactoring.coveringExpressionOffsets.length; i++) { |
- int offset = refactoring.coveringExpressionOffsets[i]; |
- int length = refactoring.coveringExpressionLengths[i]; |
- subExpressions.add(testCode.substring(offset, offset + length)); |
- } |
+ List<String> subExpressions = _getCoveringExpressions(); |
expect(subExpressions, |
['bbb', 'bbb * 2', 'aaa + bbb * 2', 'aaa + bbb * 2 + 3']); |
} |
+ test_coveringExpressions_inArgumentList() async { |
+ indexTestUnit(''' |
+main() { |
+ foo(111 + 222); |
+} |
+int foo(int x) => x; |
+'''); |
+ _createRefactoring(testCode.indexOf('11 +'), 0); |
+ // check conditions |
+ await refactoring.checkInitialConditions(); |
+ List<String> subExpressions = _getCoveringExpressions(); |
+ expect(subExpressions, ['111', '111 + 222', 'foo(111 + 222)']); |
+ } |
+ |
+ test_coveringExpressions_skipAssignments() async { |
+ indexTestUnit(''' |
+main() { |
+ int v; |
+ foo(v = 111 + 222); |
+} |
+int foo(x) => 42; |
+'''); |
+ _createRefactoring(testCode.indexOf('11 +'), 0); |
+ // check conditions |
+ await refactoring.checkInitialConditions(); |
+ List<String> subExpressions = _getCoveringExpressions(); |
+ expect(subExpressions, ['111', '111 + 222', 'foo(v = 111 + 222)']); |
+ } |
+ |
test_fragmentExpression() { |
indexTestUnit(''' |
main() { |
@@ -1053,4 +1077,14 @@ main() { |
int length = selectionSearch.length; |
_createRefactoring(offset, length); |
} |
+ |
+ List<String> _getCoveringExpressions() { |
+ List<String> subExpressions = <String>[]; |
+ for (int i = 0; i < refactoring.coveringExpressionOffsets.length; i++) { |
+ int offset = refactoring.coveringExpressionOffsets[i]; |
+ int length = refactoring.coveringExpressionLengths[i]; |
+ subExpressions.add(testCode.substring(offset, offset + length)); |
+ } |
+ return subExpressions; |
+ } |
} |