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

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.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/suggestion_builder.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
index a57319a6dbce03a064a77ff7500771b04d3764b1..448d848148159974d3ccee9e9887348d0f24894c 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
@@ -8,6 +8,7 @@ import 'package:analysis_server/src/protocol_server.dart' as protocol;
import 'package:analysis_server/src/protocol_server.dart'
hide Element, ElementKind;
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
+import 'package:analysis_server/src/services/completion/dart/utilities.dart';
import 'package:analysis_server/src/utilities/documentation.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
@@ -70,13 +71,18 @@ CompletionSuggestion createSuggestion(Element element,
// Gracefully degrade if type not resolved yet
return paramType != null ? paramType.displayName : 'var';
}).toList();
- suggestion.requiredParameterCount = element.parameters
- .where((ParameterElement parameter) =>
- parameter.parameterKind == ParameterKind.REQUIRED)
- .length;
- suggestion.hasNamedParameters = element.parameters.any(
- (ParameterElement parameter) =>
- parameter.parameterKind == ParameterKind.NAMED);
+
+ Iterable<ParameterElement> requiredParameters = element.parameters.where(
+ (ParameterElement param) =>
+ param.parameterKind == ParameterKind.REQUIRED);
+ suggestion.requiredParameterCount = requiredParameters.length;
+
+ Iterable<ParameterElement> namedParameters = element.parameters.where(
+ (ParameterElement param) => param.parameterKind == ParameterKind.NAMED);
+ suggestion.hasNamedParameters = namedParameters.isNotEmpty;
+
+ suggestion.defaultArgumentListString =
+ buildDefaultArgList(requiredParameters, namedParameters);
}
if (importForSource != null) {
String srcPath = path.dirname(importForSource.fullName);

Powered by Google App Engine
This is Rietveld 408576698