Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 34893fa

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Use DartType.getDisplayString() instead of toString().
Change-Id: I982a4fff312593e6788afcbc9200a83793fefb97 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134464 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
1 parent 738ad28 commit 34893fa

4 files changed

Lines changed: 9 additions & 6 deletions

File tree

pkg/analysis_server/lib/src/protocol_server.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ String getReturnTypeString(engine.Element element) {
6262
if (element.kind == engine.ElementKind.SETTER) {
6363
return null;
6464
} else {
65-
return element.returnType?.toString();
65+
return element.returnType?.getDisplayString(withNullability: false);
6666
}
6767
} else if (element is engine.VariableElement) {
6868
engine.DartType type = element.type;
6969
return type != null
7070
? type.getDisplayString(withNullability: false)
7171
: 'dynamic';
7272
} else if (element is engine.FunctionTypeAliasElement) {
73-
return element.function.returnType.toString();
73+
var returnType = element.function.returnType;
74+
return returnType.getDisplayString(withNullability: false);
7475
} else {
7576
return null;
7677
}

pkg/analysis_server/lib/src/search/type_hierarchy.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ class TypeHierarchyComputer {
119119
{
120120
String displayName;
121121
if (typeArguments != null && typeArguments.isNotEmpty) {
122-
displayName =
123-
classElement.displayName + '<' + typeArguments.join(', ') + '>';
122+
var typeArgumentsStr = typeArguments
123+
.map((type) => type.getDisplayString(withNullability: false))
124+
.join(', ');
125+
displayName = classElement.displayName + '<' + typeArgumentsStr + '>';
124126
}
125127
ExecutableElement memberElement = _findMemberElement(classElement);
126128
item = TypeHierarchyItem(convertElement(classElement),

pkg/analysis_server/lib/src/services/completion/dart/utilities.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ String nameForType(SimpleIdentifier identifier, TypeAnnotation declaredType) {
332332
if (type == null) {
333333
return DYNAMIC;
334334
}
335-
return type.toString();
335+
return type.getDisplayString(withNullability: false);
336336
}
337337

338338
/// TODO(pq): fix to use getDefaultStringParameterValue()

pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ class FixProcessor extends BaseProcessor {
14261426
changeBuilder,
14271427
DartFixKind.CHANGE_TYPE_ANNOTATION,
14281428
args: [
1429-
typeNode.type,
1429+
typeNode.type.getDisplayString(withNullability: false),
14301430
newType.getDisplayString(withNullability: false),
14311431
],
14321432
);

0 commit comments

Comments
 (0)