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

Side by Side Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 1619913005: Rename TypeRef to EntityRef. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.src.summary.summary_common; 5 library analyzer.test.src.summary.summary_common;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 new Scanner(source, reader, AnalysisErrorListener.NULL_LISTENER); 103 new Scanner(source, reader, AnalysisErrorListener.NULL_LISTENER);
104 Parser parser = new Parser(source, AnalysisErrorListener.NULL_LISTENER); 104 Parser parser = new Parser(source, AnalysisErrorListener.NULL_LISTENER);
105 parser.parseGenericMethods = true; 105 parser.parseGenericMethods = true;
106 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); 106 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize());
107 UnlinkedPublicNamespace namespace = new UnlinkedPublicNamespace.fromBuffer( 107 UnlinkedPublicNamespace namespace = new UnlinkedPublicNamespace.fromBuffer(
108 public_namespace.computePublicNamespace(unit).toBuffer()); 108 public_namespace.computePublicNamespace(unit).toBuffer());
109 return namespace; 109 return namespace;
110 } 110 }
111 111
112 /** 112 /**
113 * Type of a function that validates an [TypeRef]. 113 * Type of a function that validates an [EntityRef].
114 */ 114 */
115 typedef void _TypeRefValidator(TypeRef unlinkedTypeRef); 115 typedef void _TypeRefValidator(EntityRef unlinkedTypeRef);
scheglov 2016/01/21 22:40:42 Rename the type and parameter?
Paul Berry 2016/01/21 22:53:48 Done.
116 116
117 /** 117 /**
118 * Base class containing most summary tests. This allows summary tests to be 118 * Base class containing most summary tests. This allows summary tests to be
119 * re-used to exercise all the different ways in which summaries can be 119 * re-used to exercise all the different ways in which summaries can be
120 * generated (e.g. direct from the AST, from the element model, from a 120 * generated (e.g. direct from the AST, from the element model, from a
121 * "relinking" process, etc.) 121 * "relinking" process, etc.)
122 */ 122 */
123 abstract class SummaryTest { 123 abstract class SummaryTest {
124 /** 124 /**
125 * A test will set this to `true` if it contains `import`, `export`, or 125 * A test will set this to `true` if it contains `import`, `export`, or
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 String expectedCommentText = 228 String expectedCommentText =
229 text.substring(commentStart, commentEnd).replaceAll('\r\n', '\n'); 229 text.substring(commentStart, commentEnd).replaceAll('\r\n', '\n');
230 expect(documentationComment.text, expectedCommentText); 230 expect(documentationComment.text, expectedCommentText);
231 expect(documentationComment.offset, commentStart); 231 expect(documentationComment.offset, commentStart);
232 expect(documentationComment.length, commentEnd - commentStart); 232 expect(documentationComment.length, commentEnd - commentStart);
233 } 233 }
234 234
235 /** 235 /**
236 * Verify that the given [typeRef] represents the type `dynamic`. 236 * Verify that the given [typeRef] represents the type `dynamic`.
237 */ 237 */
238 void checkDynamicTypeRef(TypeRef typeRef) { 238 void checkDynamicTypeRef(EntityRef typeRef) {
239 checkTypeRef(typeRef, null, null, null); 239 checkTypeRef(typeRef, null, null, null);
240 } 240 }
241 241
242 /** 242 /**
243 * Verify that the given [exportName] represents a reference to an entity 243 * Verify that the given [exportName] represents a reference to an entity
244 * declared in a file reachable via [absoluteUri] and [relativeUri], having 244 * declared in a file reachable via [absoluteUri] and [relativeUri], having
245 * name [expectedName]. [expectedKind] is the kind of object referenced. 245 * name [expectedName]. [expectedKind] is the kind of object referenced.
246 * [expectedTargetUnit] is the index of the compilation unit in which the 246 * [expectedTargetUnit] is the index of the compilation unit in which the
247 * target of the [exportName] is expected to appear; if not specified it is 247 * target of the [exportName] is expected to appear; if not specified it is
248 * assumed to be the defining compilation unit. 248 * assumed to be the defining compilation unit.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 * [expectedName]. If [allowTypeParameters] is true, allow the type 316 * [expectedName]. If [allowTypeParameters] is true, allow the type
317 * reference to supply type parameters. [expectedKind] is the kind of object 317 * reference to supply type parameters. [expectedKind] is the kind of object
318 * referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer to the 318 * referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer to the
319 * compilation unit within which the [typeRef] appears; if not specified they 319 * compilation unit within which the [typeRef] appears; if not specified they
320 * are assumed to refer to the defining compilation unit. 320 * are assumed to refer to the defining compilation unit.
321 * [expectedTargetUnit] is the index of the compilation unit in which the 321 * [expectedTargetUnit] is the index of the compilation unit in which the
322 * target of the [typeRef] is expected to appear; if not specified it is 322 * target of the [typeRef] is expected to appear; if not specified it is
323 * assumed to be the defining compilation unit. [numTypeParameters] is the 323 * assumed to be the defining compilation unit. [numTypeParameters] is the
324 * number of type parameters of the thing being referred to. 324 * number of type parameters of the thing being referred to.
325 */ 325 */
326 void checkLinkedTypeRef(TypeRef typeRef, String absoluteUri, 326 void checkLinkedTypeRef(EntityRef typeRef, String absoluteUri,
327 String relativeUri, String expectedName, 327 String relativeUri, String expectedName,
328 {bool allowTypeParameters: false, 328 {bool allowTypeParameters: false,
329 ReferenceKind expectedKind: ReferenceKind.classOrEnum, 329 ReferenceKind expectedKind: ReferenceKind.classOrEnum,
330 int expectedTargetUnit: 0, 330 int expectedTargetUnit: 0,
331 LinkedUnit linkedSourceUnit, 331 LinkedUnit linkedSourceUnit,
332 UnlinkedUnit unlinkedSourceUnit, 332 UnlinkedUnit unlinkedSourceUnit,
333 int numTypeParameters: 0}) { 333 int numTypeParameters: 0}) {
334 linkedSourceUnit ??= definingUnit; 334 linkedSourceUnit ??= definingUnit;
335 expect(typeRef, isNotNull, 335 expect(typeRef, isNotNull,
336 reason: 'No entry in linkedSourceUnit.types matching slotId'); 336 reason: 'No entry in linkedSourceUnit.types matching slotId');
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 expectedTargetUnit: expectedTargetUnit, 388 expectedTargetUnit: expectedTargetUnit,
389 linkedSourceUnit: linkedSourceUnit, 389 linkedSourceUnit: linkedSourceUnit,
390 unlinkedSourceUnit: unlinkedSourceUnit, 390 unlinkedSourceUnit: unlinkedSourceUnit,
391 numTypeParameters: numTypeParameters); 391 numTypeParameters: numTypeParameters);
392 } 392 }
393 393
394 /** 394 /**
395 * Verify that the given [typeRef] represents a reference to a type parameter 395 * Verify that the given [typeRef] represents a reference to a type parameter
396 * having the given [deBruijnIndex]. 396 * having the given [deBruijnIndex].
397 */ 397 */
398 void checkParamTypeRef(TypeRef typeRef, int deBruijnIndex) { 398 void checkParamTypeRef(EntityRef typeRef, int deBruijnIndex) {
399 expect(typeRef, new isInstanceOf<TypeRef>()); 399 expect(typeRef, new isInstanceOf<EntityRef>());
400 expect(typeRef.reference, 0); 400 expect(typeRef.reference, 0);
401 expect(typeRef.typeArguments, isEmpty); 401 expect(typeRef.typeArguments, isEmpty);
402 expect(typeRef.paramReference, deBruijnIndex); 402 expect(typeRef.paramReference, deBruijnIndex);
403 } 403 }
404 404
405 /** 405 /**
406 * Verify that [prefixReference] is a valid reference to a prefix having the 406 * Verify that [prefixReference] is a valid reference to a prefix having the
407 * given [name]. 407 * given [name].
408 */ 408 */
409 void checkPrefix(int prefixReference, String name) { 409 void checkPrefix(int prefixReference, String name) {
(...skipping 12 matching lines...) Expand all
422 * reached via the given prefix. If [allowTypeParameters] is true, allow the 422 * reached via the given prefix. If [allowTypeParameters] is true, allow the
423 * type reference to supply type parameters. [expectedKind] is the kind of 423 * type reference to supply type parameters. [expectedKind] is the kind of
424 * object referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer 424 * object referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer
425 * to the compilation unit within which the [typeRef] appears; if not 425 * to the compilation unit within which the [typeRef] appears; if not
426 * specified they are assumed to refer to the defining compilation unit. 426 * specified they are assumed to refer to the defining compilation unit.
427 * [expectedTargetUnit] is the index of the compilation unit in which the 427 * [expectedTargetUnit] is the index of the compilation unit in which the
428 * target of the [typeRef] is expected to appear; if not specified it is 428 * target of the [typeRef] is expected to appear; if not specified it is
429 * assumed to be the defining compilation unit. [numTypeParameters] is the 429 * assumed to be the defining compilation unit. [numTypeParameters] is the
430 * number of type parameters of the thing being referred to. 430 * number of type parameters of the thing being referred to.
431 */ 431 */
432 void checkTypeRef(TypeRef typeRef, String absoluteUri, String relativeUri, 432 void checkTypeRef(EntityRef typeRef, String absoluteUri, String relativeUri,
433 String expectedName, 433 String expectedName,
434 {String expectedPrefix, 434 {String expectedPrefix,
435 bool allowTypeParameters: false, 435 bool allowTypeParameters: false,
436 ReferenceKind expectedKind: ReferenceKind.classOrEnum, 436 ReferenceKind expectedKind: ReferenceKind.classOrEnum,
437 int expectedTargetUnit: 0, 437 int expectedTargetUnit: 0,
438 LinkedUnit linkedSourceUnit, 438 LinkedUnit linkedSourceUnit,
439 UnlinkedUnit unlinkedSourceUnit, 439 UnlinkedUnit unlinkedSourceUnit,
440 int numTypeParameters: 0}) { 440 int numTypeParameters: 0}) {
441 linkedSourceUnit ??= definingUnit; 441 linkedSourceUnit ??= definingUnit;
442 expect(typeRef, new isInstanceOf<TypeRef>()); 442 expect(typeRef, new isInstanceOf<EntityRef>());
443 expect(typeRef.paramReference, 0); 443 expect(typeRef.paramReference, 0);
444 int index = typeRef.reference; 444 int index = typeRef.reference;
445 if (!allowTypeParameters) { 445 if (!allowTypeParameters) {
446 expect(typeRef.typeArguments, isEmpty); 446 expect(typeRef.typeArguments, isEmpty);
447 } 447 }
448 UnlinkedReference reference = checkTypeRefCommonElements( 448 UnlinkedReference reference = checkTypeRefCommonElements(
449 index, 449 index,
450 absoluteUri, 450 absoluteUri,
451 relativeUri, 451 relativeUri,
452 expectedName, 452 expectedName,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 expect(referenceResolution.unit, expectedTargetUnit); 530 expect(referenceResolution.unit, expectedTargetUnit);
531 expect(referenceResolution.numTypeParameters, numTypeParameters); 531 expect(referenceResolution.numTypeParameters, numTypeParameters);
532 return reference; 532 return reference;
533 } 533 }
534 534
535 /** 535 /**
536 * Verify that the given [typeRef] represents a reference to an unresolved 536 * Verify that the given [typeRef] represents a reference to an unresolved
537 * type. 537 * type.
538 */ 538 */
539 void checkUnresolvedTypeRef( 539 void checkUnresolvedTypeRef(
540 TypeRef typeRef, String expectedPrefix, String expectedName, 540 EntityRef typeRef, String expectedPrefix, String expectedName,
541 {LinkedUnit linkedSourceUnit, UnlinkedUnit unlinkedSourceUnit}) { 541 {LinkedUnit linkedSourceUnit, UnlinkedUnit unlinkedSourceUnit}) {
542 // When serializing from the element model, unresolved type refs lose their 542 // When serializing from the element model, unresolved type refs lose their
543 // name. 543 // name.
544 checkTypeRef(typeRef, null, null, checkAstDerivedData ? expectedName : null, 544 checkTypeRef(typeRef, null, null, checkAstDerivedData ? expectedName : null,
545 expectedPrefix: expectedPrefix, 545 expectedPrefix: expectedPrefix,
546 expectedKind: ReferenceKind.unresolved, 546 expectedKind: ReferenceKind.unresolved,
547 linkedSourceUnit: linkedSourceUnit, 547 linkedSourceUnit: linkedSourceUnit,
548 unlinkedSourceUnit: unlinkedSourceUnit); 548 unlinkedSourceUnit: unlinkedSourceUnit);
549 } 549 }
550 550
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 } 674 }
675 if (result == null && failIfAbsent) { 675 if (result == null && failIfAbsent) {
676 fail('Variable $variableName not found in serialized output'); 676 fail('Variable $variableName not found in serialized output');
677 } 677 }
678 return result; 678 return result;
679 } 679 }
680 680
681 /** 681 /**
682 * Find the entry in [linkedSourceUnit.types] matching [slotId]. 682 * Find the entry in [linkedSourceUnit.types] matching [slotId].
683 */ 683 */
684 TypeRef getTypeRefForSlot(int slotId, {LinkedUnit linkedSourceUnit}) { 684 EntityRef getTypeRefForSlot(int slotId, {LinkedUnit linkedSourceUnit}) {
685 linkedSourceUnit ??= definingUnit; 685 linkedSourceUnit ??= definingUnit;
686 for (TypeRef typeRef in linkedSourceUnit.types) { 686 for (EntityRef typeRef in linkedSourceUnit.types) {
687 if (typeRef.slot == slotId) { 687 if (typeRef.slot == slotId) {
688 return typeRef; 688 return typeRef;
689 } 689 }
690 } 690 }
691 return null; 691 return null;
692 } 692 }
693 693
694 /** 694 /**
695 * Serialize the given library [text] and return the summary of the class 695 * Serialize the given library [text] and return the summary of the class
696 * with the given [className]. 696 * with the given [className].
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 * with the given [typedefName]. 743 * with the given [typedefName].
744 */ 744 */
745 UnlinkedTypedef serializeTypedefText(String text, 745 UnlinkedTypedef serializeTypedefText(String text,
746 [String typedefName = 'F']) { 746 [String typedefName = 'F']) {
747 serializeLibraryText(text); 747 serializeLibraryText(text);
748 return findTypedef(typedefName, failIfAbsent: true); 748 return findTypedef(typedefName, failIfAbsent: true);
749 } 749 }
750 750
751 /** 751 /**
752 * Serialize a type declaration using the given [text] as a type name, and 752 * Serialize a type declaration using the given [text] as a type name, and
753 * return a summary of the corresponding [TypeRef]. If the type 753 * return a summary of the corresponding [EntityRef]. If the type
754 * declaration needs to refer to types that are not available in core, those 754 * declaration needs to refer to types that are not available in core, those
755 * types may be declared in [otherDeclarations]. 755 * types may be declared in [otherDeclarations].
756 */ 756 */
757 TypeRef serializeTypeText(String text, 757 EntityRef serializeTypeText(String text,
758 {String otherDeclarations: '', bool allowErrors: false}) { 758 {String otherDeclarations: '', bool allowErrors: false}) {
759 return serializeVariableText('$otherDeclarations\n$text v;', 759 return serializeVariableText('$otherDeclarations\n$text v;',
760 allowErrors: allowErrors) 760 allowErrors: allowErrors)
761 .type; 761 .type;
762 } 762 }
763 763
764 /** 764 /**
765 * Serialize the given library [text] and return the summary of the variable 765 * Serialize the given library [text] and return the summary of the variable
766 * with the given [variableName]. 766 * with the given [variableName].
767 */ 767 */
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 expect(cls.executables, isEmpty); 971 expect(cls.executables, isEmpty);
972 } 972 }
973 973
974 test_class_alias_private() { 974 test_class_alias_private() {
975 serializeClassText('class _C = _D with _E; class _D {} class _E {}', 975 serializeClassText('class _C = _D with _E; class _D {} class _E {}',
976 className: '_C'); 976 className: '_C');
977 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); 977 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
978 } 978 }
979 979
980 test_class_alias_reference_generic() { 980 test_class_alias_reference_generic() {
981 TypeRef typeRef = serializeTypeText('C', 981 EntityRef typeRef = serializeTypeText('C',
982 otherDeclarations: 'class C<D, E> = F with G; class F {} class G {}'); 982 otherDeclarations: 'class C<D, E> = F with G; class F {} class G {}');
983 checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2); 983 checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2);
984 } 984 }
985 985
986 test_class_alias_reference_generic_imported() { 986 test_class_alias_reference_generic_imported() {
987 addNamedSource( 987 addNamedSource(
988 '/lib.dart', 'class C<D, E> = F with G; class F {} class G {}'); 988 '/lib.dart', 'class C<D, E> = F with G; class F {} class G {}');
989 TypeRef typeRef = 989 EntityRef typeRef =
990 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); 990 serializeTypeText('C', otherDeclarations: 'import "lib.dart";');
991 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C', 991 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C',
992 numTypeParameters: 2); 992 numTypeParameters: 2);
993 } 993 }
994 994
995 test_class_alias_supertype() { 995 test_class_alias_supertype() {
996 UnlinkedClass cls = 996 UnlinkedClass cls =
997 serializeClassText('class C = D with E; class D {} class E {}'); 997 serializeClassText('class C = D with E; class D {} class E {}');
998 checkTypeRef(cls.supertype, null, null, 'D'); 998 checkTypeRef(cls.supertype, null, null, 'D');
999 expect(cls.hasNoSupertype, isFalse); 999 expect(cls.hasNoSupertype, isFalse);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 UnlinkedClass cls = serializeClassText('class C {}'); 1115 UnlinkedClass cls = serializeClassText('class C {}');
1116 expect(cls.isMixinApplication, false); 1116 expect(cls.isMixinApplication, false);
1117 } 1117 }
1118 1118
1119 test_class_private() { 1119 test_class_private() {
1120 serializeClassText('class _C {}', className: '_C'); 1120 serializeClassText('class _C {}', className: '_C');
1121 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); 1121 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
1122 } 1122 }
1123 1123
1124 test_class_reference_generic() { 1124 test_class_reference_generic() {
1125 TypeRef typeRef = 1125 EntityRef typeRef =
1126 serializeTypeText('C', otherDeclarations: 'class C<D, E> {}'); 1126 serializeTypeText('C', otherDeclarations: 'class C<D, E> {}');
1127 checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2); 1127 checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2);
1128 } 1128 }
1129 1129
1130 test_class_reference_generic_imported() { 1130 test_class_reference_generic_imported() {
1131 addNamedSource('/lib.dart', 'class C<D, E> {}'); 1131 addNamedSource('/lib.dart', 'class C<D, E> {}');
1132 TypeRef typeRef = 1132 EntityRef typeRef =
1133 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); 1133 serializeTypeText('C', otherDeclarations: 'import "lib.dart";');
1134 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C', 1134 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C',
1135 numTypeParameters: 2); 1135 numTypeParameters: 2);
1136 } 1136 }
1137 1137
1138 test_class_superclass() { 1138 test_class_superclass() {
1139 UnlinkedClass cls = serializeClassText('class C {}'); 1139 UnlinkedClass cls = serializeClassText('class C {}');
1140 expect(cls.supertype, isNull); 1140 expect(cls.supertype, isNull);
1141 expect(cls.hasNoSupertype, isFalse); 1141 expect(cls.hasNoSupertype, isFalse);
1142 } 1142 }
1143 1143
1144 test_class_superclass_explicit() { 1144 test_class_superclass_explicit() {
1145 UnlinkedClass cls = serializeClassText('class C extends D {} class D {}'); 1145 UnlinkedClass cls = serializeClassText('class C extends D {} class D {}');
1146 expect(cls.supertype, isNotNull); 1146 expect(cls.supertype, isNotNull);
1147 checkTypeRef(cls.supertype, null, null, 'D'); 1147 checkTypeRef(cls.supertype, null, null, 'D');
1148 expect(cls.hasNoSupertype, isFalse); 1148 expect(cls.hasNoSupertype, isFalse);
1149 } 1149 }
1150 1150
1151 test_class_type_param_bound() { 1151 test_class_type_param_bound() {
1152 UnlinkedClass cls = serializeClassText('class C<T extends List> {}'); 1152 UnlinkedClass cls = serializeClassText('class C<T extends List> {}');
1153 expect(cls.typeParameters, hasLength(1)); 1153 expect(cls.typeParameters, hasLength(1));
1154 expect(cls.typeParameters[0].name, 'T'); 1154 expect(cls.typeParameters[0].name, 'T');
1155 expect(cls.typeParameters[0].bound, isNotNull); 1155 expect(cls.typeParameters[0].bound, isNotNull);
1156 checkTypeRef(cls.typeParameters[0].bound, 'dart:core', 'dart:core', 'List', 1156 checkTypeRef(cls.typeParameters[0].bound, 'dart:core', 'dart:core', 'List',
1157 allowTypeParameters: true, numTypeParameters: 1); 1157 allowTypeParameters: true, numTypeParameters: 1);
1158 } 1158 }
1159 1159
1160 test_class_type_param_f_bound() { 1160 test_class_type_param_f_bound() {
1161 UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}'); 1161 UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}');
1162 TypeRef typeArgument = cls.typeParameters[1].bound.typeArguments[0]; 1162 EntityRef typeArgument = cls.typeParameters[1].bound.typeArguments[0];
1163 checkParamTypeRef(typeArgument, 2); 1163 checkParamTypeRef(typeArgument, 2);
1164 } 1164 }
1165 1165
1166 test_class_type_param_f_bound_self_ref() { 1166 test_class_type_param_f_bound_self_ref() {
1167 UnlinkedClass cls = serializeClassText('class C<T, U extends List<U>> {}'); 1167 UnlinkedClass cls = serializeClassText('class C<T, U extends List<U>> {}');
1168 TypeRef typeArgument = cls.typeParameters[1].bound.typeArguments[0]; 1168 EntityRef typeArgument = cls.typeParameters[1].bound.typeArguments[0];
1169 checkParamTypeRef(typeArgument, 1); 1169 checkParamTypeRef(typeArgument, 1);
1170 } 1170 }
1171 1171
1172 test_class_type_param_no_bound() { 1172 test_class_type_param_no_bound() {
1173 String text = 'class C<T> {}'; 1173 String text = 'class C<T> {}';
1174 UnlinkedClass cls = serializeClassText(text); 1174 UnlinkedClass cls = serializeClassText(text);
1175 expect(cls.typeParameters, hasLength(1)); 1175 expect(cls.typeParameters, hasLength(1));
1176 expect(cls.typeParameters[0].name, 'T'); 1176 expect(cls.typeParameters[0].name, 'T');
1177 expect(cls.typeParameters[0].nameOffset, text.indexOf('T')); 1177 expect(cls.typeParameters[0].nameOffset, text.indexOf('T'));
1178 expect(cls.typeParameters[0].bound, isNull); 1178 expect(cls.typeParameters[0].bound, isNull);
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 const v = const C.named(); 1442 const v = const C.named();
1443 '''); 1443 ''');
1444 _assertUnlinkedConst(variable.constExpr, operators: [ 1444 _assertUnlinkedConst(variable.constExpr, operators: [
1445 UnlinkedConstOperation.invokeConstructor, 1445 UnlinkedConstOperation.invokeConstructor,
1446 ], ints: [ 1446 ], ints: [
1447 0, 1447 0,
1448 0 1448 0
1449 ], strings: [ 1449 ], strings: [
1450 'named' 1450 'named'
1451 ], referenceValidators: [ 1451 ], referenceValidators: [
1452 (TypeRef r) => checkTypeRef(r, null, null, 'C', 1452 (EntityRef r) => checkTypeRef(r, null, null, 'C',
1453 expectedKind: ReferenceKind.classOrEnum) 1453 expectedKind: ReferenceKind.classOrEnum)
1454 ]); 1454 ]);
1455 } 1455 }
1456 1456
1457 test_constExpr_invokeConstructor_named_imported() { 1457 test_constExpr_invokeConstructor_named_imported() {
1458 if (checkAstDerivedData) { 1458 if (checkAstDerivedData) {
1459 // TODO(scheglov) at the moment we cannot link class member references 1459 // TODO(scheglov) at the moment we cannot link class member references
1460 return; 1460 return;
1461 } 1461 }
1462 addNamedSource( 1462 addNamedSource(
1463 '/a.dart', 1463 '/a.dart',
1464 ''' 1464 '''
1465 class C { 1465 class C {
1466 const C.named(); 1466 const C.named();
1467 } 1467 }
1468 '''); 1468 ''');
1469 UnlinkedVariable variable = serializeVariableText(''' 1469 UnlinkedVariable variable = serializeVariableText('''
1470 import 'a.dart'; 1470 import 'a.dart';
1471 const v = const C.named(); 1471 const v = const C.named();
1472 '''); 1472 ''');
1473 _assertUnlinkedConst(variable.constExpr, operators: [ 1473 _assertUnlinkedConst(variable.constExpr, operators: [
1474 UnlinkedConstOperation.invokeConstructor, 1474 UnlinkedConstOperation.invokeConstructor,
1475 ], ints: [ 1475 ], ints: [
1476 0, 1476 0,
1477 0 1477 0
1478 ], strings: [ 1478 ], strings: [
1479 'named' 1479 'named'
1480 ], referenceValidators: [ 1480 ], referenceValidators: [
1481 (TypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', 1481 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
1482 expectedKind: ReferenceKind.classOrEnum) 1482 expectedKind: ReferenceKind.classOrEnum)
1483 ]); 1483 ]);
1484 } 1484 }
1485 1485
1486 test_constExpr_invokeConstructor_named_imported_withPrefix() { 1486 test_constExpr_invokeConstructor_named_imported_withPrefix() {
1487 addNamedSource( 1487 addNamedSource(
1488 '/a.dart', 1488 '/a.dart',
1489 ''' 1489 '''
1490 class C { 1490 class C {
1491 const C.named(); 1491 const C.named();
1492 } 1492 }
1493 '''); 1493 ''');
1494 UnlinkedVariable variable = serializeVariableText(''' 1494 UnlinkedVariable variable = serializeVariableText('''
1495 import 'a.dart' as p; 1495 import 'a.dart' as p;
1496 const v = const p.C.named(); 1496 const v = const p.C.named();
1497 '''); 1497 ''');
1498 _assertUnlinkedConst(variable.constExpr, operators: [ 1498 _assertUnlinkedConst(variable.constExpr, operators: [
1499 UnlinkedConstOperation.invokeConstructor, 1499 UnlinkedConstOperation.invokeConstructor,
1500 ], ints: [ 1500 ], ints: [
1501 0, 1501 0,
1502 0 1502 0
1503 ], strings: [ 1503 ], strings: [
1504 'named' 1504 'named'
1505 ], referenceValidators: [ 1505 ], referenceValidators: [
1506 (TypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', 1506 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
1507 expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'p') 1507 expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'p')
1508 ]); 1508 ]);
1509 } 1509 }
1510 1510
1511 test_constExpr_invokeConstructor_unnamed() { 1511 test_constExpr_invokeConstructor_unnamed() {
1512 UnlinkedVariable variable = serializeVariableText(''' 1512 UnlinkedVariable variable = serializeVariableText('''
1513 class C { 1513 class C {
1514 const C(a, b, c, d, {e, f, g}); 1514 const C(a, b, c, d, {e, f, g});
1515 } 1515 }
1516 const v = const C(11, 22, 3.3, '444', e: 55, g: '777', f: 66); 1516 const v = const C(11, 22, 3.3, '444', e: 55, g: '777', f: 66);
(...skipping 21 matching lines...) Expand all
1538 ], doubles: [ 1538 ], doubles: [
1539 3.3 1539 3.3
1540 ], strings: [ 1540 ], strings: [
1541 '444', 1541 '444',
1542 '777', 1542 '777',
1543 'e', 1543 'e',
1544 'g', 1544 'g',
1545 'f', 1545 'f',
1546 '' 1546 ''
1547 ], referenceValidators: [ 1547 ], referenceValidators: [
1548 (TypeRef r) => checkTypeRef(r, null, null, 'C', 1548 (EntityRef r) => checkTypeRef(r, null, null, 'C',
1549 expectedKind: ReferenceKind.classOrEnum) 1549 expectedKind: ReferenceKind.classOrEnum)
1550 ]); 1550 ]);
1551 } 1551 }
1552 1552
1553 test_constExpr_length() { 1553 test_constExpr_length() {
1554 UnlinkedVariable variable = 1554 UnlinkedVariable variable =
1555 serializeVariableText('const v = "abc".length;'); 1555 serializeVariableText('const v = "abc".length;');
1556 _assertUnlinkedConst(variable.constExpr, operators: [ 1556 _assertUnlinkedConst(variable.constExpr, operators: [
1557 UnlinkedConstOperation.pushString, 1557 UnlinkedConstOperation.pushString,
1558 UnlinkedConstOperation.length 1558 UnlinkedConstOperation.length
1559 ], strings: [ 1559 ], strings: [
1560 'abc' 1560 'abc'
1561 ]); 1561 ]);
1562 } 1562 }
1563 1563
1564 test_constExpr_makeList_typed() { 1564 test_constExpr_makeList_typed() {
1565 UnlinkedVariable variable = 1565 UnlinkedVariable variable =
1566 serializeVariableText('const v = const <int>[11, 22, 33];'); 1566 serializeVariableText('const v = const <int>[11, 22, 33];');
1567 _assertUnlinkedConst(variable.constExpr, operators: [ 1567 _assertUnlinkedConst(variable.constExpr, operators: [
1568 UnlinkedConstOperation.pushInt, 1568 UnlinkedConstOperation.pushInt,
1569 UnlinkedConstOperation.pushInt, 1569 UnlinkedConstOperation.pushInt,
1570 UnlinkedConstOperation.pushInt, 1570 UnlinkedConstOperation.pushInt,
1571 UnlinkedConstOperation.makeList 1571 UnlinkedConstOperation.makeList
1572 ], ints: [ 1572 ], ints: [
1573 11, 1573 11,
1574 22, 1574 22,
1575 33, 1575 33,
1576 3 1576 3
1577 ], referenceValidators: [ 1577 ], referenceValidators: [
1578 (TypeRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int', 1578 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int',
1579 expectedKind: ReferenceKind.classOrEnum) 1579 expectedKind: ReferenceKind.classOrEnum)
1580 ]); 1580 ]);
1581 } 1581 }
1582 1582
1583 test_constExpr_makeList_untyped() { 1583 test_constExpr_makeList_untyped() {
1584 UnlinkedVariable variable = 1584 UnlinkedVariable variable =
1585 serializeVariableText('const v = const [11, 22, 33];'); 1585 serializeVariableText('const v = const [11, 22, 33];');
1586 _assertUnlinkedConst(variable.constExpr, operators: [ 1586 _assertUnlinkedConst(variable.constExpr, operators: [
1587 UnlinkedConstOperation.pushInt, 1587 UnlinkedConstOperation.pushInt,
1588 UnlinkedConstOperation.pushInt, 1588 UnlinkedConstOperation.pushInt,
1589 UnlinkedConstOperation.pushInt, 1589 UnlinkedConstOperation.pushInt,
1590 UnlinkedConstOperation.makeList 1590 UnlinkedConstOperation.makeList
1591 ], ints: [ 1591 ], ints: [
1592 11, 1592 11,
1593 22, 1593 22,
1594 33, 1594 33,
1595 3 1595 3
1596 ], referenceValidators: [ 1596 ], referenceValidators: [
1597 (TypeRef r) => checkTypeRef(r, null, null, '', 1597 (EntityRef r) => checkTypeRef(r, null, null, '',
1598 expectedKind: ReferenceKind.classOrEnum) 1598 expectedKind: ReferenceKind.classOrEnum)
1599 ]); 1599 ]);
1600 } 1600 }
1601 1601
1602 test_constExpr_makeMap_typed() { 1602 test_constExpr_makeMap_typed() {
1603 UnlinkedVariable variable = serializeVariableText( 1603 UnlinkedVariable variable = serializeVariableText(
1604 'const v = const <int, String>{11: "aaa", 22: "bbb", 33: "ccc"};'); 1604 'const v = const <int, String>{11: "aaa", 22: "bbb", 33: "ccc"};');
1605 _assertUnlinkedConst(variable.constExpr, operators: [ 1605 _assertUnlinkedConst(variable.constExpr, operators: [
1606 UnlinkedConstOperation.pushInt, 1606 UnlinkedConstOperation.pushInt,
1607 UnlinkedConstOperation.pushString, 1607 UnlinkedConstOperation.pushString,
1608 UnlinkedConstOperation.pushInt, 1608 UnlinkedConstOperation.pushInt,
1609 UnlinkedConstOperation.pushString, 1609 UnlinkedConstOperation.pushString,
1610 UnlinkedConstOperation.pushInt, 1610 UnlinkedConstOperation.pushInt,
1611 UnlinkedConstOperation.pushString, 1611 UnlinkedConstOperation.pushString,
1612 UnlinkedConstOperation.makeMap 1612 UnlinkedConstOperation.makeMap
1613 ], ints: [ 1613 ], ints: [
1614 11, 1614 11,
1615 22, 1615 22,
1616 33, 1616 33,
1617 3 1617 3
1618 ], strings: [ 1618 ], strings: [
1619 'aaa', 1619 'aaa',
1620 'bbb', 1620 'bbb',
1621 'ccc' 1621 'ccc'
1622 ], referenceValidators: [ 1622 ], referenceValidators: [
1623 (TypeRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int', 1623 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int',
1624 expectedKind: ReferenceKind.classOrEnum), 1624 expectedKind: ReferenceKind.classOrEnum),
1625 (TypeRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String', 1625 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String',
1626 expectedKind: ReferenceKind.classOrEnum) 1626 expectedKind: ReferenceKind.classOrEnum)
1627 ]); 1627 ]);
1628 } 1628 }
1629 1629
1630 test_constExpr_makeMap_untyped() { 1630 test_constExpr_makeMap_untyped() {
1631 UnlinkedVariable variable = serializeVariableText( 1631 UnlinkedVariable variable = serializeVariableText(
1632 'const v = const {11: "aaa", 22: "bbb", 33: "ccc"};'); 1632 'const v = const {11: "aaa", 22: "bbb", 33: "ccc"};');
1633 _assertUnlinkedConst(variable.constExpr, operators: [ 1633 _assertUnlinkedConst(variable.constExpr, operators: [
1634 UnlinkedConstOperation.pushInt, 1634 UnlinkedConstOperation.pushInt,
1635 UnlinkedConstOperation.pushString, 1635 UnlinkedConstOperation.pushString,
1636 UnlinkedConstOperation.pushInt, 1636 UnlinkedConstOperation.pushInt,
1637 UnlinkedConstOperation.pushString, 1637 UnlinkedConstOperation.pushString,
1638 UnlinkedConstOperation.pushInt, 1638 UnlinkedConstOperation.pushInt,
1639 UnlinkedConstOperation.pushString, 1639 UnlinkedConstOperation.pushString,
1640 UnlinkedConstOperation.makeMap 1640 UnlinkedConstOperation.makeMap
1641 ], ints: [ 1641 ], ints: [
1642 11, 1642 11,
1643 22, 1643 22,
1644 33, 1644 33,
1645 3 1645 3
1646 ], strings: [ 1646 ], strings: [
1647 'aaa', 1647 'aaa',
1648 'bbb', 1648 'bbb',
1649 'ccc' 1649 'ccc'
1650 ], referenceValidators: [ 1650 ], referenceValidators: [
1651 (TypeRef r) => checkTypeRef(r, null, null, '', 1651 (EntityRef r) => checkTypeRef(r, null, null, '',
1652 expectedKind: ReferenceKind.classOrEnum), 1652 expectedKind: ReferenceKind.classOrEnum),
1653 (TypeRef r) => checkTypeRef(r, null, null, '', 1653 (EntityRef r) => checkTypeRef(r, null, null, '',
1654 expectedKind: ReferenceKind.classOrEnum) 1654 expectedKind: ReferenceKind.classOrEnum)
1655 ]); 1655 ]);
1656 } 1656 }
1657 1657
1658 test_constExpr_makeSymbol() { 1658 test_constExpr_makeSymbol() {
1659 UnlinkedVariable variable = serializeVariableText('const v = #a.bb.ccc;'); 1659 UnlinkedVariable variable = serializeVariableText('const v = #a.bb.ccc;');
1660 _assertUnlinkedConst(variable.constExpr, operators: [ 1660 _assertUnlinkedConst(variable.constExpr, operators: [
1661 UnlinkedConstOperation.pushString, 1661 UnlinkedConstOperation.pushString,
1662 UnlinkedConstOperation.makeSymbol 1662 UnlinkedConstOperation.makeSymbol
1663 ], strings: [ 1663 ], strings: [
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 } 1790 }
1791 1791
1792 test_constExpr_pushReference_class() { 1792 test_constExpr_pushReference_class() {
1793 UnlinkedVariable variable = serializeVariableText(''' 1793 UnlinkedVariable variable = serializeVariableText('''
1794 class C {} 1794 class C {}
1795 const v = C; 1795 const v = C;
1796 '''); 1796 ''');
1797 _assertUnlinkedConst(variable.constExpr, operators: [ 1797 _assertUnlinkedConst(variable.constExpr, operators: [
1798 UnlinkedConstOperation.pushReference 1798 UnlinkedConstOperation.pushReference
1799 ], referenceValidators: [ 1799 ], referenceValidators: [
1800 (TypeRef r) => checkTypeRef(r, null, null, 'C', 1800 (EntityRef r) => checkTypeRef(r, null, null, 'C',
1801 expectedKind: ReferenceKind.classOrEnum) 1801 expectedKind: ReferenceKind.classOrEnum)
1802 ]); 1802 ]);
1803 } 1803 }
1804 1804
1805 test_constExpr_pushReference_class_field() { 1805 test_constExpr_pushReference_class_field() {
1806 // TODO(scheglov) Not sure for to represent a field reference 1806 // TODO(scheglov) Not sure for to represent a field reference
1807 // using TypeRef. 1807 // using TypeRef.
1808 // UnlinkedVariable variable = serializeVariableText(''' 1808 // UnlinkedVariable variable = serializeVariableText('''
1809 //class C { 1809 //class C {
1810 // static const int F = 1; 1810 // static const int F = 1;
1811 //} 1811 //}
1812 //const v = C.F; 1812 //const v = C.F;
1813 //'''); 1813 //''');
1814 // _assertUnlinkedConst(variable.constExpr, operators: [ 1814 // _assertUnlinkedConst(variable.constExpr, operators: [
1815 // UnlinkedConstOperation.pushReference 1815 // UnlinkedConstOperation.pushReference
1816 // ], references: [ 1816 // ], references: [
1817 // (TypeRef r) => checkTypeRef(r, null, null, 'F', 1817 // (TypeRef r) => checkTypeRef(r, null, null, 'F',
1818 // expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'C') 1818 // expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'C')
1819 // ]); 1819 // ]);
1820 } 1820 }
1821 1821
1822 test_constExpr_pushReference_enum() { 1822 test_constExpr_pushReference_enum() {
1823 UnlinkedVariable variable = serializeVariableText(''' 1823 UnlinkedVariable variable = serializeVariableText('''
1824 enum C {V1, V2, V3} 1824 enum C {V1, V2, V3}
1825 const v = C; 1825 const v = C;
1826 '''); 1826 ''');
1827 _assertUnlinkedConst(variable.constExpr, operators: [ 1827 _assertUnlinkedConst(variable.constExpr, operators: [
1828 UnlinkedConstOperation.pushReference 1828 UnlinkedConstOperation.pushReference
1829 ], referenceValidators: [ 1829 ], referenceValidators: [
1830 (TypeRef r) => checkTypeRef(r, null, null, 'C', 1830 (EntityRef r) => checkTypeRef(r, null, null, 'C',
1831 expectedKind: ReferenceKind.classOrEnum) 1831 expectedKind: ReferenceKind.classOrEnum)
1832 ]); 1832 ]);
1833 } 1833 }
1834 1834
1835 test_constExpr_pushReference_topLevelVariable_imported() { 1835 test_constExpr_pushReference_topLevelVariable_imported() {
1836 addNamedSource('/a.dart', 'const int a = 1;'); 1836 addNamedSource('/a.dart', 'const int a = 1;');
1837 UnlinkedVariable variable = serializeVariableText(''' 1837 UnlinkedVariable variable = serializeVariableText('''
1838 import 'a.dart'; 1838 import 'a.dart';
1839 const v = a; 1839 const v = a;
1840 '''); 1840 ''');
1841 _assertUnlinkedConst(variable.constExpr, operators: [ 1841 _assertUnlinkedConst(variable.constExpr, operators: [
1842 UnlinkedConstOperation.pushReference 1842 UnlinkedConstOperation.pushReference
1843 ], referenceValidators: [ 1843 ], referenceValidators: [
1844 (TypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', 1844 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a',
1845 expectedKind: ReferenceKind.topLevelPropertyAccessor) 1845 expectedKind: ReferenceKind.topLevelPropertyAccessor)
1846 ]); 1846 ]);
1847 } 1847 }
1848 1848
1849 test_constExpr_pushReference_topLevelVariable_imported_withPrefix() { 1849 test_constExpr_pushReference_topLevelVariable_imported_withPrefix() {
1850 addNamedSource('/a.dart', 'const int a = 1;'); 1850 addNamedSource('/a.dart', 'const int a = 1;');
1851 UnlinkedVariable variable = serializeVariableText(''' 1851 UnlinkedVariable variable = serializeVariableText('''
1852 import 'a.dart' as p; 1852 import 'a.dart' as p;
1853 const v = p.a; 1853 const v = p.a;
1854 '''); 1854 ''');
1855 _assertUnlinkedConst(variable.constExpr, operators: [ 1855 _assertUnlinkedConst(variable.constExpr, operators: [
1856 UnlinkedConstOperation.pushReference 1856 UnlinkedConstOperation.pushReference
1857 ], referenceValidators: [ 1857 ], referenceValidators: [
1858 (TypeRef r) { 1858 (EntityRef r) {
1859 return checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', 1859 return checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a',
1860 expectedKind: ReferenceKind.topLevelPropertyAccessor, 1860 expectedKind: ReferenceKind.topLevelPropertyAccessor,
1861 expectedPrefix: 'p'); 1861 expectedPrefix: 'p');
1862 } 1862 }
1863 ]); 1863 ]);
1864 } 1864 }
1865 1865
1866 test_constExpr_pushReference_topLevelVariable_local() { 1866 test_constExpr_pushReference_topLevelVariable_local() {
1867 // TODO(scheglov) use `a + b` 1867 // TODO(scheglov) use `a + b`
1868 UnlinkedVariable variable = serializeVariableText(''' 1868 UnlinkedVariable variable = serializeVariableText('''
1869 const int a = 1; 1869 const int a = 1;
1870 const v = a; 1870 const v = a;
1871 '''); 1871 ''');
1872 _assertUnlinkedConst(variable.constExpr, operators: [ 1872 _assertUnlinkedConst(variable.constExpr, operators: [
1873 UnlinkedConstOperation.pushReference 1873 UnlinkedConstOperation.pushReference
1874 ], referenceValidators: [ 1874 ], referenceValidators: [
1875 (TypeRef r) => checkTypeRef(r, null, null, 'a', 1875 (EntityRef r) => checkTypeRef(r, null, null, 'a',
1876 expectedKind: ReferenceKind.topLevelPropertyAccessor) 1876 expectedKind: ReferenceKind.topLevelPropertyAccessor)
1877 ]); 1877 ]);
1878 } 1878 }
1879 1879
1880 test_constExpr_pushString_adjacent() { 1880 test_constExpr_pushString_adjacent() {
1881 UnlinkedVariable variable = 1881 UnlinkedVariable variable =
1882 serializeVariableText('const v = "aaa" "b" "ccc";'); 1882 serializeVariableText('const v = "aaa" "b" "ccc";');
1883 _assertUnlinkedConst(variable.constExpr, 1883 _assertUnlinkedConst(variable.constExpr,
1884 operators: [UnlinkedConstOperation.pushString], strings: ['aaabccc']); 1884 operators: [UnlinkedConstOperation.pushString], strings: ['aaabccc']);
1885 } 1885 }
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
2788 2788
2789 test_executable_static() { 2789 test_executable_static() {
2790 UnlinkedExecutable executable = 2790 UnlinkedExecutable executable =
2791 serializeClassText('class C { static f() {} }').executables[0]; 2791 serializeClassText('class C { static f() {} }').executables[0];
2792 expect(executable.isStatic, isTrue); 2792 expect(executable.isStatic, isTrue);
2793 } 2793 }
2794 2794
2795 test_executable_type_param_f_bound_function() { 2795 test_executable_type_param_f_bound_function() {
2796 UnlinkedExecutable ex = 2796 UnlinkedExecutable ex =
2797 serializeExecutableText('void f<T, U extends List<T>>() {}'); 2797 serializeExecutableText('void f<T, U extends List<T>>() {}');
2798 TypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0]; 2798 EntityRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
2799 checkParamTypeRef(typeArgument, 2); 2799 checkParamTypeRef(typeArgument, 2);
2800 } 2800 }
2801 2801
2802 test_executable_type_param_f_bound_method() { 2802 test_executable_type_param_f_bound_method() {
2803 UnlinkedExecutable ex = 2803 UnlinkedExecutable ex =
2804 serializeMethodText('void f<T, U extends List<T>>() {}'); 2804 serializeMethodText('void f<T, U extends List<T>>() {}');
2805 TypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0]; 2805 EntityRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
2806 checkParamTypeRef(typeArgument, 2); 2806 checkParamTypeRef(typeArgument, 2);
2807 } 2807 }
2808 2808
2809 test_executable_type_param_f_bound_self_ref_function() { 2809 test_executable_type_param_f_bound_self_ref_function() {
2810 UnlinkedExecutable ex = 2810 UnlinkedExecutable ex =
2811 serializeExecutableText('void f<T, U extends List<U>>() {}'); 2811 serializeExecutableText('void f<T, U extends List<U>>() {}');
2812 TypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0]; 2812 EntityRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
2813 checkParamTypeRef(typeArgument, 1); 2813 checkParamTypeRef(typeArgument, 1);
2814 } 2814 }
2815 2815
2816 test_executable_type_param_f_bound_self_ref_method() { 2816 test_executable_type_param_f_bound_self_ref_method() {
2817 UnlinkedExecutable ex = 2817 UnlinkedExecutable ex =
2818 serializeMethodText('void f<T, U extends List<U>>() {}'); 2818 serializeMethodText('void f<T, U extends List<U>>() {}');
2819 TypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0]; 2819 EntityRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
2820 checkParamTypeRef(typeArgument, 1); 2820 checkParamTypeRef(typeArgument, 1);
2821 } 2821 }
2822 2822
2823 test_executable_type_param_in_parameter_function() { 2823 test_executable_type_param_in_parameter_function() {
2824 UnlinkedExecutable ex = serializeExecutableText('void f<T>(T t) {}'); 2824 UnlinkedExecutable ex = serializeExecutableText('void f<T>(T t) {}');
2825 checkParamTypeRef(ex.parameters[0].type, 1); 2825 checkParamTypeRef(ex.parameters[0].type, 1);
2826 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 1); 2826 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 1);
2827 } 2827 }
2828 2828
2829 test_executable_type_param_in_parameter_method() { 2829 test_executable_type_param_in_parameter_method() {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
3107 return; 3107 return;
3108 } 3108 }
3109 serializeLibraryText('final x = 0; String y;'); 3109 serializeLibraryText('final x = 0; String y;');
3110 checkLinkedTypeSlot(unlinkedUnits[0].variables[0].propagatedTypeSlot, 3110 checkLinkedTypeSlot(unlinkedUnits[0].variables[0].propagatedTypeSlot,
3111 'dart:core', 'dart:core', 'int'); 3111 'dart:core', 'dart:core', 'int');
3112 checkTypeRef( 3112 checkTypeRef(
3113 unlinkedUnits[0].variables[1].type, 'dart:core', 'dart:core', 'String'); 3113 unlinkedUnits[0].variables[1].type, 'dart:core', 'dart:core', 'String');
3114 // Even though the definition of y follows the definition of x, the linked 3114 // Even though the definition of y follows the definition of x, the linked
3115 // type reference for x should use a higher numbered reference than the 3115 // type reference for x should use a higher numbered reference than the
3116 // unlinked type reference for y. 3116 // unlinked type reference for y.
3117 TypeRef propagatedType = 3117 EntityRef propagatedType =
3118 getTypeRefForSlot(unlinkedUnits[0].variables[0].propagatedTypeSlot); 3118 getTypeRefForSlot(unlinkedUnits[0].variables[0].propagatedTypeSlot);
3119 expect(unlinkedUnits[0].variables[1].type.reference, 3119 expect(unlinkedUnits[0].variables[1].type.reference,
3120 lessThan(propagatedType.reference)); 3120 lessThan(propagatedType.reference));
3121 } 3121 }
3122 3122
3123 test_function_documented() { 3123 test_function_documented() {
3124 String text = ''' 3124 String text = '''
3125 // Extra comment so doc comment offset != 0 3125 // Extra comment so doc comment offset != 0
3126 /** 3126 /**
3127 * Docs 3127 * Docs
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
3588 test_slot_reuse() { 3588 test_slot_reuse() {
3589 // Different compilation units have independent notions of slot id, so slot 3589 // Different compilation units have independent notions of slot id, so slot
3590 // ids should be reused. 3590 // ids should be reused.
3591 addNamedSource('/a.dart', 'part of foo; final v = 0;'); 3591 addNamedSource('/a.dart', 'part of foo; final v = 0;');
3592 serializeLibraryText('library foo; part "a.dart"; final w = 0;'); 3592 serializeLibraryText('library foo; part "a.dart"; final w = 0;');
3593 expect(unlinkedUnits[0].variables[0].propagatedTypeSlot, 1); 3593 expect(unlinkedUnits[0].variables[0].propagatedTypeSlot, 1);
3594 expect(unlinkedUnits[1].variables[0].propagatedTypeSlot, 1); 3594 expect(unlinkedUnits[1].variables[0].propagatedTypeSlot, 1);
3595 } 3595 }
3596 3596
3597 test_type_arguments_explicit() { 3597 test_type_arguments_explicit() {
3598 TypeRef typeRef = serializeTypeText('List<int>'); 3598 EntityRef typeRef = serializeTypeText('List<int>');
3599 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', 3599 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List',
3600 allowTypeParameters: true, numTypeParameters: 1); 3600 allowTypeParameters: true, numTypeParameters: 1);
3601 expect(typeRef.typeArguments, hasLength(1)); 3601 expect(typeRef.typeArguments, hasLength(1));
3602 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); 3602 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int');
3603 } 3603 }
3604 3604
3605 test_type_arguments_explicit_dynamic() { 3605 test_type_arguments_explicit_dynamic() {
3606 TypeRef typeRef = serializeTypeText('List<dynamic>'); 3606 EntityRef typeRef = serializeTypeText('List<dynamic>');
3607 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', 3607 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List',
3608 allowTypeParameters: true, numTypeParameters: 1); 3608 allowTypeParameters: true, numTypeParameters: 1);
3609 expect(typeRef.typeArguments, isEmpty); 3609 expect(typeRef.typeArguments, isEmpty);
3610 } 3610 }
3611 3611
3612 test_type_arguments_explicit_dynamic_dynamic() { 3612 test_type_arguments_explicit_dynamic_dynamic() {
3613 TypeRef typeRef = serializeTypeText('Map<dynamic, dynamic>'); 3613 EntityRef typeRef = serializeTypeText('Map<dynamic, dynamic>');
3614 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', 3614 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map',
3615 allowTypeParameters: true, numTypeParameters: 2); 3615 allowTypeParameters: true, numTypeParameters: 2);
3616 // Trailing type arguments of type `dynamic` are omitted. 3616 // Trailing type arguments of type `dynamic` are omitted.
3617 expect(typeRef.typeArguments, isEmpty); 3617 expect(typeRef.typeArguments, isEmpty);
3618 } 3618 }
3619 3619
3620 test_type_arguments_explicit_dynamic_int() { 3620 test_type_arguments_explicit_dynamic_int() {
3621 TypeRef typeRef = serializeTypeText('Map<dynamic, int>'); 3621 EntityRef typeRef = serializeTypeText('Map<dynamic, int>');
3622 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', 3622 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map',
3623 allowTypeParameters: true, numTypeParameters: 2); 3623 allowTypeParameters: true, numTypeParameters: 2);
3624 // Leading type arguments of type `dynamic` are not omitted. 3624 // Leading type arguments of type `dynamic` are not omitted.
3625 expect(typeRef.typeArguments.length, 2); 3625 expect(typeRef.typeArguments.length, 2);
3626 checkDynamicTypeRef(typeRef.typeArguments[0]); 3626 checkDynamicTypeRef(typeRef.typeArguments[0]);
3627 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); 3627 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int');
3628 } 3628 }
3629 3629
3630 test_type_arguments_explicit_dynamic_typedef() { 3630 test_type_arguments_explicit_dynamic_typedef() {
3631 TypeRef typeRef = 3631 EntityRef typeRef =
3632 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();'); 3632 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();');
3633 checkTypeRef(typeRef, null, null, 'F', 3633 checkTypeRef(typeRef, null, null, 'F',
3634 allowTypeParameters: true, 3634 allowTypeParameters: true,
3635 expectedKind: ReferenceKind.typedef, 3635 expectedKind: ReferenceKind.typedef,
3636 numTypeParameters: 1); 3636 numTypeParameters: 1);
3637 expect(typeRef.typeArguments, isEmpty); 3637 expect(typeRef.typeArguments, isEmpty);
3638 } 3638 }
3639 3639
3640 test_type_arguments_explicit_String_dynamic() { 3640 test_type_arguments_explicit_String_dynamic() {
3641 TypeRef typeRef = serializeTypeText('Map<String, dynamic>'); 3641 EntityRef typeRef = serializeTypeText('Map<String, dynamic>');
3642 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', 3642 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map',
3643 allowTypeParameters: true, numTypeParameters: 2); 3643 allowTypeParameters: true, numTypeParameters: 2);
3644 // Trailing type arguments of type `dynamic` are omitted. 3644 // Trailing type arguments of type `dynamic` are omitted.
3645 expect(typeRef.typeArguments.length, 1); 3645 expect(typeRef.typeArguments.length, 1);
3646 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); 3646 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String');
3647 } 3647 }
3648 3648
3649 test_type_arguments_explicit_String_int() { 3649 test_type_arguments_explicit_String_int() {
3650 TypeRef typeRef = serializeTypeText('Map<String, int>'); 3650 EntityRef typeRef = serializeTypeText('Map<String, int>');
3651 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', 3651 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map',
3652 allowTypeParameters: true, numTypeParameters: 2); 3652 allowTypeParameters: true, numTypeParameters: 2);
3653 expect(typeRef.typeArguments.length, 2); 3653 expect(typeRef.typeArguments.length, 2);
3654 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); 3654 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String');
3655 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); 3655 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int');
3656 } 3656 }
3657 3657
3658 test_type_arguments_explicit_typedef() { 3658 test_type_arguments_explicit_typedef() {
3659 TypeRef typeRef = 3659 EntityRef typeRef =
3660 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();'); 3660 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();');
3661 checkTypeRef(typeRef, null, null, 'F', 3661 checkTypeRef(typeRef, null, null, 'F',
3662 allowTypeParameters: true, 3662 allowTypeParameters: true,
3663 expectedKind: ReferenceKind.typedef, 3663 expectedKind: ReferenceKind.typedef,
3664 numTypeParameters: 1); 3664 numTypeParameters: 1);
3665 expect(typeRef.typeArguments, hasLength(1)); 3665 expect(typeRef.typeArguments, hasLength(1));
3666 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); 3666 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int');
3667 } 3667 }
3668 3668
3669 test_type_arguments_implicit() { 3669 test_type_arguments_implicit() {
3670 TypeRef typeRef = serializeTypeText('List'); 3670 EntityRef typeRef = serializeTypeText('List');
3671 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', 3671 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List',
3672 allowTypeParameters: true, numTypeParameters: 1); 3672 allowTypeParameters: true, numTypeParameters: 1);
3673 expect(typeRef.typeArguments, isEmpty); 3673 expect(typeRef.typeArguments, isEmpty);
3674 } 3674 }
3675 3675
3676 test_type_arguments_implicit_typedef() { 3676 test_type_arguments_implicit_typedef() {
3677 TypeRef typeRef = 3677 EntityRef typeRef =
3678 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();'); 3678 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();');
3679 checkTypeRef(typeRef, null, null, 'F', 3679 checkTypeRef(typeRef, null, null, 'F',
3680 allowTypeParameters: true, 3680 allowTypeParameters: true,
3681 expectedKind: ReferenceKind.typedef, 3681 expectedKind: ReferenceKind.typedef,
3682 numTypeParameters: 1); 3682 numTypeParameters: 1);
3683 expect(typeRef.typeArguments, isEmpty); 3683 expect(typeRef.typeArguments, isEmpty);
3684 } 3684 }
3685 3685
3686 test_type_arguments_order() { 3686 test_type_arguments_order() {
3687 TypeRef typeRef = serializeTypeText('Map<int, Object>'); 3687 EntityRef typeRef = serializeTypeText('Map<int, Object>');
3688 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', 3688 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map',
3689 allowTypeParameters: true, numTypeParameters: 2); 3689 allowTypeParameters: true, numTypeParameters: 2);
3690 expect(typeRef.typeArguments, hasLength(2)); 3690 expect(typeRef.typeArguments, hasLength(2));
3691 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); 3691 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int');
3692 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object'); 3692 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object');
3693 } 3693 }
3694 3694
3695 test_type_dynamic() { 3695 test_type_dynamic() {
3696 checkDynamicTypeRef(serializeTypeText('dynamic')); 3696 checkDynamicTypeRef(serializeTypeText('dynamic'));
3697 } 3697 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3788 checkTypeRef(findVariable('v', variables: unlinkedUnits[1].variables).type, 3788 checkTypeRef(findVariable('v', variables: unlinkedUnits[1].variables).type,
3789 absUri('/a.dart'), 'a.dart', 'C', 3789 absUri('/a.dart'), 'a.dart', 'C',
3790 expectedPrefix: 'a', 3790 expectedPrefix: 'a',
3791 linkedSourceUnit: linked.units[1], 3791 linkedSourceUnit: linked.units[1],
3792 unlinkedSourceUnit: unlinkedUnits[1]); 3792 unlinkedSourceUnit: unlinkedUnits[1]);
3793 } 3793 }
3794 3794
3795 test_type_reference_to_class_argument() { 3795 test_type_reference_to_class_argument() {
3796 UnlinkedClass cls = serializeClassText('class C<T, U> { T t; U u; }'); 3796 UnlinkedClass cls = serializeClassText('class C<T, U> { T t; U u; }');
3797 { 3797 {
3798 TypeRef typeRef = 3798 EntityRef typeRef =
3799 findVariable('t', variables: cls.fields, failIfAbsent: true).type; 3799 findVariable('t', variables: cls.fields, failIfAbsent: true).type;
3800 checkParamTypeRef(typeRef, 2); 3800 checkParamTypeRef(typeRef, 2);
3801 } 3801 }
3802 { 3802 {
3803 TypeRef typeRef = 3803 EntityRef typeRef =
3804 findVariable('u', variables: cls.fields, failIfAbsent: true).type; 3804 findVariable('u', variables: cls.fields, failIfAbsent: true).type;
3805 checkParamTypeRef(typeRef, 1); 3805 checkParamTypeRef(typeRef, 1);
3806 } 3806 }
3807 } 3807 }
3808 3808
3809 test_type_reference_to_import_of_export() { 3809 test_type_reference_to_import_of_export() {
3810 addNamedSource('/a.dart', 'library a; export "b.dart";'); 3810 addNamedSource('/a.dart', 'library a; export "b.dart";');
3811 addNamedSource('/b.dart', 'library b; class C {}'); 3811 addNamedSource('/b.dart', 'library b; class C {}');
3812 checkTypeRef(serializeTypeText('C', otherDeclarations: 'import "a.dart";'), 3812 checkTypeRef(serializeTypeText('C', otherDeclarations: 'import "a.dart";'),
3813 absUri('/b.dart'), 'b.dart', 'C'); 3813 absUri('/b.dart'), 'b.dart', 'C');
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3880 } 3880 }
3881 3881
3882 test_type_reference_to_nonexistent_file_via_prefix() { 3882 test_type_reference_to_nonexistent_file_via_prefix() {
3883 if (!checkAstDerivedData) { 3883 if (!checkAstDerivedData) {
3884 // TODO(paulberry): this test currently fails because there is not enough 3884 // TODO(paulberry): this test currently fails because there is not enough
3885 // information in the element model to figure out that the unresolved 3885 // information in the element model to figure out that the unresolved
3886 // reference `p.C` uses the prefix `p`. 3886 // reference `p.C` uses the prefix `p`.
3887 return; 3887 return;
3888 } 3888 }
3889 allowMissingFiles = true; 3889 allowMissingFiles = true;
3890 TypeRef typeRef = serializeTypeText('p.C', 3890 EntityRef typeRef = serializeTypeText('p.C',
3891 otherDeclarations: 'import "foo.dart" as p;', allowErrors: true); 3891 otherDeclarations: 'import "foo.dart" as p;', allowErrors: true);
3892 checkUnresolvedTypeRef(typeRef, 'p', 'C'); 3892 checkUnresolvedTypeRef(typeRef, 'p', 'C');
3893 } 3893 }
3894 3894
3895 test_type_reference_to_part() { 3895 test_type_reference_to_part() {
3896 addNamedSource('/a.dart', 'part of foo; class C { C(); }'); 3896 addNamedSource('/a.dart', 'part of foo; class C { C(); }');
3897 serializeLibraryText('library foo; part "a.dart"; C c;'); 3897 serializeLibraryText('library foo; part "a.dart"; C c;');
3898 checkTypeRef(unlinkedUnits[0].variables.single.type, null, null, 'C', 3898 checkTypeRef(unlinkedUnits[0].variables.single.type, null, null, 'C',
3899 expectedKind: ReferenceKind.classOrEnum, expectedTargetUnit: 1); 3899 expectedKind: ReferenceKind.classOrEnum, expectedTargetUnit: 1);
3900 } 3900 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3933 test_type_reference_to_typedef() { 3933 test_type_reference_to_typedef() {
3934 checkTypeRef(serializeTypeText('F', otherDeclarations: 'typedef void F();'), 3934 checkTypeRef(serializeTypeText('F', otherDeclarations: 'typedef void F();'),
3935 null, null, 'F', 3935 null, null, 'F',
3936 expectedKind: ReferenceKind.typedef); 3936 expectedKind: ReferenceKind.typedef);
3937 } 3937 }
3938 3938
3939 test_type_unit_counts_unreferenced_units() { 3939 test_type_unit_counts_unreferenced_units() {
3940 addNamedSource('/a.dart', 'library a; part "b.dart"; part "c.dart";'); 3940 addNamedSource('/a.dart', 'library a; part "b.dart"; part "c.dart";');
3941 addNamedSource('/b.dart', 'part of a;'); 3941 addNamedSource('/b.dart', 'part of a;');
3942 addNamedSource('/c.dart', 'part of a; class C {}'); 3942 addNamedSource('/c.dart', 'part of a; class C {}');
3943 TypeRef typeRef = 3943 EntityRef typeRef =
3944 serializeTypeText('C', otherDeclarations: 'import "a.dart";'); 3944 serializeTypeText('C', otherDeclarations: 'import "a.dart";');
3945 // The referenced unit should be 2, since unit 0 is a.dart and unit 1 is 3945 // The referenced unit should be 2, since unit 0 is a.dart and unit 1 is
3946 // b.dart. a.dart and b.dart are counted even though nothing is imported 3946 // b.dart. a.dart and b.dart are counted even though nothing is imported
3947 // from them. 3947 // from them.
3948 checkTypeRef(typeRef, absUri('/a.dart'), 'a.dart', 'C', 3948 checkTypeRef(typeRef, absUri('/a.dart'), 'a.dart', 'C',
3949 expectedTargetUnit: 2); 3949 expectedTargetUnit: 2);
3950 } 3950 }
3951 3951
3952 test_type_unresolved() { 3952 test_type_unresolved() {
3953 TypeRef typeRef = serializeTypeText('Foo', allowErrors: true); 3953 EntityRef typeRef = serializeTypeText('Foo', allowErrors: true);
3954 checkUnresolvedTypeRef(typeRef, null, 'Foo'); 3954 checkUnresolvedTypeRef(typeRef, null, 'Foo');
3955 } 3955 }
3956 3956
3957 test_typedef_documented() { 3957 test_typedef_documented() {
3958 String text = ''' 3958 String text = '''
3959 // Extra comment so doc comment offset != 0 3959 // Extra comment so doc comment offset != 0
3960 /** 3960 /**
3961 * Docs 3961 * Docs
3962 */ 3962 */
3963 typedef F();'''; 3963 typedef F();''';
(...skipping 25 matching lines...) Expand all
3989 expect(type.parameters[0].name, 'x'); 3989 expect(type.parameters[0].name, 'x');
3990 expect(type.parameters[1].name, 'y'); 3990 expect(type.parameters[1].name, 'y');
3991 } 3991 }
3992 3992
3993 test_typedef_private() { 3993 test_typedef_private() {
3994 serializeTypedefText('typedef _F();', '_F'); 3994 serializeTypedefText('typedef _F();', '_F');
3995 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); 3995 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
3996 } 3996 }
3997 3997
3998 test_typedef_reference_generic() { 3998 test_typedef_reference_generic() {
3999 TypeRef typeRef = 3999 EntityRef typeRef =
4000 serializeTypeText('F', otherDeclarations: 'typedef void F<A, B>();'); 4000 serializeTypeText('F', otherDeclarations: 'typedef void F<A, B>();');
4001 checkTypeRef(typeRef, null, null, 'F', 4001 checkTypeRef(typeRef, null, null, 'F',
4002 numTypeParameters: 2, expectedKind: ReferenceKind.typedef); 4002 numTypeParameters: 2, expectedKind: ReferenceKind.typedef);
4003 } 4003 }
4004 4004
4005 test_typedef_reference_generic_imported() { 4005 test_typedef_reference_generic_imported() {
4006 addNamedSource('/lib.dart', 'typedef void F<A, B>();'); 4006 addNamedSource('/lib.dart', 'typedef void F<A, B>();');
4007 TypeRef typeRef = 4007 EntityRef typeRef =
4008 serializeTypeText('F', otherDeclarations: 'import "lib.dart";'); 4008 serializeTypeText('F', otherDeclarations: 'import "lib.dart";');
4009 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'F', 4009 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'F',
4010 numTypeParameters: 2, expectedKind: ReferenceKind.typedef); 4010 numTypeParameters: 2, expectedKind: ReferenceKind.typedef);
4011 } 4011 }
4012 4012
4013 test_typedef_return_type_explicit() { 4013 test_typedef_return_type_explicit() {
4014 UnlinkedTypedef type = serializeTypedefText('typedef int F();'); 4014 UnlinkedTypedef type = serializeTypedefText('typedef int F();');
4015 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int'); 4015 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int');
4016 } 4016 }
4017 4017
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
4157 4157
4158 test_variable_propagated_type_new_reference() { 4158 test_variable_propagated_type_new_reference() {
4159 if (skipFullyLinkedData) { 4159 if (skipFullyLinkedData) {
4160 return; 4160 return;
4161 } 4161 }
4162 UnlinkedVariable v = serializeVariableText('final v = 0;'); 4162 UnlinkedVariable v = serializeVariableText('final v = 0;');
4163 // Since the propagated type of `v` is `int`, and there are no references 4163 // Since the propagated type of `v` is `int`, and there are no references
4164 // to `int` elsewhere in the source file, a new linked reference should 4164 // to `int` elsewhere in the source file, a new linked reference should
4165 // have been created for it, with no associated unlinked reference. 4165 // have been created for it, with no associated unlinked reference.
4166 expect(v.propagatedTypeSlot, isNot(0)); 4166 expect(v.propagatedTypeSlot, isNot(0));
4167 TypeRef type = getTypeRefForSlot(v.propagatedTypeSlot); 4167 EntityRef type = getTypeRefForSlot(v.propagatedTypeSlot);
4168 expect(type, isNotNull); 4168 expect(type, isNotNull);
4169 expect(type.reference, 4169 expect(type.reference,
4170 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); 4170 greaterThanOrEqualTo(unlinkedUnits[0].references.length));
4171 } 4171 }
4172 4172
4173 test_variable_propagated_type_omit_dynamic() { 4173 test_variable_propagated_type_omit_dynamic() {
4174 if (skipFullyLinkedData) { 4174 if (skipFullyLinkedData) {
4175 return; 4175 return;
4176 } 4176 }
4177 UnlinkedVariable v = serializeVariableText('final v = <int, dynamic>{};'); 4177 UnlinkedVariable v = serializeVariableText('final v = <int, dynamic>{};');
4178 TypeRef type = getTypeRefForSlot(v.propagatedTypeSlot); 4178 EntityRef type = getTypeRefForSlot(v.propagatedTypeSlot);
4179 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', 4179 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map',
4180 allowTypeParameters: true, numTypeParameters: 2); 4180 allowTypeParameters: true, numTypeParameters: 2);
4181 expect(type.typeArguments, hasLength(1)); 4181 expect(type.typeArguments, hasLength(1));
4182 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int'); 4182 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int');
4183 } 4183 }
4184 4184
4185 test_variable_propagatedTypeSlot_const() { 4185 test_variable_propagatedTypeSlot_const() {
4186 // Const variables are propagable so they have a nonzero 4186 // Const variables are propagable so they have a nonzero
4187 // propagatedTypeSlot. 4187 // propagatedTypeSlot.
4188 UnlinkedVariable variable = serializeVariableText('const v = 0;'); 4188 UnlinkedVariable variable = serializeVariableText('const v = 0;');
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4226 expect(constExpr.operations, operators); 4226 expect(constExpr.operations, operators);
4227 expect(constExpr.ints, ints); 4227 expect(constExpr.ints, ints);
4228 expect(constExpr.doubles, doubles); 4228 expect(constExpr.doubles, doubles);
4229 expect(constExpr.strings, strings); 4229 expect(constExpr.strings, strings);
4230 expect(constExpr.references, hasLength(referenceValidators.length)); 4230 expect(constExpr.references, hasLength(referenceValidators.length));
4231 for (int i = 0; i < referenceValidators.length; i++) { 4231 for (int i = 0; i < referenceValidators.length; i++) {
4232 referenceValidators[i](constExpr.references[i]); 4232 referenceValidators[i](constExpr.references[i]);
4233 } 4233 }
4234 } 4234 }
4235 } 4235 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | pkg/analyzer/tool/summary/idl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698