mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:27:39 +00:00
Legacy. Deprecate 'withNullability' in getDisplayString() methods.
Change-Id: I688f230f4189cd1fc600e4d34f07f339111c382d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350645 Reviewed-by: Phil Quitslund <pquitslund@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
5055a516f1
commit
14a1045f16
|
@ -181,7 +181,7 @@ String? _getParametersString(engine.Element element) {
|
|||
} else if (parameter.hasRequired) {
|
||||
sb.write('@required ');
|
||||
}
|
||||
parameter.appendToWithoutDelimiters(sb, withNullability: true);
|
||||
parameter.appendToWithoutDelimiters(sb);
|
||||
}
|
||||
sb.write(closeOptionalString);
|
||||
return '($sb)';
|
||||
|
|
|
@ -111,7 +111,6 @@ class DartUnitHoverComputer {
|
|||
/// whether they are const).
|
||||
String? _elementDisplayString(AstNode node, Element? element) {
|
||||
var displayString = element?.getDisplayString(
|
||||
withNullability: true,
|
||||
multiline: true,
|
||||
);
|
||||
|
||||
|
@ -254,7 +253,7 @@ class DartUnitHoverComputer {
|
|||
} else if (node is DartPattern) {
|
||||
staticType = node.matchedValueType;
|
||||
}
|
||||
return staticType?.getDisplayString(withNullability: true);
|
||||
return staticType?.getDisplayString();
|
||||
}
|
||||
|
||||
/// Whether to use the non-synthetic element for hover information.
|
||||
|
|
|
@ -174,8 +174,7 @@ class DartInlayHintComputer {
|
|||
parts.add(InlayHintLabelPart(
|
||||
// Write type without type args or nullability suffix. Type args need
|
||||
// adding as their own parts, and the nullability suffix does after them.
|
||||
value:
|
||||
type.element?.name ?? type.getDisplayString(withNullability: false),
|
||||
value: type.element?.name ?? type.getDisplayString(),
|
||||
location: _locationForElement(type.element),
|
||||
));
|
||||
// Call recursively for any nested type arguments.
|
||||
|
|
|
@ -263,7 +263,7 @@ class TypeHierarchyItem {
|
|||
|
||||
/// Returns a name to display in the hierarchy for [type].
|
||||
static String _displayNameForType(InterfaceType type) {
|
||||
return type.getDisplayString(withNullability: false);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
|
||||
/// Returns the [SourceRange] of the name for [element].
|
||||
|
|
|
@ -77,7 +77,7 @@ class DartUnitSignatureComputer {
|
|||
? ParameterKind.REQUIRED_NAMED
|
||||
: ParameterKind.REQUIRED_POSITIONAL,
|
||||
param.displayName,
|
||||
param.type.getDisplayString(withNullability: true),
|
||||
param.type.getDisplayString(),
|
||||
defaultValue: param.defaultValueCode);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class DartTypeArgumentsSignatureComputer {
|
|||
|
||||
_argumentList = argumentList;
|
||||
|
||||
final label = element.getDisplayString(withNullability: true);
|
||||
final label = element.getDisplayString();
|
||||
final documentation = DartUnitHoverComputer.computePreferredDocumentation(
|
||||
_dartdocInfo, element, documentationPreference);
|
||||
|
||||
|
@ -88,7 +88,7 @@ class DartTypeArgumentsSignatureComputer {
|
|||
) {
|
||||
final parameters = typeParameters
|
||||
.map((param) => lsp.ParameterInformation(
|
||||
label: param.getDisplayString(withNullability: true),
|
||||
label: param.getDisplayString(),
|
||||
))
|
||||
.toList();
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ void doSourceChange_addSourceEdit(
|
|||
String? getAliasedTypeString(engine.Element element) {
|
||||
if (element is engine.TypeAliasElement) {
|
||||
var aliasedType = element.aliasedType;
|
||||
return aliasedType.getDisplayString(withNullability: true);
|
||||
return aliasedType.getDisplayString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -59,16 +59,16 @@ String? getReturnTypeString(engine.Element element) {
|
|||
if (element.kind == engine.ElementKind.SETTER) {
|
||||
return null;
|
||||
} else {
|
||||
return element.returnType.getDisplayString(withNullability: true);
|
||||
return element.returnType.getDisplayString();
|
||||
}
|
||||
} else if (element is engine.VariableElement) {
|
||||
var type = element.type;
|
||||
return type.getDisplayString(withNullability: true);
|
||||
return type.getDisplayString();
|
||||
} else if (element is engine.TypeAliasElement) {
|
||||
var aliasedType = element.aliasedType;
|
||||
if (aliasedType is FunctionType) {
|
||||
var returnType = aliasedType.returnType;
|
||||
return returnType.getDisplayString(withNullability: true);
|
||||
return returnType.getDisplayString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -101,9 +101,8 @@ class TypeHierarchyComputer {
|
|||
{
|
||||
String? displayName;
|
||||
if (typeArguments != null && typeArguments.isNotEmpty) {
|
||||
var typeArgumentsStr = typeArguments
|
||||
.map((type) => type.getDisplayString(withNullability: true))
|
||||
.join(', ');
|
||||
var typeArgumentsStr =
|
||||
typeArguments.map((type) => type.getDisplayString()).join(', ');
|
||||
displayName = '${classElement.displayName}<$typeArgumentsStr>';
|
||||
}
|
||||
var memberElement = helper.findMemberElement(classElement);
|
||||
|
|
|
@ -809,7 +809,7 @@ class SuggestionBuilder {
|
|||
required bool appendComma,
|
||||
int? replacementLength}) {
|
||||
var name = parameter.name;
|
||||
var type = parameter.type.getDisplayString(withNullability: true);
|
||||
var type = parameter.type.getDisplayString();
|
||||
|
||||
var completion = name;
|
||||
if (appendColon) {
|
||||
|
@ -883,9 +883,7 @@ class SuggestionBuilder {
|
|||
required bool appendComma,
|
||||
int? replacementLength}) {
|
||||
final name = field.name;
|
||||
final type = field.type.getDisplayString(
|
||||
withNullability: true,
|
||||
);
|
||||
final type = field.type.getDisplayString();
|
||||
|
||||
var completion = name;
|
||||
if (appendColon) {
|
||||
|
@ -1037,9 +1035,7 @@ class SuggestionBuilder {
|
|||
contextType: contextType,
|
||||
);
|
||||
|
||||
final returnType = field.type.getDisplayString(
|
||||
withNullability: true,
|
||||
);
|
||||
final returnType = field.type.getDisplayString();
|
||||
|
||||
_addSuggestion(
|
||||
CompletionSuggestion(
|
||||
|
@ -1476,9 +1472,7 @@ class SuggestionBuilder {
|
|||
return parameter.name;
|
||||
}).toList();
|
||||
parameterTypes = element.parameters.map((ParameterElement parameter) {
|
||||
return parameter.type.getDisplayString(
|
||||
withNullability: true,
|
||||
);
|
||||
return parameter.type.getDisplayString();
|
||||
}).toList();
|
||||
|
||||
var requiredParameters = element.parameters
|
||||
|
|
|
@ -218,7 +218,7 @@ String getTypeString(DartType type) {
|
|||
if (type is DynamicType) {
|
||||
return '';
|
||||
} else {
|
||||
return '${type.getDisplayString(withNullability: true)} ';
|
||||
return '${type.getDisplayString()} ';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ String? nameForType(SimpleIdentifier identifier, TypeAnnotation? declaredType) {
|
|||
}
|
||||
return DYNAMIC;
|
||||
}
|
||||
return type.getDisplayString(withNullability: false);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
|
||||
class CompletionDefaultArgumentList {
|
||||
|
|
|
@ -466,9 +466,7 @@ class PostfixCompletionProcessor {
|
|||
}
|
||||
|
||||
// Can't catch nullable types, strip `?`s now that we've checked for `*`s.
|
||||
return type
|
||||
.withNullability(NullabilitySuffix.none)
|
||||
.getDisplayString(withNullability: true);
|
||||
return type.withNullability(NullabilitySuffix.none).getDisplayString();
|
||||
}
|
||||
return 'Exception';
|
||||
}
|
||||
|
|
|
@ -588,8 +588,7 @@ abstract class _AbstractCorrectionProducer<T extends ParsedUnitResult> {
|
|||
|
||||
/// Return the text that should be displayed to users when referring to the
|
||||
/// given [type].
|
||||
String displayStringForType(DartType type) =>
|
||||
type.getDisplayString(withNullability: true);
|
||||
String displayStringForType(DartType type) => type.getDisplayString();
|
||||
|
||||
CodeStyleOptions getCodeStyleOptions(File file) =>
|
||||
sessionHelper.session.analysisContext
|
||||
|
|
|
@ -79,8 +79,7 @@ class EncapsulateField extends ResolvedCorrectionProducer {
|
|||
var normalParam = parameter.parameter;
|
||||
if (normalParam is FieldFormalParameter) {
|
||||
var start = normalParam.thisKeyword;
|
||||
var type = parameterElement.type
|
||||
.getDisplayString(withNullability: true);
|
||||
var type = parameterElement.type.getDisplayString();
|
||||
builder.addSimpleReplacement(
|
||||
range.startEnd(start, normalParam.period), '$type ');
|
||||
|
||||
|
|
|
@ -6,7 +6,9 @@ import 'package:_fe_analyzer_shared/src/scanner/token.dart';
|
|||
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/element/nullability_suffix.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer/src/dart/element/type.dart';
|
||||
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
|
||||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
import 'package:analyzer_plugin/utilities/range_factory.dart';
|
||||
|
@ -51,8 +53,12 @@ class ReplaceNullCheckWithCast extends ResolvedCorrectionProducer {
|
|||
// TODO(srawlins): Follow up on
|
||||
// https://github.com/dart-lang/linter/issues/3256.
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
builder.addSimpleReplacement(range.token(operator!),
|
||||
' as ${operandType!.getDisplayString(withNullability: false)}');
|
||||
var operandTypeNonNull =
|
||||
(operandType as TypeImpl).withNullability(NullabilitySuffix.none);
|
||||
builder.addSimpleReplacement(
|
||||
range.token(operator!),
|
||||
' as ${operandTypeNonNull.getDisplayString()}',
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class ReplaceReturnType extends ResolvedCorrectionProducer {
|
|||
newType = typeProvider.futureType(newType!);
|
||||
}
|
||||
|
||||
_newType = newType!.getDisplayString(withNullability: true);
|
||||
_newType = newType!.getDisplayString();
|
||||
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
if (builder.canWriteType(newType)) {
|
||||
|
|
|
@ -563,9 +563,7 @@ class _SelectionAnalyzer {
|
|||
return const UnexpectedSelectionState();
|
||||
}
|
||||
|
||||
final typeStr = parameterElement.type.getDisplayString(
|
||||
withNullability: true,
|
||||
);
|
||||
final typeStr = parameterElement.type.getDisplayString();
|
||||
|
||||
formalParameterStateList.add(
|
||||
FormalParameterState(
|
||||
|
|
|
@ -84,8 +84,7 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
|
|||
String? typeString;
|
||||
if (codeStyleOptions.specifyTypes) {
|
||||
typeString = singleExpression != null
|
||||
? singleExpression?.staticType
|
||||
?.getDisplayString(withNullability: true)
|
||||
? singleExpression?.staticType?.getDisplayString()
|
||||
: stringLiteralPart != null
|
||||
? 'String'
|
||||
: null;
|
||||
|
|
|
@ -142,7 +142,7 @@ class RenameClassMemberRefactoringImpl extends RenameRefactoringImpl {
|
|||
var parameter = node.parameter as FieldFormalParameter;
|
||||
|
||||
var start = parameter.thisKeyword.offset;
|
||||
var type = element.type.getDisplayString(withNullability: true);
|
||||
var type = element.type.getDisplayString();
|
||||
var edit = SourceEdit(start, parameter.period.end - start, '$type ');
|
||||
doSourceChange_addSourceEdit(change, reference.unitSource, edit);
|
||||
|
||||
|
|
|
@ -743,7 +743,7 @@ MyCl^ass1<String, String>? a;
|
|||
addTestSource(content);
|
||||
await expectTarget(
|
||||
_isItem(
|
||||
'MyClass1<String, String>',
|
||||
'MyClass1<String, String>?',
|
||||
testFile.path,
|
||||
codeRange: code.ranges[0].sourceRange,
|
||||
nameRange: code.ranges[1].sourceRange,
|
||||
|
|
|
@ -27,7 +27,7 @@ class ContextTypeTest extends FeatureComputerTest {
|
|||
if (expectedType == null) {
|
||||
expect(type, null);
|
||||
} else {
|
||||
expect(type?.getDisplayString(withNullability: false), expectedType);
|
||||
expect(type?.getDisplayString(), expectedType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ class ImpliedTypeCollector extends RecursiveAstVisitor<void> {
|
|||
// Record the name with the type.
|
||||
data.recordImpliedType(
|
||||
node.name.lexeme,
|
||||
rhsType.getDisplayString(withNullability: false),
|
||||
rhsType.getDisplayString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -745,7 +745,8 @@ abstract class Element implements AnalysisTarget {
|
|||
/// Clients should not depend on the content of the returned value as it will
|
||||
/// be changed if doing so would improve the UX.
|
||||
String getDisplayString({
|
||||
required bool withNullability,
|
||||
@Deprecated('Only non-nullable by default mode is supported')
|
||||
bool withNullability = true,
|
||||
bool multiline = false,
|
||||
});
|
||||
|
||||
|
@ -2198,7 +2199,8 @@ abstract class ParameterElement
|
|||
/// to the given [buffer].
|
||||
void appendToWithoutDelimiters(
|
||||
StringBuffer buffer, {
|
||||
bool withNullability = false,
|
||||
@Deprecated('Only non-nullable by default mode is supported')
|
||||
bool withNullability = true,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,10 @@ abstract class DartType {
|
|||
///
|
||||
/// Clients should not depend on the content of the returned value as it will
|
||||
/// be changed if doing so would improve the UX.
|
||||
String getDisplayString({required bool withNullability});
|
||||
String getDisplayString({
|
||||
@Deprecated('Only non-nullable by default mode is supported')
|
||||
bool withNullability = true,
|
||||
});
|
||||
|
||||
/// If this type is a [TypeParameterType], returns its bound if it has one, or
|
||||
/// [objectType] otherwise.
|
||||
|
|
|
@ -256,9 +256,7 @@ class ErrorReporter {
|
|||
for (var i = 0; i < arguments.length; i++) {
|
||||
var argument = arguments[i];
|
||||
if (argument is Element) {
|
||||
arguments[i] = argument.getDisplayString(
|
||||
withNullability: true,
|
||||
);
|
||||
arguments[i] = argument.getDisplayString();
|
||||
} else if (!(argument is String ||
|
||||
argument is DartType ||
|
||||
argument is int ||
|
||||
|
@ -284,9 +282,7 @@ class ErrorReporter {
|
|||
for (int i = 0; i < arguments.length; i++) {
|
||||
var argument = arguments[i];
|
||||
if (argument is DartType) {
|
||||
String displayName = argument.getDisplayString(
|
||||
withNullability: true,
|
||||
);
|
||||
String displayName = argument.getDisplayString();
|
||||
List<_TypeToConvert> types =
|
||||
typeGroups.putIfAbsent(displayName, () => <_TypeToConvert>[]);
|
||||
types.add(_TypeToConvert(i, argument, displayName));
|
||||
|
|
|
@ -285,7 +285,7 @@ class ParsedLibraryResultImpl extends AnalysisResultImpl
|
|||
var unitResult = units.firstWhere(
|
||||
(r) => r.path == elementPath,
|
||||
orElse: () {
|
||||
var elementStr = element.getDisplayString(withNullability: true);
|
||||
var elementStr = element.getDisplayString();
|
||||
throw ArgumentError('Element (${element.runtimeType}) $elementStr is '
|
||||
'not defined in this library.');
|
||||
},
|
||||
|
@ -408,7 +408,7 @@ class ResolvedLibraryResultImpl extends AnalysisResultImpl
|
|||
var unitResult = units.firstWhere(
|
||||
(r) => r.path == elementPath,
|
||||
orElse: () {
|
||||
var elementStr = element.getDisplayString(withNullability: true);
|
||||
var elementStr = element.getDisplayString();
|
||||
throw ArgumentError('Element (${element.runtimeType}) $elementStr is '
|
||||
'not defined in this library.');
|
||||
},
|
||||
|
|
|
@ -1121,7 +1121,7 @@ class _FindCompilationUnitDeclarations {
|
|||
|
||||
String? parameters;
|
||||
if (element is ExecutableElement) {
|
||||
var displayString = element.getDisplayString(withNullability: true);
|
||||
var displayString = element.getDisplayString();
|
||||
var parameterIndex = displayString.indexOf('(');
|
||||
if (parameterIndex > 0) {
|
||||
parameters = displayString.substring(parameterIndex);
|
||||
|
|
|
@ -130,8 +130,8 @@ class ConstantEvaluationEngine {
|
|||
constantInitializer,
|
||||
CompileTimeErrorCode.VARIABLE_TYPE_MISMATCH,
|
||||
arguments: [
|
||||
dartConstant.type.getDisplayString(withNullability: true),
|
||||
constant.type.getDisplayString(withNullability: true),
|
||||
dartConstant.type.getDisplayString(),
|
||||
constant.type.getDisplayString(),
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
@ -1666,10 +1666,8 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
|
|||
|
||||
// No other property access is allowed except for `.length` of a `String`.
|
||||
return InvalidConstant.forEntity(
|
||||
errorNode, CompileTimeErrorCode.CONST_EVAL_PROPERTY_ACCESS, arguments: [
|
||||
identifier.name,
|
||||
targetType.getDisplayString(withNullability: true)
|
||||
]);
|
||||
errorNode, CompileTimeErrorCode.CONST_EVAL_PROPERTY_ACCESS,
|
||||
arguments: [identifier.name, targetType.getDisplayString()]);
|
||||
}
|
||||
|
||||
/// Returns a [Constant] based on the [element] provided.
|
||||
|
@ -2574,9 +2572,9 @@ class _InstanceCreationEvaluator {
|
|||
return InvalidConstant.forEntity(errorNode,
|
||||
CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
|
||||
arguments: [
|
||||
fieldValue.type.getDisplayString(withNullability: true),
|
||||
fieldValue.type.getDisplayString(),
|
||||
field.name,
|
||||
fieldType.getDisplayString(withNullability: true),
|
||||
fieldType.getDisplayString(),
|
||||
],
|
||||
isRuntimeException: isRuntimeException);
|
||||
}
|
||||
|
@ -2671,10 +2669,9 @@ class _InstanceCreationEvaluator {
|
|||
CompileTimeErrorCode
|
||||
.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
|
||||
arguments: [
|
||||
evaluationResult.type
|
||||
.getDisplayString(withNullability: true),
|
||||
evaluationResult.type.getDisplayString(),
|
||||
fieldName,
|
||||
field.type.getDisplayString(withNullability: true),
|
||||
field.type.getDisplayString(),
|
||||
],
|
||||
isRuntimeException: isRuntimeException),
|
||||
evaluationIsComplete: true);
|
||||
|
@ -2822,8 +2819,8 @@ class _InstanceCreationEvaluator {
|
|||
return InvalidConstant.forEntity(errorTarget,
|
||||
CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
||||
arguments: [
|
||||
argumentValue.type.getDisplayString(withNullability: true),
|
||||
parameter.type.getDisplayString(withNullability: true),
|
||||
argumentValue.type.getDisplayString(),
|
||||
parameter.type.getDisplayString(),
|
||||
],
|
||||
isRuntimeException: isEvaluationException);
|
||||
}
|
||||
|
@ -2840,9 +2837,8 @@ class _InstanceCreationEvaluator {
|
|||
return InvalidConstant.forEntity(errorTarget,
|
||||
CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
||||
arguments: [
|
||||
argumentValue.type
|
||||
.getDisplayString(withNullability: true),
|
||||
fieldType.getDisplayString(withNullability: true),
|
||||
argumentValue.type.getDisplayString(),
|
||||
fieldType.getDisplayString(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -946,7 +946,7 @@ class DartObjectImpl implements DartObject, Constant {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "${type.getDisplayString(withNullability: false)} ($state)";
|
||||
return "${type.getDisplayString()} ($state)";
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -3130,7 +3130,7 @@ class TypeState extends InstanceState {
|
|||
if (_type == null) {
|
||||
return StringState.UNKNOWN_VALUE;
|
||||
}
|
||||
return StringState(_type!.getDisplayString(withNullability: false));
|
||||
return StringState(_type!.getDisplayString());
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -3161,6 +3161,6 @@ class TypeState extends InstanceState {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return _type?.getDisplayString(withNullability: true) ?? '-unknown-';
|
||||
return _type?.getDisplayString() ?? '-unknown-';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@ class ElementDisplayStringBuilder {
|
|||
final bool _multiline;
|
||||
|
||||
ElementDisplayStringBuilder({
|
||||
required bool withNullability,
|
||||
@Deprecated('Only non-nullable by default mode is supported')
|
||||
bool withNullability = true,
|
||||
bool multiline = false,
|
||||
}) : _withNullability = withNullability,
|
||||
_multiline = multiline;
|
||||
|
|
|
@ -2414,11 +2414,11 @@ abstract class ElementImpl implements Element {
|
|||
|
||||
@override
|
||||
String getDisplayString({
|
||||
required bool withNullability,
|
||||
@Deprecated('Only non-nullable by default mode is supported')
|
||||
bool withNullability = true,
|
||||
bool multiline = false,
|
||||
}) {
|
||||
var builder = ElementDisplayStringBuilder(
|
||||
withNullability: withNullability,
|
||||
multiline: multiline,
|
||||
);
|
||||
appendTo(builder);
|
||||
|
@ -2484,7 +2484,7 @@ abstract class ElementImpl implements Element {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return getDisplayString(withNullability: true);
|
||||
return getDisplayString();
|
||||
}
|
||||
|
||||
/// Use the given [visitor] to visit all of the children of this element.
|
||||
|
@ -5514,13 +5514,12 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
|
|||
|
||||
@override
|
||||
String getDisplayString({
|
||||
required bool withNullability,
|
||||
@Deprecated('Only non-nullable by default mode is supported')
|
||||
bool withNullability = true,
|
||||
bool multiline = false,
|
||||
}) {
|
||||
var elementsStr = conflictingElements.map((e) {
|
||||
return e.getDisplayString(
|
||||
withNullability: withNullability,
|
||||
);
|
||||
return e.getDisplayString();
|
||||
}).join(', ');
|
||||
return '[$elementsStr]';
|
||||
}
|
||||
|
@ -5565,7 +5564,7 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
|
|||
needsSeparator = true;
|
||||
}
|
||||
buffer.write(
|
||||
element.getDisplayString(withNullability: true),
|
||||
element.getDisplayString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -5983,10 +5982,12 @@ mixin ParameterElementMixin implements ParameterElement {
|
|||
@override
|
||||
void appendToWithoutDelimiters(
|
||||
StringBuffer buffer, {
|
||||
bool withNullability = false,
|
||||
@Deprecated('Only non-nullable by default mode is supported')
|
||||
bool withNullability = true,
|
||||
}) {
|
||||
buffer.write(
|
||||
type.getDisplayString(
|
||||
// ignore:deprecated_member_use_from_same_package
|
||||
withNullability: withNullability,
|
||||
),
|
||||
);
|
||||
|
|
|
@ -475,14 +475,12 @@ class GenericInferrer {
|
|||
}
|
||||
|
||||
String _elementStr(Element element) {
|
||||
return element.getDisplayString(withNullability: true);
|
||||
return element.getDisplayString();
|
||||
}
|
||||
|
||||
String _formatError(TypeParameterElement typeParam, DartType inferred,
|
||||
Iterable<_TypeConstraint> constraints) {
|
||||
var inferredStr = inferred.getDisplayString(
|
||||
withNullability: true,
|
||||
);
|
||||
var inferredStr = inferred.getDisplayString();
|
||||
var intro = "Tried to infer '$inferredStr' for '${typeParam.name}'"
|
||||
" which doesn't work:";
|
||||
|
||||
|
@ -657,7 +655,7 @@ class GenericInferrer {
|
|||
}
|
||||
|
||||
String _typeStr(DartType type) {
|
||||
return type.getDisplayString(withNullability: true);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
|
||||
static String _formatConstraints(Iterable<_TypeConstraint> constraints) {
|
||||
|
@ -825,7 +823,7 @@ abstract class _TypeConstraintOrigin {
|
|||
List<String> formatError();
|
||||
|
||||
String _typeStr(DartType type) {
|
||||
return type.getDisplayString(withNullability: true);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -881,9 +879,9 @@ class _TypeRange {
|
|||
/// For example, if [typeName] is 'T' and the range has bounds int and Object
|
||||
/// respectively, the returned string will be 'int <: T <: Object'.
|
||||
@visibleForTesting
|
||||
String format(String typeName, {required bool withNullability}) {
|
||||
String format(String typeName) {
|
||||
String typeStr(DartType type) {
|
||||
return type.getDisplayString(withNullability: withNullability);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
|
||||
var lowerString = identical(lowerBound, UnknownInferredType.instance)
|
||||
|
@ -896,5 +894,5 @@ class _TypeRange {
|
|||
}
|
||||
|
||||
@override
|
||||
String toString() => format('(type)', withNullability: true);
|
||||
String toString() => format('(type)');
|
||||
}
|
||||
|
|
|
@ -704,11 +704,11 @@ abstract class Member implements Element {
|
|||
|
||||
@override
|
||||
String getDisplayString({
|
||||
required bool withNullability,
|
||||
@Deprecated('Only non-nullable by default mode is supported')
|
||||
bool withNullability = true,
|
||||
bool multiline = false,
|
||||
}) {
|
||||
var builder = ElementDisplayStringBuilder(
|
||||
withNullability: withNullability,
|
||||
multiline: multiline,
|
||||
);
|
||||
appendTo(builder);
|
||||
|
@ -736,7 +736,7 @@ abstract class Member implements Element {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return getDisplayString(withNullability: false);
|
||||
return getDisplayString();
|
||||
}
|
||||
|
||||
/// Use the given [visitor] to visit all of the children of this element.
|
||||
|
|
|
@ -1331,9 +1331,11 @@ abstract class TypeImpl implements DartType {
|
|||
|
||||
@override
|
||||
String getDisplayString({
|
||||
required bool withNullability,
|
||||
@Deprecated('Only non-nullable by default mode is supported')
|
||||
bool withNullability = true,
|
||||
}) {
|
||||
var builder = ElementDisplayStringBuilder(
|
||||
// ignore:deprecated_member_use_from_same_package
|
||||
withNullability: withNullability,
|
||||
);
|
||||
appendTo(builder);
|
||||
|
@ -1351,7 +1353,7 @@ abstract class TypeImpl implements DartType {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return getDisplayString(withNullability: true);
|
||||
return getDisplayString();
|
||||
}
|
||||
|
||||
/// Return the same type, but with the given [nullabilitySuffix].
|
||||
|
|
|
@ -28,8 +28,8 @@ class TypeConstraint {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
var lowerStr = lower.getDisplayString(withNullability: true);
|
||||
var upperStr = upper.getDisplayString(withNullability: true);
|
||||
var lowerStr = lower.getDisplayString();
|
||||
var upperStr = upper.getDisplayString();
|
||||
return '$lowerStr <: ${parameter.name} <: $upperStr';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,8 +117,7 @@ class ExtensionMemberResolver {
|
|||
if (name != null) {
|
||||
return "extension '$name'";
|
||||
}
|
||||
var type = e.extension.extendedType
|
||||
.getDisplayString(withNullability: true);
|
||||
var type = e.extension.extendedType.getDisplayString();
|
||||
return "unnamed extension on '$type'";
|
||||
}).commaSeparatedWithAnd,
|
||||
],
|
||||
|
|
|
@ -772,9 +772,7 @@ class _ClassVerifier {
|
|||
} else if (conflict is CandidatesConflict) {
|
||||
var candidatesStr = conflict.candidates.map((candidate) {
|
||||
var className = candidate.enclosingElement.name;
|
||||
var typeStr = candidate.type.getDisplayString(
|
||||
withNullability: true,
|
||||
);
|
||||
var typeStr = candidate.type.getDisplayString();
|
||||
return '$className.${name.name} ($typeStr)';
|
||||
}).join(', ');
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ class NullSafeApiVerifier {
|
|||
_errorReporter.atNode(
|
||||
argument ?? node,
|
||||
WarningCode.NULL_ARGUMENT_TO_NON_NULL_TYPE,
|
||||
arguments: [memberName, type.getDisplayString(withNullability: true)],
|
||||
arguments: [memberName, type.getDisplayString()],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -342,9 +342,7 @@ class TypeArgumentsVerifier {
|
|||
}
|
||||
|
||||
String typeArgumentsToString(List<DartType> typeArguments) {
|
||||
return typeArguments
|
||||
.map((e) => e.getDisplayString(withNullability: true))
|
||||
.join(', ');
|
||||
return typeArguments.map((e) => e.getDisplayString()).join(', ');
|
||||
}
|
||||
|
||||
if (namedType.typeArguments == null) {
|
||||
|
|
|
@ -127,7 +127,7 @@ mixin ErrorDetectionHelpers {
|
|||
if (!namedFields.any((element) =>
|
||||
element.name == field.name && field.type == element.type)) {
|
||||
additionalInfo.add(
|
||||
'Unexpected named argument `${field.name}` with type `${field.type.getDisplayString(withNullability: true)}`.');
|
||||
'Unexpected named argument `${field.name}` with type `${field.type.getDisplayString()}`.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2261,8 +2261,8 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
|||
arguments: [
|
||||
_enclosingClass!.kind.displayName,
|
||||
_enclosingClass!.name,
|
||||
error.first.getDisplayString(withNullability: true),
|
||||
error.second.getDisplayString(withNullability: true),
|
||||
error.first.getDisplayString(),
|
||||
error.second.getDisplayString(),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -477,7 +477,7 @@ class MissingPatternTypePart extends MissingPatternPart {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return type.getDisplayString(withNullability: true);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -646,8 +646,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
|
|||
|
||||
bool _extendsNativeFieldWrapperClass1(InterfaceType? type) {
|
||||
while (type != null) {
|
||||
if (type.getDisplayString(withNullability: false) ==
|
||||
'NativeFieldWrapperClass1') {
|
||||
if (type.getDisplayString() == 'NativeFieldWrapperClass1') {
|
||||
return true;
|
||||
}
|
||||
final element = type.element;
|
||||
|
@ -1349,10 +1348,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
|
|||
_errorReporter.atNode(
|
||||
node,
|
||||
FfiCode.EMPTY_STRUCT,
|
||||
arguments: [
|
||||
clazz.name,
|
||||
clazz.supertype!.getDisplayString(withNullability: false)
|
||||
],
|
||||
arguments: [clazz.name, clazz.supertype!.getDisplayString()],
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -709,9 +709,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
}
|
||||
var propertyType = whyNotPromotedVisitor.propertyType;
|
||||
if (propertyType != null) {
|
||||
var propertyTypeStr = propertyType.getDisplayString(
|
||||
withNullability: true,
|
||||
);
|
||||
var propertyTypeStr = propertyType.getDisplayString();
|
||||
args.add('type: $propertyTypeStr');
|
||||
}
|
||||
if (args.isNotEmpty) {
|
||||
|
@ -3944,8 +3942,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
if (name == null) {
|
||||
var staticElement = nameNode.staticElement;
|
||||
if (staticElement != null) {
|
||||
name =
|
||||
'${staticElement.returnType.getDisplayString(withNullability: true)}.new';
|
||||
name = '${staticElement.returnType.getDisplayString()}.new';
|
||||
}
|
||||
}
|
||||
} else if (nameNode is SuperConstructorInvocation) {
|
||||
|
@ -3953,8 +3950,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
if (name == null) {
|
||||
var staticElement = nameNode.staticElement;
|
||||
if (staticElement != null) {
|
||||
name =
|
||||
'${staticElement.returnType.getDisplayString(withNullability: true)}.new';
|
||||
name = '${staticElement.returnType.getDisplayString()}.new';
|
||||
}
|
||||
}
|
||||
} else if (nameNode is MethodInvocation) {
|
||||
|
@ -3968,11 +3964,11 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
|||
var parent = nameNode.parent;
|
||||
if (parent is EnumConstantDeclaration) {
|
||||
var declaredElement = parent.declaredElement!;
|
||||
name = declaredElement.type.getDisplayString(withNullability: true);
|
||||
name = declaredElement.type.getDisplayString();
|
||||
}
|
||||
} else if (nameNode is EnumConstantDeclaration) {
|
||||
var declaredElement = nameNode.declaredElement!;
|
||||
name = declaredElement.type.getDisplayString(withNullability: true);
|
||||
name = declaredElement.type.getDisplayString();
|
||||
} else if (nameNode is Annotation) {
|
||||
var nameNodeName = nameNode.name;
|
||||
name = nameNodeName is PrefixedIdentifier
|
||||
|
|
|
@ -441,9 +441,7 @@ class InstanceMemberInferrer {
|
|||
if (conflict is CandidatesConflict) {
|
||||
conflictExplanation = conflict.candidates.map((candidate) {
|
||||
var className = candidate.enclosingElement.name;
|
||||
var typeStr = candidate.type.getDisplayString(
|
||||
withNullability: true,
|
||||
);
|
||||
var typeStr = candidate.type.getDisplayString();
|
||||
return '$className.${name.name} ($typeStr)';
|
||||
}).join(', ');
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ void main() {
|
|||
@reflectiveTest
|
||||
class RecordTypeTest extends AbstractTypeSystemTest {
|
||||
void check(DartType type, String expected) {
|
||||
expect(type.getDisplayString(withNullability: true), expected);
|
||||
expect(type.getDisplayString(), expected);
|
||||
}
|
||||
|
||||
void test_empty() {
|
||||
|
|
|
@ -299,7 +299,7 @@ class StaticTypeAnalyzer2TestShared extends PubPackageResolutionTest {
|
|||
|
||||
String typeParametersStr(List<TypeParameterElement> elements) {
|
||||
var elementsStr = elements.map((e) {
|
||||
return e.getDisplayString(withNullability: false);
|
||||
return e.getDisplayString();
|
||||
}).join(', ');
|
||||
return '[$elementsStr]';
|
||||
}
|
||||
|
|
|
@ -3007,7 +3007,7 @@ class B<T2, U2> {
|
|||
|
||||
var constructorMember = redirected.staticElement!;
|
||||
expect(
|
||||
constructorMember.getDisplayString(withNullability: false),
|
||||
constructorMember.getDisplayString(),
|
||||
'A<T2, U2> A.named()',
|
||||
);
|
||||
expect(redirected.name!.staticElement, constructorMember);
|
||||
|
@ -3043,7 +3043,7 @@ class B<T2, U2> {
|
|||
|
||||
expect(redirected.name, isNull);
|
||||
expect(
|
||||
redirected.staticElement!.getDisplayString(withNullability: false),
|
||||
redirected.staticElement!.getDisplayString(),
|
||||
'A<T2, U2> A()',
|
||||
);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class TryPromoteToTest extends AbstractTypeSystemTest {
|
|||
}
|
||||
|
||||
void check(TypeParameterTypeImpl type, String expected) {
|
||||
expect(type.getDisplayString(withNullability: true), expected);
|
||||
expect(type.getDisplayString(), expected);
|
||||
}
|
||||
|
||||
var T = typeParameter('T');
|
||||
|
|
|
@ -114,6 +114,6 @@ class ConstantsDataExtractor extends AstDataExtractor<String> {
|
|||
}
|
||||
|
||||
String _stringifyType(DartType type) {
|
||||
return type.getDisplayString(withNullability: true);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ class _InferredTypeArgumentsDataInterpreter
|
|||
if (i > 0) {
|
||||
sb.write(',');
|
||||
}
|
||||
sb.write(actualData[i].getDisplayString(withNullability: true));
|
||||
sb.write(actualData[i].getDisplayString());
|
||||
}
|
||||
sb.write('>');
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class _InferredVariableTypesDataInterpreter
|
|||
|
||||
@override
|
||||
String getText(DartType actualData, [String? indentation]) {
|
||||
return actualData.getDisplayString(withNullability: true);
|
||||
return actualData.getDisplayString();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -69,7 +69,7 @@ String supertypeToString(InterfaceType type) {
|
|||
var comma = '';
|
||||
for (var typeArgument in type.typeArguments) {
|
||||
sb.write(comma);
|
||||
sb.write(typeArgument.getDisplayString(withNullability: true));
|
||||
sb.write(typeArgument.getDisplayString());
|
||||
comma = ', ';
|
||||
}
|
||||
sb.write('>');
|
||||
|
@ -121,8 +121,7 @@ class _InheritanceDataExtractor extends AstDataExtractor<String> {
|
|||
|
||||
void registerMember(
|
||||
MemberId id, int offset, Object object, DartType type) {
|
||||
registerValue(uri, offset, id,
|
||||
type.getDisplayString(withNullability: true), object);
|
||||
registerValue(uri, offset, id, type.getDisplayString(), object);
|
||||
}
|
||||
|
||||
var interface = inheritance.getInterface(element);
|
||||
|
|
|
@ -92,7 +92,7 @@ class _TypePromotionDataInterpreter implements DataInterpreter<DartType> {
|
|||
|
||||
@override
|
||||
String getText(DartType actualData, [String? indentation]) {
|
||||
return actualData.getDisplayString(withNullability: true);
|
||||
return actualData.getDisplayString();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -111,6 +111,6 @@ mixin _AbstractClassHierarchyMixin on ElementsTypesMixin {
|
|||
String _interfaceString(InterfaceType interface) {
|
||||
return (interface as InterfaceTypeImpl)
|
||||
.withNullability(NullabilitySuffix.none)
|
||||
.getDisplayString(withNullability: true);
|
||||
.getDisplayString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,12 +28,13 @@ class ElementDisplayStringTest extends AbstractTypeSystemTest {
|
|||
],
|
||||
);
|
||||
|
||||
final singleLine = methodA.getDisplayString(withNullability: true);
|
||||
final singleLine = methodA.getDisplayString();
|
||||
expect(singleLine, '''
|
||||
String? longMethodName(String? aaa, [String? bbb = 'a', String? ccc])''');
|
||||
|
||||
final multiLine =
|
||||
methodA.getDisplayString(withNullability: true, multiline: true);
|
||||
final multiLine = methodA.getDisplayString(
|
||||
multiline: true,
|
||||
);
|
||||
expect(multiLine, '''
|
||||
String? longMethodName(
|
||||
String? aaa, [
|
||||
|
@ -64,12 +65,13 @@ String? longMethodName(
|
|||
],
|
||||
);
|
||||
|
||||
final singleLine = methodA.getDisplayString(withNullability: true);
|
||||
final singleLine = methodA.getDisplayString();
|
||||
expect(singleLine, '''
|
||||
String? longMethodName(String? aaa, [String? Function(String?, String?, String?) bbb, String? ccc])''');
|
||||
|
||||
final multiLine =
|
||||
methodA.getDisplayString(withNullability: true, multiline: true);
|
||||
final multiLine = methodA.getDisplayString(
|
||||
multiline: true,
|
||||
);
|
||||
expect(multiLine, '''
|
||||
String? longMethodName(
|
||||
String? aaa, [
|
||||
|
@ -84,7 +86,7 @@ String? longMethodName(
|
|||
..isGetter = true
|
||||
..returnType = stringNone;
|
||||
|
||||
expect(getterA.getDisplayString(withNullability: true), 'String get a');
|
||||
expect(getterA.getDisplayString(), 'String get a');
|
||||
}
|
||||
|
||||
void test_property_setter() {
|
||||
|
@ -97,7 +99,7 @@ String? longMethodName(
|
|||
];
|
||||
|
||||
expect(
|
||||
setterA.getDisplayString(withNullability: true),
|
||||
setterA.getDisplayString(),
|
||||
'set a(String value)',
|
||||
);
|
||||
}
|
||||
|
@ -112,11 +114,12 @@ String? longMethodName(
|
|||
],
|
||||
);
|
||||
|
||||
final singleLine = methodA.getDisplayString(withNullability: true);
|
||||
final singleLine = methodA.getDisplayString();
|
||||
expect(singleLine, 'String? m(String? a, [String? b])');
|
||||
|
||||
final multiLine =
|
||||
methodA.getDisplayString(withNullability: true, multiline: true);
|
||||
final multiLine = methodA.getDisplayString(
|
||||
multiline: true,
|
||||
);
|
||||
// The signature is short enough that it remains on one line even for
|
||||
// multiline: true.
|
||||
expect(multiLine, 'String? m(String? a, [String? b])');
|
||||
|
|
|
@ -945,7 +945,7 @@ enum B {B1, B2, B3}
|
|||
@reflectiveTest
|
||||
class FunctionTypeImplTest extends AbstractTypeSystemTest {
|
||||
void assertType(DartType type, String expected) {
|
||||
var typeStr = type.getDisplayString(withNullability: false);
|
||||
var typeStr = type.getDisplayString();
|
||||
expect(typeStr, expected);
|
||||
}
|
||||
|
||||
|
@ -1085,9 +1085,7 @@ class InterfaceTypeImplTest extends AbstractTypeSystemTest with StringTypes {
|
|||
void test_allSupertypes() {
|
||||
void check(InterfaceType type, List<String> expected) {
|
||||
var actual = type.allSupertypes.map((e) {
|
||||
return e.getDisplayString(
|
||||
withNullability: true,
|
||||
);
|
||||
return e.getDisplayString();
|
||||
}).toList()
|
||||
..sort();
|
||||
expect(actual, expected);
|
||||
|
@ -1900,7 +1898,7 @@ class TypeParameterTypeImplTest extends AbstractTypeSystemTest {
|
|||
) {
|
||||
var result = (type as TypeImpl).asInstanceOf(element);
|
||||
expect(
|
||||
result?.getDisplayString(withNullability: true),
|
||||
result?.getDisplayString(),
|
||||
expected,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,6 @@ class FactorTypeTest with FactorTypeTestMixin<DartType>, ElementsTypesMixin {
|
|||
|
||||
@override
|
||||
String typeString(covariant TypeImpl type) {
|
||||
return type.getDisplayString(withNullability: true);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ class FlattenTypeTest extends AbstractTypeSystemTest {
|
|||
void _check(DartType T, String expected) {
|
||||
final result = typeSystem.flatten(T);
|
||||
expect(
|
||||
result.getDisplayString(withNullability: true),
|
||||
result.getDisplayString(),
|
||||
expected,
|
||||
);
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ class FutureTypeTest extends AbstractTypeSystemTest {
|
|||
expect(expected, isNull);
|
||||
} else {
|
||||
expect(
|
||||
result.getDisplayString(withNullability: true),
|
||||
result.getDisplayString(),
|
||||
expected,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class FunctionTypeTest extends AbstractTypeSystemTest {
|
|||
typeParameters = isEmpty}) {
|
||||
// DartType properties
|
||||
expect(
|
||||
f.getDisplayString(withNullability: false),
|
||||
f.getDisplayString(),
|
||||
displayName,
|
||||
reason: 'displayName',
|
||||
);
|
||||
|
@ -64,13 +64,13 @@ class FunctionTypeTest extends AbstractTypeSystemTest {
|
|||
|
||||
DartType listOf(DartType elementType) => listElement.instantiate(
|
||||
typeArguments: [elementType],
|
||||
nullabilitySuffix: NullabilitySuffix.star,
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
);
|
||||
|
||||
DartType mapOf(DartType keyType, DartType valueType) =>
|
||||
mapElement.instantiate(
|
||||
typeArguments: [keyType, valueType],
|
||||
nullabilitySuffix: NullabilitySuffix.star,
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
);
|
||||
|
||||
test_equality_leftRequired_rightPositional() {
|
||||
|
@ -260,7 +260,7 @@ class FunctionTypeTest extends AbstractTypeSystemTest {
|
|||
typeFormals: const [],
|
||||
parameters: const [],
|
||||
returnType: dynamicType,
|
||||
nullabilitySuffix: NullabilitySuffix.star,
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
);
|
||||
basicChecks(f);
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ class FunctionTypeTest extends AbstractTypeSystemTest {
|
|||
typeFormals: [t],
|
||||
parameters: [x],
|
||||
returnType: typeParameterTypeNone(t),
|
||||
nullabilitySuffix: NullabilitySuffix.star,
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
);
|
||||
FunctionType instantiated = f.instantiate([objectType]);
|
||||
basicChecks(instantiated,
|
||||
|
@ -291,7 +291,7 @@ class FunctionTypeTest extends AbstractTypeSystemTest {
|
|||
typeFormals: [t],
|
||||
parameters: const [],
|
||||
returnType: dynamicType,
|
||||
nullabilitySuffix: NullabilitySuffix.star,
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
);
|
||||
expect(() => f.instantiate([]), throwsA(TypeMatcher<ArgumentError>()));
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ class FunctionTypeTest extends AbstractTypeSystemTest {
|
|||
typeFormals: const [],
|
||||
parameters: const [],
|
||||
returnType: dynamicType,
|
||||
nullabilitySuffix: NullabilitySuffix.star,
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
);
|
||||
expect(f.instantiate([]), same(f));
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ class FunctionTypeTest extends AbstractTypeSystemTest {
|
|||
typeFormals: const [],
|
||||
parameters: [p],
|
||||
returnType: dynamicType,
|
||||
nullabilitySuffix: NullabilitySuffix.star,
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
);
|
||||
basicChecks(f,
|
||||
displayName: 'dynamic Function({Object x})',
|
||||
|
@ -329,7 +329,7 @@ class FunctionTypeTest extends AbstractTypeSystemTest {
|
|||
typeFormals: const [],
|
||||
parameters: [p],
|
||||
returnType: dynamicType,
|
||||
nullabilitySuffix: NullabilitySuffix.star,
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
);
|
||||
basicChecks(f,
|
||||
displayName: 'dynamic Function(Object)',
|
||||
|
@ -347,7 +347,7 @@ class FunctionTypeTest extends AbstractTypeSystemTest {
|
|||
typeFormals: const [],
|
||||
parameters: [p],
|
||||
returnType: dynamicType,
|
||||
nullabilitySuffix: NullabilitySuffix.star,
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
);
|
||||
basicChecks(f,
|
||||
displayName: 'dynamic Function([Object])',
|
||||
|
@ -364,7 +364,7 @@ class FunctionTypeTest extends AbstractTypeSystemTest {
|
|||
typeFormals: const [],
|
||||
parameters: const [],
|
||||
returnType: objectType,
|
||||
nullabilitySuffix: NullabilitySuffix.star,
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
);
|
||||
basicChecks(f,
|
||||
displayName: 'Object Function()', returnType: same(objectType));
|
||||
|
@ -375,12 +375,12 @@ class FunctionTypeTest extends AbstractTypeSystemTest {
|
|||
FunctionType f = FunctionTypeImpl(
|
||||
typeFormals: [t],
|
||||
parameters: const [],
|
||||
returnType: typeParameterTypeStar(t),
|
||||
nullabilitySuffix: NullabilitySuffix.star,
|
||||
returnType: typeParameterTypeNone(t),
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
);
|
||||
basicChecks(f,
|
||||
displayName: 'T Function<T>()',
|
||||
returnType: typeParameterTypeStar(t),
|
||||
returnType: typeParameterTypeNone(t),
|
||||
typeFormals: [same(t)]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class FutureOrBaseTest extends AbstractTypeSystemTest {
|
|||
void _check(DartType T, String expected) {
|
||||
var result = typeSystem.futureOrBase(T);
|
||||
expect(
|
||||
result.getDisplayString(withNullability: true),
|
||||
result.getDisplayString(),
|
||||
expected,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ class FutureValueTypeTest extends AbstractTypeSystemTest {
|
|||
void _check(DartType T, String expected) {
|
||||
var result = typeSystem.futureValueType(T);
|
||||
expect(
|
||||
result.getDisplayString(withNullability: true),
|
||||
result.getDisplayString(),
|
||||
expected,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -589,17 +589,17 @@ class GenericFunctionInferenceTest extends AbstractTypeSystemTest {
|
|||
}
|
||||
|
||||
void _assertType(DartType type, String expected) {
|
||||
var typeStr = type.getDisplayString(withNullability: false);
|
||||
var typeStr = type.getDisplayString();
|
||||
expect(typeStr, expected);
|
||||
}
|
||||
|
||||
void _assertTypes(List<DartType> actual, List<DartType> expected) {
|
||||
var actualStr = actual.map((e) {
|
||||
return e.getDisplayString(withNullability: true);
|
||||
return e.getDisplayString();
|
||||
}).toList();
|
||||
|
||||
var expectedStr = expected.map((e) {
|
||||
return e.getDisplayString(withNullability: true);
|
||||
return e.getDisplayString();
|
||||
}).toList();
|
||||
|
||||
expect(actualStr, expectedStr);
|
||||
|
|
|
@ -2786,7 +2786,7 @@ class _InheritanceManager3Base extends PubPackageResolutionTest {
|
|||
var enclosingElement = element.enclosingElement;
|
||||
if (enclosingElement.name == 'Object') continue;
|
||||
|
||||
var typeStr = type.getDisplayString(withNullability: false);
|
||||
var typeStr = type.getDisplayString();
|
||||
lines.add('${enclosingElement.name}.${element.name}: $typeStr');
|
||||
}
|
||||
|
||||
|
|
|
@ -128,13 +128,13 @@ class GreatestClosureTest extends AbstractTypeSystemTest {
|
|||
}) {
|
||||
var greatestResult = typeSystem.greatestClosure(type, [T]);
|
||||
expect(
|
||||
greatestResult.getDisplayString(withNullability: true),
|
||||
greatestResult.getDisplayString(),
|
||||
greatest,
|
||||
);
|
||||
|
||||
var leastResult = typeSystem.leastClosure(type, [T]);
|
||||
expect(
|
||||
leastResult.getDisplayString(withNullability: true),
|
||||
leastResult.getDisplayString(),
|
||||
least,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -110,6 +110,6 @@ class ReplaceTopBottomTest extends AbstractTypeSystemTest {
|
|||
}
|
||||
|
||||
String _typeString(DartType type) {
|
||||
return type.getDisplayString(withNullability: true);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,6 +179,6 @@ class ResolveToBoundTest extends AbstractTypeSystemTest {
|
|||
}
|
||||
|
||||
String _typeString(DartType type) {
|
||||
return type.getDisplayString(withNullability: true);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,8 +104,7 @@ mixin StringTypes on AbstractTypeSystemTest {
|
|||
}
|
||||
|
||||
String typeString(DartType type) {
|
||||
return type.getDisplayString(withNullability: true) +
|
||||
_typeParametersStr(type);
|
||||
return type.getDisplayString() + _typeParametersStr(type);
|
||||
}
|
||||
|
||||
void _defineFunctionTypes() {
|
||||
|
@ -610,7 +609,7 @@ class _TypeParameterCollector extends TypeVisitor<void> {
|
|||
|
||||
var str = '';
|
||||
|
||||
var boundStr = bound.getDisplayString(withNullability: true);
|
||||
var boundStr = bound.getDisplayString();
|
||||
str += '${type.element.name} extends $boundStr';
|
||||
|
||||
typeParameters.add(str);
|
||||
|
|
|
@ -5830,7 +5830,7 @@ class SubtypingCompoundTest extends _SubtypingTestBase {
|
|||
}
|
||||
|
||||
static String _typeStr(DartType type) {
|
||||
return type.getDisplayString(withNullability: true);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -333,15 +333,15 @@ class TopMergeTest extends AbstractTypeSystemTest {
|
|||
void _check(DartType T, DartType S, DartType expected) {
|
||||
var result = typeSystem.topMerge(T, S);
|
||||
if (result != expected) {
|
||||
var expectedStr = expected.getDisplayString(withNullability: true);
|
||||
var resultStr = result.getDisplayString(withNullability: true);
|
||||
var expectedStr = expected.getDisplayString();
|
||||
var resultStr = result.getDisplayString();
|
||||
fail('Expected: $expectedStr, actual: $resultStr');
|
||||
}
|
||||
|
||||
result = typeSystem.topMerge(S, T);
|
||||
if (result != expected) {
|
||||
var expectedStr = expected.getDisplayString(withNullability: true);
|
||||
var resultStr = result.getDisplayString(withNullability: true);
|
||||
var expectedStr = expected.getDisplayString();
|
||||
var resultStr = result.getDisplayString();
|
||||
fail('Expected: $expectedStr, actual: $resultStr');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -581,7 +581,7 @@ class _Base extends AbstractTypeSystemTest {
|
|||
}
|
||||
|
||||
static String _typeStr(DartType type) {
|
||||
var result = type.getDisplayString(withNullability: true);
|
||||
var result = type.getDisplayString();
|
||||
|
||||
var alias = type.alias;
|
||||
if (alias != null) {
|
||||
|
|
|
@ -1340,8 +1340,8 @@ class TypeConstraintGathererTest extends AbstractTypeSystemTest {
|
|||
|
||||
var constraints = gatherer.computeConstraints();
|
||||
var constraintsStr = constraints.entries.map((e) {
|
||||
var lowerStr = e.value.lower.getDisplayString(withNullability: true);
|
||||
var upperStr = e.value.upper.getDisplayString(withNullability: true);
|
||||
var lowerStr = e.value.lower.getDisplayString();
|
||||
var upperStr = e.value.upper.getDisplayString();
|
||||
return '$lowerStr <: ${e.key.name} <: $upperStr';
|
||||
}).toList();
|
||||
|
||||
|
|
|
@ -946,7 +946,7 @@ class LowerBoundTest extends _BoundsTestBase {
|
|||
requiredParameter(type: T),
|
||||
]),
|
||||
);
|
||||
expect(result.getDisplayString(withNullability: true), str);
|
||||
expect(result.getDisplayString(), str);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -175,9 +175,7 @@ mixin ResolutionTest implements ResourceProviderMixin {
|
|||
}
|
||||
|
||||
void assertElementString(Element element, String expected) {
|
||||
var str = element.getDisplayString(
|
||||
withNullability: isNullSafetyEnabled,
|
||||
);
|
||||
var str = element.getDisplayString();
|
||||
expect(str, expected);
|
||||
}
|
||||
|
||||
|
@ -505,8 +503,7 @@ mixin ResolutionTest implements ResourceProviderMixin {
|
|||
|
||||
/// Return a textual representation of the [type] that is appropriate for
|
||||
/// tests.
|
||||
String typeString(DartType type) =>
|
||||
type.getDisplayString(withNullability: isNullSafetyEnabled);
|
||||
String typeString(DartType type) => type.getDisplayString();
|
||||
|
||||
Matcher _elementMatcher(Object? elementOrMatcher) {
|
||||
if (elementOrMatcher is Element) {
|
||||
|
|
|
@ -47915,13 +47915,13 @@ library
|
|||
}
|
||||
|
||||
void _assertTypeStr(DartType type, String expected) {
|
||||
var typeStr = type.getDisplayString(withNullability: true);
|
||||
var typeStr = type.getDisplayString();
|
||||
expect(typeStr, expected);
|
||||
}
|
||||
|
||||
void _assertTypeStrings(List<DartType> types, List<String> expected) {
|
||||
var typeStringList = types.map((e) {
|
||||
return e.getDisplayString(withNullability: true);
|
||||
return e.getDisplayString();
|
||||
}).toList();
|
||||
expect(typeStringList, expected);
|
||||
}
|
||||
|
|
|
@ -4186,7 +4186,7 @@ var x = f().g;
|
|||
var v = print;
|
||||
''');
|
||||
var v = _resultUnitElement.topLevelVariables[0];
|
||||
_assertTypeStr(v.type, 'void Function(Object)');
|
||||
_assertTypeStr(v.type, 'void Function(Object?)');
|
||||
}
|
||||
|
||||
test_inferredType_invokeMethod() async {
|
||||
|
@ -5941,7 +5941,7 @@ main() {
|
|||
}
|
||||
|
||||
void _assertTypeStr(DartType type, String expected) {
|
||||
var typeStr = type.getDisplayString(withNullability: false);
|
||||
var typeStr = type.getDisplayString();
|
||||
expect(typeStr, expected);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ class ElementPrinter {
|
|||
}
|
||||
|
||||
String _typeStr(DartType type) {
|
||||
return type.getDisplayString(withNullability: true);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
|
||||
void _writeAugmentationImportElement(AugmentationImportElement element) {
|
||||
|
|
|
@ -850,7 +850,7 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
|
|||
if (type is InterfaceType && alreadyAdded.add(type)) {
|
||||
builder.addSuggestion(
|
||||
LinkedEditSuggestionKind.TYPE,
|
||||
type.getDisplayString(withNullability: false),
|
||||
type.getDisplayString(),
|
||||
);
|
||||
_addSuperTypeProposals(builder, type.superclass, alreadyAdded);
|
||||
for (var interfaceType in type.interfaces) {
|
||||
|
@ -2189,7 +2189,7 @@ class DartLinkedEditBuilderImpl extends LinkedEditBuilderImpl
|
|||
}
|
||||
|
||||
String _getTypeSuggestionText(InterfaceType type) {
|
||||
return type.getDisplayString(withNullability: true);
|
||||
return type.getDisplayString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ class SuggestionBuilderImpl implements SuggestionBuilder {
|
|||
.toList();
|
||||
suggestion.parameterTypes =
|
||||
element.parameters.map((ParameterElement parameter) {
|
||||
return parameter.type.getDisplayString(withNullability: false);
|
||||
return parameter.type.getDisplayString();
|
||||
}).toList();
|
||||
|
||||
var requiredParameters = element.parameters
|
||||
|
@ -128,16 +128,16 @@ class SuggestionBuilderImpl implements SuggestionBuilder {
|
|||
if (element.kind == ElementKind.SETTER) {
|
||||
return null;
|
||||
} else {
|
||||
return element.returnType.getDisplayString(withNullability: false);
|
||||
return element.returnType.getDisplayString();
|
||||
}
|
||||
} else if (element is VariableElement) {
|
||||
var type = element.type;
|
||||
return type.getDisplayString(withNullability: false);
|
||||
return type.getDisplayString();
|
||||
} else if (element is TypeAliasElement) {
|
||||
var aliasedElement = element.aliasedElement;
|
||||
if (aliasedElement is GenericFunctionTypeElement) {
|
||||
var returnType = aliasedElement.returnType;
|
||||
return returnType.getDisplayString(withNullability: false);
|
||||
return returnType.getDisplayString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ class AnalyzerConverter {
|
|||
String? _getAliasedTypeString(analyzer.Element element) {
|
||||
if (element is analyzer.TypeAliasElement) {
|
||||
var aliasedType = element.aliasedType;
|
||||
return aliasedType.getDisplayString(withNullability: false);
|
||||
return aliasedType.getDisplayString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ class AnalyzerConverter {
|
|||
closeOptionalString = ']';
|
||||
}
|
||||
}
|
||||
parameter.appendToWithoutDelimiters(buffer, withNullability: false);
|
||||
parameter.appendToWithoutDelimiters(buffer);
|
||||
}
|
||||
buffer.write(closeOptionalString);
|
||||
buffer.write(')');
|
||||
|
@ -246,14 +246,14 @@ class AnalyzerConverter {
|
|||
if (element.kind == analyzer.ElementKind.SETTER) {
|
||||
return null;
|
||||
}
|
||||
return element.returnType.getDisplayString(withNullability: false);
|
||||
return element.returnType.getDisplayString();
|
||||
} else if (element is analyzer.VariableElement) {
|
||||
return element.type.getDisplayString(withNullability: false);
|
||||
return element.type.getDisplayString();
|
||||
} else if (element is analyzer.TypeAliasElement) {
|
||||
var aliasedType = element.aliasedType;
|
||||
if (aliasedType is FunctionType) {
|
||||
var returnType = aliasedType.returnType;
|
||||
return returnType.getDisplayString(withNullability: false);
|
||||
return returnType.getDisplayString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -2091,7 +2091,7 @@ _prefix0.A1 a1; _prefix0.A2 a2; _prefix1.B b;''');
|
|||
var classElement = await _getClassElement(path, name);
|
||||
return classElement.instantiate(
|
||||
typeArguments: typeArguments,
|
||||
nullabilitySuffix: NullabilitySuffix.star,
|
||||
nullabilitySuffix: NullabilitySuffix.none,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -977,12 +977,12 @@ class _Base extends AbstractContextTest {
|
|||
|
||||
static String _executableStr(ExecutableElement element) {
|
||||
var executableStr = _executableNameStr(element);
|
||||
var typeStr = element.type.getDisplayString(withNullability: false);
|
||||
var typeStr = element.type.getDisplayString();
|
||||
return '$executableStr: $typeStr';
|
||||
}
|
||||
|
||||
static String _parameterStr(ParameterElement element) {
|
||||
var typeStr = element.type.getDisplayString(withNullability: false);
|
||||
var typeStr = element.type.getDisplayString();
|
||||
return '${element.name}: $typeStr';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ class A {
|
|||
expect(location.startLine, 2);
|
||||
expect(location.startColumn, 11);
|
||||
}
|
||||
expect(element.parameters, '(int a, [String b])');
|
||||
expect(element.parameters, '(int a, [String? b])');
|
||||
expect(element.returnType, 'A');
|
||||
expect(element.flags, plugin.Element.FLAG_CONST);
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ class A {
|
|||
expect(location.startLine, 2);
|
||||
expect(location.startColumn, 23);
|
||||
}
|
||||
expect(element.parameters, '(int a, {String b, int c})');
|
||||
expect(element.parameters, '(int a, {String? b, int? c})');
|
||||
expect(element.returnType, 'List<String>');
|
||||
expect(element.flags, plugin.Element.FLAG_STATIC);
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ class _Visitor extends SimpleAstVisitor<void> {
|
|||
type ??= variable.initializer?.staticType;
|
||||
|
||||
if (type != null) {
|
||||
types.add(type.getDisplayString(withNullability: true));
|
||||
types.add(type.getDisplayString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,9 +77,7 @@ class _Visitor extends SimpleAstVisitor<void> {
|
|||
} else {
|
||||
rule.reportLint(node,
|
||||
errorCode: AvoidCatchingErrors.subclassCode,
|
||||
arguments: [
|
||||
exceptionType!.getDisplayString(withNullability: false)
|
||||
]);
|
||||
arguments: [exceptionType!.getDisplayString()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -302,16 +302,16 @@ class _Visitor extends SimpleAstVisitor<void> {
|
|||
collectionType.typeArguments[methodDefinition.typeArgumentIndex];
|
||||
if (typesAreUnrelated(typeSystem, argumentType, typeArgument)) {
|
||||
rule.reportLint(argument, arguments: [
|
||||
argumentType.getDisplayString(withNullability: true),
|
||||
typeArgument.getDisplayString(withNullability: true),
|
||||
argumentType.getDisplayString(),
|
||||
typeArgument.getDisplayString(),
|
||||
]);
|
||||
}
|
||||
|
||||
case _ExpectedArgumentKind.assignableToCollection:
|
||||
if (!typeSystem.isAssignableTo(argumentType, collectionType)) {
|
||||
rule.reportLint(argument, arguments: [
|
||||
argumentType.getDisplayString(withNullability: true),
|
||||
collectionType.getDisplayString(withNullability: true),
|
||||
argumentType.getDisplayString(),
|
||||
collectionType.getDisplayString(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -321,8 +321,8 @@ class _Visitor extends SimpleAstVisitor<void> {
|
|||
if (iterableType != null &&
|
||||
!typeSystem.isAssignableTo(argumentType, iterableType)) {
|
||||
rule.reportLint(argument, arguments: [
|
||||
argumentType.getDisplayString(withNullability: true),
|
||||
iterableType.getDisplayString(withNullability: true),
|
||||
argumentType.getDisplayString(),
|
||||
iterableType.getDisplayString(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,8 +190,8 @@ class _Visitor extends SimpleAstVisitor<void> {
|
|||
node.operator,
|
||||
errorCode: UnrelatedTypeEqualityChecks.expressionCode,
|
||||
arguments: [
|
||||
rightType.getDisplayString(withNullability: true),
|
||||
leftType.getDisplayString(withNullability: true),
|
||||
rightType.getDisplayString(),
|
||||
leftType.getDisplayString(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -209,8 +209,8 @@ class _Visitor extends SimpleAstVisitor<void> {
|
|||
node,
|
||||
errorCode: UnrelatedTypeEqualityChecks.patternCode,
|
||||
arguments: [
|
||||
operandType.getDisplayString(withNullability: true),
|
||||
valueType.getDisplayString(withNullability: true),
|
||||
operandType.getDisplayString(),
|
||||
valueType.getDisplayString(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue