diff --git a/pkg/analyzer/lib/src/dart/element/display_string_builder.dart b/pkg/analyzer/lib/src/dart/element/display_string_builder.dart index 60d3e16b0c70..939a09104961 100644 --- a/pkg/analyzer/lib/src/dart/element/display_string_builder.dart +++ b/pkg/analyzer/lib/src/dart/element/display_string_builder.dart @@ -11,18 +11,21 @@ import 'package:analyzer/src/dart/element/type_algebra.dart'; import 'package:analyzer/src/dart/resolver/variance.dart'; import 'package:analyzer/src/generated/element_type_provider.dart'; +/// A class that builds a "display string" for [Element]s and [DartType]s. class ElementDisplayStringBuilder { final StringBuffer _buffer = StringBuffer(); - final bool skipAllDynamicArguments; - final bool withNullability; - final bool multiline; + /// Whether to include the nullability ('?' characters) in a display string. + final bool _withNullability; + + /// Whether to allow a display string to be written in multiple lines. + final bool _multiline; ElementDisplayStringBuilder({ - required this.skipAllDynamicArguments, - required this.withNullability, - this.multiline = false, - }); + required bool withNullability, + bool multiline = false, + }) : _withNullability = withNullability, + _multiline = multiline; @override String toString() { @@ -336,7 +339,7 @@ class ElementDisplayStringBuilder { // Assume the display string looks better wrapped when there are at least // three parameters. This avoids having to pre-compute the single-line // version and know the length of the function name/return type. - var multiline = allowMultiline && this.multiline && parameters.length >= 3; + var multiline = allowMultiline && _multiline && parameters.length >= 3; // The prefix for open groups is included in separator for single-line but // not for multline so must be added explicitly. @@ -388,16 +391,13 @@ class ElementDisplayStringBuilder { } void _writeNullability(NullabilitySuffix nullabilitySuffix) { - if (withNullability) { + if (_withNullability) { switch (nullabilitySuffix) { case NullabilitySuffix.question: _write('?'); - break; case NullabilitySuffix.star: _write('*'); - break; case NullabilitySuffix.none: - break; } } } @@ -411,12 +411,6 @@ class ElementDisplayStringBuilder { return; } - if (skipAllDynamicArguments) { - if (typeArguments.every((t) => t is DynamicType)) { - return; - } - } - _write('<'); for (var i = 0; i < typeArguments.length; i++) { if (i != 0) { diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart index eb155044bd95..ab483180ac7c 100644 --- a/pkg/analyzer/lib/src/dart/element/element.dart +++ b/pkg/analyzer/lib/src/dart/element/element.dart @@ -2469,7 +2469,6 @@ abstract class ElementImpl implements Element { bool multiline = false, }) { var builder = ElementDisplayStringBuilder( - skipAllDynamicArguments: false, withNullability: withNullability, multiline: multiline, ); diff --git a/pkg/analyzer/lib/src/dart/element/member.dart b/pkg/analyzer/lib/src/dart/element/member.dart index bb0b13ab15aa..6eb42bafa8cb 100644 --- a/pkg/analyzer/lib/src/dart/element/member.dart +++ b/pkg/analyzer/lib/src/dart/element/member.dart @@ -683,7 +683,6 @@ abstract class Member implements Element { bool multiline = false, }) { var builder = ElementDisplayStringBuilder( - skipAllDynamicArguments: false, withNullability: withNullability, multiline: multiline, ); diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart index 628b014a3215..c70639fa3a39 100644 --- a/pkg/analyzer/lib/src/dart/element/type.dart +++ b/pkg/analyzer/lib/src/dart/element/type.dart @@ -1347,11 +1347,9 @@ abstract class TypeImpl implements DartType { @override String getDisplayString({ - bool skipAllDynamicArguments = false, required bool withNullability, }) { var builder = ElementDisplayStringBuilder( - skipAllDynamicArguments: skipAllDynamicArguments, withNullability: withNullability, ); appendTo(builder);