Add code completion support for the flutter section in pubspec.yaml

Change-Id: I1097661d4b4ec329cb315ee908d35a9db9baed18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174160
Reviewed-by: Danny Tuppeny <danny@tuppeny.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/services/completion/yaml/pubspec_generator.dart b/pkg/analysis_server/lib/src/services/completion/yaml/pubspec_generator.dart
index e38bddc..8c01840b 100644
--- a/pkg/analysis_server/lib/src/services/completion/yaml/pubspec_generator.dart
+++ b/pkg/analysis_server/lib/src/services/completion/yaml/pubspec_generator.dart
@@ -29,6 +29,53 @@
     // TODO(brianwilkerson) Suggest names already listed under 'dependencies'
     //  and 'dev_dependencies'.
     'dependency_overrides': EmptyProducer(),
+    'flutter': MapProducer({
+      'assets': EmptyProducer(), // ListProducer(FilePathProducer()),
+      'fonts': ListProducer(MapProducer({
+        'family': EmptyProducer(),
+        'fonts': ListProducer(MapProducer({
+          'asset': EmptyProducer(),
+          'style': EnumProducer(['italic', 'normal']),
+          'weight': EnumProducer(
+              ['100', '200', '300', '400', '500', '600', '700', '800', '900']),
+        })),
+      })),
+      'generate': BooleanProducer(),
+      'module': MapProducer({
+        'androidX': BooleanProducer(),
+        'androidPackage': EmptyProducer(),
+        'iosBundleIdentifier': EmptyProducer(),
+      }),
+      'plugin': MapProducer({
+        'platforms': MapProducer({
+          'android': MapProducer({
+            'package': EmptyProducer(),
+            'pluginClass': EmptyProducer(),
+          }),
+          'ios': MapProducer({
+            'pluginClass': EmptyProducer(),
+          }),
+          'linux': MapProducer({
+            'dartPluginClass': EmptyProducer(),
+            'pluginClass': EmptyProducer(),
+          }),
+          'macos': MapProducer({
+            'dartPluginClass': EmptyProducer(),
+            'pluginClass': EmptyProducer(),
+          }),
+          'web': MapProducer({
+            'fileName': EmptyProducer(),
+            'pluginClass': EmptyProducer(),
+          }),
+          'windows': MapProducer({
+            'dartPluginClass': EmptyProducer(),
+            'pluginClass': EmptyProducer(),
+          }),
+        }),
+      }),
+      'services': EmptyProducer(), // ListProducer(EmptyProducer()),
+      'uses-material-design': BooleanProducer(),
+    }),
   });
 
   /// Initialize a newly created suggestion generator for pubspec files.
diff --git a/pkg/analysis_server/test/src/services/completion/yaml/pubspec_generator_test.dart b/pkg/analysis_server/test/src/services/completion/yaml/pubspec_generator_test.dart
index 7247af0..11430c5 100644
--- a/pkg/analysis_server/test/src/services/completion/yaml/pubspec_generator_test.dart
+++ b/pkg/analysis_server/test/src/services/completion/yaml/pubspec_generator_test.dart
@@ -23,6 +23,7 @@
 
   void test_empty() {
     getCompletions('^');
+    assertSuggestion('flutter: ');
     assertSuggestion('name: ');
   }
 
@@ -34,4 +35,163 @@
     assertSuggestion('flutter: ');
     assertSuggestion('sdk: ');
   }
+
+  void test_flutter() {
+    getCompletions('''
+flutter:
+  ^
+''');
+    assertSuggestion('assets: ');
+    assertSuggestion('plugin: ');
+  }
+
+  void test_flutter_fonts() {
+    getCompletions('''
+flutter:
+  fonts:
+    ^
+''');
+    assertSuggestion('family: ');
+    assertSuggestion('fonts:');
+  }
+
+  void test_flutter_fonts_fonts() {
+    getCompletions('''
+flutter:
+  fonts:
+    - fonts:
+        ^
+''');
+    assertSuggestion('asset: ');
+  }
+
+  void test_flutter_fonts_fonts_style() {
+    getCompletions('''
+flutter:
+  fonts:
+    - fonts:
+       - style: ^
+''');
+    assertSuggestion('italic');
+  }
+
+  void test_flutter_fonts_weight() {
+    getCompletions('''
+flutter:
+  fonts:
+    - fonts:
+        - weight: ^
+''');
+    assertSuggestion('100');
+    assertSuggestion('900');
+  }
+
+  void test_flutter_module() {
+    getCompletions('''
+flutter:
+  module:
+    ^
+''');
+    assertSuggestion('androidX: ');
+    assertSuggestion('iosBundleIdentifier: ');
+  }
+
+  void test_flutter_plugin() {
+    getCompletions('''
+flutter:
+  plugin:
+    ^
+''');
+    assertSuggestion('platforms: ');
+  }
+
+  void test_flutter_plugin_platforms() {
+    getCompletions('''
+flutter:
+  plugin:
+    platforms:
+      ^
+''');
+    assertSuggestion('android: ');
+    assertSuggestion('web: ');
+  }
+
+  void test_flutter_plugin_platforms_android() {
+    getCompletions('''
+flutter:
+  plugin:
+    platforms:
+      android:
+        ^
+''');
+    assertSuggestion('package: ');
+    assertSuggestion('pluginClass: ');
+  }
+
+  void test_flutter_plugin_platforms_ios() {
+    getCompletions('''
+flutter:
+  plugin:
+    platforms:
+      ios:
+        ^
+''');
+    assertSuggestion('pluginClass: ');
+  }
+
+  void test_flutter_plugin_platforms_linux() {
+    getCompletions('''
+flutter:
+  plugin:
+    platforms:
+      linux:
+        ^
+''');
+    assertSuggestion('dartPluginClass: ');
+    assertSuggestion('pluginClass: ');
+  }
+
+  void test_flutter_plugin_platforms_macos() {
+    getCompletions('''
+flutter:
+  plugin:
+    platforms:
+      macos:
+        ^
+''');
+    assertSuggestion('dartPluginClass: ');
+    assertSuggestion('pluginClass: ');
+  }
+
+  void test_flutter_plugin_platforms_web() {
+    getCompletions('''
+flutter:
+  plugin:
+    platforms:
+      web:
+        ^
+''');
+    assertSuggestion('fileName: ');
+    assertSuggestion('pluginClass: ');
+  }
+
+  void test_flutter_plugin_platforms_windows() {
+    getCompletions('''
+flutter:
+  plugin:
+    platforms:
+      windows:
+        ^
+''');
+    assertSuggestion('dartPluginClass: ');
+    assertSuggestion('pluginClass: ');
+  }
+
+  void test_flutter_usesMaterialDesign() {
+    getCompletions('''
+flutter:
+  uses-material-design: ^
+''');
+    assertSuggestion('true');
+  }
 }