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

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/utilities.dart

Issue 2728653004: Default arg support continued (flutter-intellij#553). (Closed)
Patch Set: Review tweaks. Created 3 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
Index: pkg/analysis_server/lib/src/services/completion/dart/utilities.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart b/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart
index a3ec936bb7299bb792ede1bfdfbab7e16b93425f..f64f5d07c1c15dd79c2daecf5dad510f760aab9c 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart
@@ -13,6 +13,7 @@ import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/standard_ast_factory.dart';
import 'package:analyzer/dart/ast/token.dart';
+import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/ast/token.dart';
import 'package:analyzer/src/generated/source.dart';
@@ -29,6 +30,21 @@ final TypeName NO_RETURN_TYPE = astFactory.typeName(
null);
/**
+ * Build a default argument list based on the given [requiredParams] and
+ * [namedParams].
+ */
+String buildDefaultArgList(Iterable<ParameterElement> requiredParams,
+ Iterable<ParameterElement> namedParams) {
+ List<String> args = requiredParams.map((p) => p.name).toList();
+ List<String> requiredArgs = namedParams
+ .where((p) => p.isRequired)
+ .map((p) => '${p.name}: null')
+ .toList();
+ args.addAll(requiredArgs);
+ return args.isEmpty ? null : args.join(', ');
+}
+
+/**
* Create a new protocol Element for inclusion in a completion suggestion.
*/
protocol.Element createLocalElement(

Powered by Google App Engine
This is Rietveld 408576698