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

Unified Diff: pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart

Issue 2768273003: <Widget> boilerplate for Flutter `children:` suggestions. (Closed)
Patch Set: format 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
Index: pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
index 3ac9fd84a7fcaa58c197af55dbe48b88be1a2d36..9e856143edd4c3e9b5c5eafd06863f3334b79f61 100644
--- a/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
@@ -5,11 +5,13 @@
library test.services.completion.dart.arglist;
import 'package:analysis_server/plugin/protocol/protocol.dart';
+import 'package:analysis_server/src/ide_options.dart';
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
import 'package:analysis_server/src/services/completion/dart/arglist_contributor.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import '../../correction/flutter_util.dart';
import 'completion_contributor_util.dart';
main() {
@@ -717,6 +719,99 @@ main() { f("16", radix: ^);}''');
@reflectiveTest
class ArgListContributorTest_Driver extends ArgListContributorTest {
+ final IdeOptions generateChildrenBoilerPlate = new IdeOptionsImpl()
+ ..generateFlutterWidgetChildrenBoilerPlate = true;
+
@override
bool get enableNewAnalysisDriver => true;
+
+ test_ArgumentList_Flutter_InstanceCreationExpression_children() async {
+ configureFlutterPkg({
+ 'src/widgets/framework.dart': flutter_framework_code,
+ });
+
+ addTestSource('''
+import 'package:flutter/src/widgets/framework.dart';
+
+build() => new Container(
+ child: new Row(^);
+ );
+''');
+
+ await computeSuggestions(options: generateChildrenBoilerPlate);
+
+ assertSuggest('children: ',
+ csKind: CompletionSuggestionKind.NAMED_ARGUMENT,
+ relevance: DART_RELEVANCE_NAMED_PARAMETER,
+ defaultArgListString: '<Widget>[]');
+ }
+
+ test_ArgumentList_Flutter_InstanceCreationExpression_children_dynamic() async {
+ // Ensure we don't generate unneeded <dynamic> param if a future API doesn't
+ // type it's children.
+ configureFlutterPkg({
+ 'src/widgets/framework.dart': flutter_framework_code +
+ '\nclass DynamicRow extends Widget { DynamicRow({List children: null}){}}'
+ });
+
+ addTestSource('''
+import 'package:flutter/src/widgets/framework.dart';
+
+build() => new Container(
+ child: new DynamicRow(^);
+ );
+''');
+
+ await computeSuggestions(options: generateChildrenBoilerPlate);
+
+ assertSuggest('children: ',
+ csKind: CompletionSuggestionKind.NAMED_ARGUMENT,
+ relevance: DART_RELEVANCE_NAMED_PARAMETER,
+ defaultArgListString: '[]');
+ }
+
+ test_ArgumentList_Flutter_InstanceCreationExpression_children_Map() async {
+ // Ensure we don't generate Map params for a future API
+ configureFlutterPkg({
+ 'src/widgets/framework.dart': flutter_framework_code +
+ '\nclass MapRow extends Widget { MapRow({Map<Object,Object> children: null}){}}'
+ });
+
+ addTestSource('''
+import 'package:flutter/src/widgets/framework.dart';
+
+build() => new Container(
+ child: new MapRow(^);
+ );
+''');
+
+ await computeSuggestions(options: generateChildrenBoilerPlate);
+
+ assertSuggest('children: ',
+ csKind: CompletionSuggestionKind.NAMED_ARGUMENT,
+ relevance: DART_RELEVANCE_NAMED_PARAMETER,
+ defaultArgListString: null);
+ }
+
+ test_ArgumentList_Flutter_MethodExpression_children() async {
+ // Ensure we don't generate params for a method call
+ configureFlutterPkg({
+ 'src/widgets/framework.dart':
+ flutter_framework_code + '\nfoo({String children})'
+ });
+
+ addTestSource('''
+import 'package:flutter/src/widgets/framework.dart';
+
+main() {
+foo(^);
+''');
+
+ await computeSuggestions(options: generateChildrenBoilerPlate);
+
+ assertSuggest('children: ',
+ csKind: CompletionSuggestionKind.NAMED_ARGUMENT,
+ relevance: DART_RELEVANCE_NAMED_PARAMETER,
+ defaultArgListString: null);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698