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

Unified Diff: pkg/analysis_server/test/services/refactoring/extract_method_test.dart

Issue 956393002: Issue 20827. Import required type in 'Extract Method' refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_method.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/refactoring/extract_method_test.dart
diff --git a/pkg/analysis_server/test/services/refactoring/extract_method_test.dart b/pkg/analysis_server/test/services/refactoring/extract_method_test.dart
index 95c05a5da76e45da150d9d71f855ef7d00496ce4..956de7e5ff126dbf5506bbced1bb014e72e5e14a 100644
--- a/pkg/analysis_server/test/services/refactoring/extract_method_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/extract_method_test.dart
@@ -1373,6 +1373,27 @@ int res(Foo<String, int> foo, String s) => foo(s);
''');
}
+ test_singleExpression_returnType_importLibrary() async {
+ _addLibraryReturningAsync();
+ indexTestUnit('''
+import 'asyncLib.dart';
+main() {
+ var a = newFuture();
+}
+''');
+ _createRefactoringForString('newFuture()');
+ // apply refactoring
+ return _assertSuccessfulRefactoring('''
+import 'asyncLib.dart';
+import 'dart:async';
+main() {
+ var a = res();
+}
+
+Future<int> res() => newFuture();
+''');
+ }
+
test_singleExpression_returnTypeGeneric() {
indexTestUnit('''
main() {
@@ -2203,6 +2224,35 @@ void res(int a) {
''');
}
+ test_statements_parameters_importType() {
+ _addLibraryReturningAsync();
+ indexTestUnit('''
+import 'asyncLib.dart';
+main() {
+ var v = newFuture();
+// start
+ print(v);
+// end
+}
+''');
+ _createRefactoringForStartEndComments();
+ // apply refactoring
+ return _assertSuccessfulRefactoring('''
+import 'asyncLib.dart';
+import 'dart:async';
+main() {
+ var v = newFuture();
+// start
+ res(v);
+// end
+}
+
+void res(Future<int> v) {
+ print(v);
+}
+''');
+ }
+
test_statements_return_last() {
indexTestUnit('''
main() {
@@ -2406,6 +2456,14 @@ void res() {
''');
}
+ void _addLibraryReturningAsync() {
+ addSource('/asyncLib.dart', r'''
+library asyncLib;
+import 'dart:async';
+Future<int> newFuture() => null;
+''');
+ }
+
Future _assertConditionsError(String message) async {
RefactoringStatus status = await refactoring.checkAllConditions();
assertRefactoringStatus(
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_method.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698