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

Unified Diff: pkg/analysis_server/test/services/correction/assist_test.dart

Issue 2749283004: Add assist to convert child: to children: in Flutter new-exprs (Closed)
Patch Set: Fail fast for named args not in instance creation exprs Created 3 years, 9 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/correction/assist_internal.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/correction/assist_test.dart
diff --git a/pkg/analysis_server/test/services/correction/assist_test.dart b/pkg/analysis_server/test/services/correction/assist_test.dart
index b52c25d46d1f7a7d3eb1f39d103d442afbfffcff..29b3920b0722f86837bf626cb9847791e130b65a 100644
--- a/pkg/analysis_server/test/services/correction/assist_test.dart
+++ b/pkg/analysis_server/test/services/correction/assist_test.dart
@@ -1036,6 +1036,129 @@ class A {
''');
}
+ test_convertFlutterChild_OK_multiLine() async {
+ _configureFlutterPkg({
+ 'src/widgets/framework.dart': _flutter_framework_code,
+ });
+ await resolveTestUnit('''
+import 'package:flutter/src/widgets/framework.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ /*caret*/child: new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ key: null,
+ ),
+// end
+ );
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(
+ DartAssistKind.CONVERT_FLUTTER_CHILD,
+ '''
+import 'package:flutter/src/widgets/framework.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ /*caret*/children: <Widget>[
+ new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ ],
+ key: null,
+ ),
+// end
+ );
+}
+''');
+ }
+
+ test_convertFlutterChild_OK_newlineChild() async {
+ // This case could occur with deeply nested constructors, common in Flutter.
+ _configureFlutterPkg({
+ 'src/widgets/framework.dart': _flutter_framework_code,
+ });
+ await resolveTestUnit('''
+import 'package:flutter/src/widgets/framework.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ /*caret*/child:
+ new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ key: null,
+ ),
+// end
+ );
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(
+ DartAssistKind.CONVERT_FLUTTER_CHILD,
+ '''
+import 'package:flutter/src/widgets/framework.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ /*caret*/children: <Widget>[
+ new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ ],
+ key: null,
+ ),
+// end
+ );
+}
+''');
+ }
+
+ test_convertFlutterChild_OK_singleLine() async {
+ _configureFlutterPkg({
+ 'src/widgets/framework.dart': _flutter_framework_code,
+ });
+ await resolveTestUnit('''
+import 'package:flutter/src/widgets/framework.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ /*caret*/child: new GestureDetector(),
+ key: null,
+ ),
+// end
+ );
+}
+''');
+ _setCaretLocation();
+ await assertHasAssist(
+ DartAssistKind.CONVERT_FLUTTER_CHILD,
+ '''
+import 'package:flutter/src/widgets/framework.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ /*caret*/children: <Widget>[new GestureDetector()],
+ key: null,
+ ),
+// end
+ );
+}
+''');
+ }
+
test_convertToBlockBody_BAD_noEnclosingFunction() async {
await resolveTestUnit('''
var v = 123;
@@ -3502,6 +3625,104 @@ main() {
''');
}
+ test_moveFlutterWidgetDown_OK() async {
+ _configureFlutterPkg({
+ 'src/widgets/framework.dart': _flutter_framework_code,
+ });
+ await resolveTestUnit('''
+import 'package:flutter/src/widgets/framework.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new /*caret*/GestureDetector(
+ onTap: () => startResize(),
+ child: new Center(
+ child: new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ key: null,
+ ),
+ ),
+// end
+ );
+}
+startResize() {}
+''');
+ _setCaretLocation();
+ await assertHasAssist(
+ DartAssistKind.MOVE_FLUTTER_WIDGET_DOWN,
+ '''
+import 'package:flutter/src/widgets/framework.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ child: new /*caret*/GestureDetector(
+ onTap: () => startResize(),
+ child: new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ ),
+ key: null,
+ ),
+// end
+ );
+}
+startResize() {}
+''');
+ }
+
+ test_moveFlutterWidgetUp_OK() async {
+ _configureFlutterPkg({
+ 'src/widgets/framework.dart': _flutter_framework_code,
+ });
+ await resolveTestUnit('''
+import 'package:flutter/src/widgets/framework.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new Center(
+ child: new /*caret*/GestureDetector(
+ onTap: () => startResize(),
+ child: new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ ),
+ key: null,
+ ),
+// end
+ );
+}
+startResize() {}
+''');
+ _setCaretLocation();
+ await assertHasAssist(
+ DartAssistKind.MOVE_FLUTTER_WIDGET_UP,
+ '''
+import 'package:flutter/src/widgets/framework.dart';
+build() {
+ return new Scaffold(
+// start
+ body: new /*caret*/GestureDetector(
+ onTap: () => startResize(),
+ child: new Center(
+ child: new Container(
+ width: 200.0,
+ height: 300.0,
+ ),
+ key: null,
+ ),
+ ),
+// end
+ );
+}
+startResize() {}
+''');
+ }
+
test_removeTypeAnnotation_classField_OK() async {
await resolveTestUnit('''
class A {
@@ -3666,104 +3887,6 @@ class FakeFlutter {
await assertNoAssist(DartAssistKind.REPARENT_FLUTTER_LIST);
}
- test_moveFlutterWidgetDown_OK() async {
- _configureFlutterPkg({
- 'src/widgets/framework.dart': _flutter_framework_code,
- });
- await resolveTestUnit('''
-import 'package:flutter/src/widgets/framework.dart';
-build() {
- return new Scaffold(
-// start
- body: new /*caret*/GestureDetector(
- onTap: () => startResize(),
- child: new Center(
- child: new Container(
- width: 200.0,
- height: 300.0,
- ),
- key: null,
- ),
- ),
-// end
- );
-}
-startResize() {}
-''');
- _setCaretLocation();
- await assertHasAssist(
- DartAssistKind.MOVE_FLUTTER_WIDGET_DOWN,
- '''
-import 'package:flutter/src/widgets/framework.dart';
-build() {
- return new Scaffold(
-// start
- body: new Center(
- child: new /*caret*/GestureDetector(
- onTap: () => startResize(),
- child: new Container(
- width: 200.0,
- height: 300.0,
- ),
- ),
- key: null,
- ),
-// end
- );
-}
-startResize() {}
-''');
- }
-
- test_moveFlutterWidgetUp_OK() async {
- _configureFlutterPkg({
- 'src/widgets/framework.dart': _flutter_framework_code,
- });
- await resolveTestUnit('''
-import 'package:flutter/src/widgets/framework.dart';
-build() {
- return new Scaffold(
-// start
- body: new Center(
- child: new /*caret*/GestureDetector(
- onTap: () => startResize(),
- child: new Container(
- width: 200.0,
- height: 300.0,
- ),
- ),
- key: null,
- ),
-// end
- );
-}
-startResize() {}
-''');
- _setCaretLocation();
- await assertHasAssist(
- DartAssistKind.MOVE_FLUTTER_WIDGET_UP,
- '''
-import 'package:flutter/src/widgets/framework.dart';
-build() {
- return new Scaffold(
-// start
- body: new /*caret*/GestureDetector(
- onTap: () => startResize(),
- child: new Center(
- child: new Container(
- width: 200.0,
- height: 300.0,
- ),
- key: null,
- ),
- ),
-// end
- );
-}
-startResize() {}
-''');
- }
-
test_reparentFlutterList_OK_multiLine() async {
_configureFlutterPkg({
'src/widgets/framework.dart': _flutter_framework_code,
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/assist_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698