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

Unified Diff: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart

Issue 2915913004: Fix inference test annotation of named/optional parameters in function types. (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | pkg/front_end/test/fasta/strong.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
index 0d5db321665922de23708ad2bee6960fb539539f..d19ee4cbf63d08b32e991a3de9b1e3ed67469e12 100644
--- a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
+++ b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
@@ -12,6 +12,7 @@ import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/generated/source.dart';
+import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:front_end/src/base/instrumentation.dart' as fasta;
import 'package:front_end/src/fasta/compiler_context.dart' as fasta;
import 'package:front_end/src/fasta/testing/validating_instrumentation.dart'
@@ -212,10 +213,34 @@ class _InstrumentationValueForType extends fasta.InstrumentationValue {
void _appendParameters(
StringBuffer buffer, List<ParameterElement> parameters) {
- _appendList<ParameterElement>(buffer, '(', ')', parameters, ', ',
- (parameter) {
+ buffer.write('(');
+ bool first = true;
+ ParameterKind lastKind = ParameterKind.REQUIRED;
+ for (var parameter in parameters) {
+ if (!first) {
+ buffer.write(', ');
+ }
+ if (lastKind != parameter.parameterKind) {
+ if (parameter.parameterKind == ParameterKind.POSITIONAL) {
+ buffer.write('[');
+ } else if (parameter.parameterKind == ParameterKind.NAMED) {
+ buffer.write('{');
+ }
+ }
+ if (parameter.parameterKind == ParameterKind.NAMED) {
+ buffer.write(parameter.name);
+ buffer.write(': ');
+ }
_appendType(buffer, parameter.type);
- }, includeEmpty: true);
+ lastKind = parameter.parameterKind;
+ first = false;
+ }
+ if (lastKind == ParameterKind.POSITIONAL) {
+ buffer.write(']');
+ } else if (lastKind == ParameterKind.NAMED) {
+ buffer.write('}');
+ }
+ buffer.write(')');
}
void _appendType(StringBuffer buffer, DartType type) {
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/strong.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698