Skip to content

Commit 0b40a46

Browse files
stereotype441commit-bot@chromium.org
authored andcommitted
Eliminate uses of old AST node types from pkg/analyzer/lib/src/summary
Change-Id: Ida907040d0461d9ae723421eeac71f4e19a8d4b2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95284 Commit-Queue: Paul Berry <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 37fa71d commit 0b40a46

File tree

4 files changed

+33
-63
lines changed

4 files changed

+33
-63
lines changed

pkg/analyzer/lib/src/generated/resolver.dart

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8910,15 +8910,20 @@ class _LeafElements {
89108910
/// Return `true` if the given collection [element] does not contain any
89118911
/// synthetic tokens.
89128912
bool _isComplete(CollectionElement element) {
8913-
Token token = element.beginToken;
8914-
int endOffset = element.endToken.offset;
8915-
while (token != null && token.offset <= endOffset) {
8916-
if (token.isSynthetic) {
8917-
return false;
8918-
}
8919-
token = token.next;
8920-
}
8913+
// TODO(paulberry,brianwilkerson): the code below doesn't work because it
8914+
// assumes access to token offsets, which aren't available when working with
8915+
// expressions resynthesized from summaries. For now we just assume the
8916+
// collection element is complete.
89218917
return true;
8918+
// Token token = element.beginToken;
8919+
// int endOffset = element.endToken.offset;
8920+
// while (token != null && token.offset <= endOffset) {
8921+
// if (token.isSynthetic) {
8922+
// return false;
8923+
// }
8924+
// token = token.next;
8925+
// }
8926+
// return true;
89228927
}
89238928
}
89248929

pkg/analyzer/lib/src/summary/expr_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ class ExprBuilder {
865865
int count = _uc.ints[intPtr++];
866866
List<CollectionElement> elements = <CollectionElement>[];
867867
for (int i = 0; i < count; i++) {
868-
elements.add(_popCollectionElement());
868+
elements.insert(0, _popCollectionElement());
869869
}
870870
DartType staticType;
871871
if (typeArguments != null && typeArguments.arguments.length == 2) {

pkg/analyzer/lib/src/summary/summarize_const_expr.dart

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,6 @@ abstract class AbstractConstExprSerializer {
344344
typeName.typeArguments != null);
345345
} else if (expr is ListLiteral) {
346346
_serializeListLiteral(expr);
347-
// ignore: deprecated_member_use_from_same_package
348-
} else if (expr is MapLiteral) {
349-
// ignore: deprecated_member_use_from_same_package
350-
_serializeMapLiteral(expr);
351-
// ignore: deprecated_member_use_from_same_package
352-
} else if (expr is SetLiteral) {
353-
// ignore: deprecated_member_use_from_same_package
354-
_serializeSetLiteral(expr);
355347
} else if (expr is SetOrMapLiteral) {
356348
_serializeSetOrMapLiteral(expr);
357349
} else if (expr is MethodInvocation) {
@@ -573,27 +565,6 @@ abstract class AbstractConstExprSerializer {
573565
}
574566
}
575567

576-
@deprecated
577-
void _serializeMapLiteral(MapLiteral expr) {
578-
if (forConst || expr.typeArguments == null) {
579-
for (MapLiteralEntry entry in expr.entries) {
580-
_serialize(entry.key);
581-
_serialize(entry.value);
582-
}
583-
ints.add(expr.entries.length);
584-
} else {
585-
ints.add(0);
586-
}
587-
if (expr.typeArguments != null &&
588-
expr.typeArguments.arguments.length == 2) {
589-
references.add(serializeType(expr.typeArguments.arguments[0]));
590-
references.add(serializeType(expr.typeArguments.arguments[1]));
591-
operations.add(UnlinkedExprOperation.makeTypedMap);
592-
} else {
593-
operations.add(UnlinkedExprOperation.makeUntypedMap);
594-
}
595-
}
596-
597568
void _serializeMethodInvocation(MethodInvocation invocation) {
598569
Expression target = invocation.target;
599570
SimpleIdentifier methodName = invocation.methodName;
@@ -673,24 +644,6 @@ abstract class AbstractConstExprSerializer {
673644
}
674645
}
675646

676-
@deprecated
677-
void _serializeSetLiteral(SetLiteral expr) {
678-
if (forConst || expr.typeArguments == null) {
679-
List<Expression> elements = expr.elements;
680-
elements.forEach(_serialize);
681-
ints.add(elements.length);
682-
} else {
683-
ints.add(0);
684-
}
685-
if (expr.typeArguments != null &&
686-
expr.typeArguments.arguments.length == 1) {
687-
references.add(serializeType(expr.typeArguments.arguments[0]));
688-
operations.add(UnlinkedExprOperation.makeTypedSet);
689-
} else {
690-
operations.add(UnlinkedExprOperation.makeUntypedSet);
691-
}
692-
}
693-
694647
void _serializeSetOrMapLiteral(SetOrMapLiteral expr) {
695648
if (forConst || expr.typeArguments == null) {
696649
for (CollectionElement element in expr.elements2) {

pkg/analyzer/test/src/summary/summary_common.dart

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,11 +2884,14 @@ const int v = p.a.length;
28842884
operators: [
28852885
UnlinkedExprOperation.pushInt,
28862886
UnlinkedExprOperation.pushString,
2887+
UnlinkedExprOperation.makeMapLiteralEntry,
28872888
UnlinkedExprOperation.pushInt,
28882889
UnlinkedExprOperation.pushString,
2890+
UnlinkedExprOperation.makeMapLiteralEntry,
28892891
UnlinkedExprOperation.pushInt,
28902892
UnlinkedExprOperation.pushString,
2891-
UnlinkedExprOperation.makeTypedMap
2893+
UnlinkedExprOperation.makeMapLiteralEntry,
2894+
UnlinkedExprOperation.makeTypedMap2
28922895
],
28932896
ints: [
28942897
11,
@@ -2917,11 +2920,14 @@ const int v = p.a.length;
29172920
operators: [
29182921
UnlinkedExprOperation.pushInt,
29192922
UnlinkedExprOperation.pushString,
2923+
UnlinkedExprOperation.makeMapLiteralEntry,
29202924
UnlinkedExprOperation.pushInt,
29212925
UnlinkedExprOperation.pushString,
2926+
UnlinkedExprOperation.makeMapLiteralEntry,
29222927
UnlinkedExprOperation.pushInt,
29232928
UnlinkedExprOperation.pushString,
2924-
UnlinkedExprOperation.makeTypedMap
2929+
UnlinkedExprOperation.makeMapLiteralEntry,
2930+
UnlinkedExprOperation.makeTypedMap2
29252931
],
29262932
ints: [
29272933
11,
@@ -3078,11 +3084,14 @@ const int v = p.a.length;
30783084
operators: [
30793085
UnlinkedExprOperation.pushInt,
30803086
UnlinkedExprOperation.pushString,
3087+
UnlinkedExprOperation.makeMapLiteralEntry,
30813088
UnlinkedExprOperation.pushInt,
30823089
UnlinkedExprOperation.pushString,
3090+
UnlinkedExprOperation.makeMapLiteralEntry,
30833091
UnlinkedExprOperation.pushInt,
30843092
UnlinkedExprOperation.pushString,
3085-
UnlinkedExprOperation.makeUntypedMap
3093+
UnlinkedExprOperation.makeMapLiteralEntry,
3094+
UnlinkedExprOperation.makeUntypedSetOrMap
30863095
],
30873096
ints: [
30883097
11,
@@ -3108,7 +3117,7 @@ const int v = p.a.length;
31083117
UnlinkedExprOperation.pushInt,
31093118
UnlinkedExprOperation.pushInt,
31103119
UnlinkedExprOperation.pushInt,
3111-
UnlinkedExprOperation.makeUntypedSet
3120+
UnlinkedExprOperation.makeUntypedSetOrMap
31123121
],
31133122
ints: [11, 22, 33, 3],
31143123
);
@@ -7383,7 +7392,7 @@ final v = f<int, String>();
73837392
'var v = <int, String>{11: "aaa", 22: "bbb", 33: "ccc"};');
73847393
assertUnlinkedConst(variable.initializer.bodyExpr,
73857394
'<int, String>{11: "aaa", 22: "bbb", 33: "ccc"}',
7386-
operators: [UnlinkedExprOperation.makeTypedMap],
7395+
operators: [UnlinkedExprOperation.makeTypedMap2],
73877396
ints: [0],
73887397
referenceValidators: [
73897398
(EntityRef r) => checkTypeRef(r, 'dart:core', 'int',
@@ -7429,11 +7438,14 @@ final v = f<int, String>();
74297438
operators: [
74307439
UnlinkedExprOperation.pushInt,
74317440
UnlinkedExprOperation.pushString,
7441+
UnlinkedExprOperation.makeMapLiteralEntry,
74327442
UnlinkedExprOperation.pushInt,
74337443
UnlinkedExprOperation.pushString,
7444+
UnlinkedExprOperation.makeMapLiteralEntry,
74347445
UnlinkedExprOperation.pushInt,
74357446
UnlinkedExprOperation.pushString,
7436-
UnlinkedExprOperation.makeUntypedMap
7447+
UnlinkedExprOperation.makeMapLiteralEntry,
7448+
UnlinkedExprOperation.makeUntypedSetOrMap
74377449
],
74387450
ints: [11, 22, 33, 3],
74397451
strings: ['aaa', 'bbb', 'ccc'],
@@ -7448,7 +7460,7 @@ final v = f<int, String>();
74487460
UnlinkedExprOperation.pushInt,
74497461
UnlinkedExprOperation.pushInt,
74507462
UnlinkedExprOperation.pushInt,
7451-
UnlinkedExprOperation.makeUntypedSet
7463+
UnlinkedExprOperation.makeUntypedSetOrMap
74527464
],
74537465
ints: [11, 22, 33, 3],
74547466
forTypeInferenceOnly: true);

0 commit comments

Comments
 (0)