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

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

Issue 1543403002: Create a section of the summary for public namespace information. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 12 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_test; 5 library analyzer.test.src.summary.summary_test;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/src/generated/engine.dart'; 8 import 'package:analyzer/src/generated/engine.dart';
9 import 'package:analyzer/src/generated/java_engine_io.dart'; 9 import 'package:analyzer/src/generated/java_engine_io.dart';
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 485
486 /** 486 /**
487 * Serialize a type declaration using the given [text] as a type name, and 487 * Serialize a type declaration using the given [text] as a type name, and
488 * return a summary of the corresponding [UnlinkedTypeRef]. If the type 488 * return a summary of the corresponding [UnlinkedTypeRef]. If the type
489 * declaration needs to refer to types that are not available in core, those 489 * declaration needs to refer to types that are not available in core, those
490 * types may be declared in [otherDeclarations]. 490 * types may be declared in [otherDeclarations].
491 */ 491 */
492 UnlinkedTypeRef serializeTypeText(String text, 492 UnlinkedTypeRef serializeTypeText(String text,
493 {String otherDeclarations: '', bool allowErrors: false}) { 493 {String otherDeclarations: '', bool allowErrors: false}) {
494 return serializeVariableText('$otherDeclarations\n$text v;', 494 return serializeVariableText('$otherDeclarations\n$text v;',
495 allowErrors: allowErrors) 495 allowErrors: allowErrors).type;
496 .type;
497 } 496 }
498 497
499 /** 498 /**
500 * Serialize the given library [text] and return the summary of the variable 499 * Serialize the given library [text] and return the summary of the variable
501 * with the given [variableName]. 500 * with the given [variableName].
502 */ 501 */
503 UnlinkedVariable serializeVariableText(String text, 502 UnlinkedVariable serializeVariableText(String text,
504 {String variableName: 'v', bool allowErrors: false}) { 503 {String variableName: 'v', bool allowErrors: false}) {
505 serializeLibraryText(text, allowErrors: allowErrors); 504 serializeLibraryText(text, allowErrors: allowErrors);
506 return findVariable(variableName, failIfAbsent: true); 505 return findVariable(variableName, failIfAbsent: true);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 } 639 }
641 640
642 test_class_alias_abstract() { 641 test_class_alias_abstract() {
643 UnlinkedClass cls = serializeClassText( 642 UnlinkedClass cls = serializeClassText(
644 'abstract class C = D with E; class D {} class E {}'); 643 'abstract class C = D with E; class D {} class E {}');
645 expect(cls.isAbstract, true); 644 expect(cls.isAbstract, true);
646 } 645 }
647 646
648 test_class_alias_concrete() { 647 test_class_alias_concrete() {
649 UnlinkedClass cls = 648 UnlinkedClass cls =
650 serializeClassText('class C = D with E; class D {} class E {}'); 649 serializeClassText('class C = _D with _E; class _D {} class _E {}');
651 expect(cls.isAbstract, false); 650 expect(cls.isAbstract, false);
651 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
652 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
653 PrelinkedReferenceKind.classOrEnum);
654 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C');
652 } 655 }
653 656
654 test_class_alias_flag() { 657 test_class_alias_flag() {
655 UnlinkedClass cls = 658 UnlinkedClass cls =
656 serializeClassText('class C = D with E; class D {} class E {}'); 659 serializeClassText('class C = D with E; class D {} class E {}');
657 expect(cls.isMixinApplication, true); 660 expect(cls.isMixinApplication, true);
658 } 661 }
659 662
660 test_class_alias_mixin_order() { 663 test_class_alias_mixin_order() {
661 UnlinkedClass cls = serializeClassText(''' 664 UnlinkedClass cls = serializeClassText('''
(...skipping 12 matching lines...) Expand all
674 class C = D with E; 677 class C = D with E;
675 class D { 678 class D {
676 D.foo(); 679 D.foo();
677 D.bar(); 680 D.bar();
678 } 681 }
679 class E {} 682 class E {}
680 '''); 683 ''');
681 expect(cls.executables, isEmpty); 684 expect(cls.executables, isEmpty);
682 } 685 }
683 686
687 test_class_alias_private() {
688 serializeClassText('class _C = _D with _E; class _D {} class _E {}', '_C');
689 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
690 }
691
684 test_class_alias_supertype() { 692 test_class_alias_supertype() {
685 UnlinkedClass cls = 693 UnlinkedClass cls =
686 serializeClassText('class C = D with E; class D {} class E {}'); 694 serializeClassText('class C = D with E; class D {} class E {}');
687 checkTypeRef(cls.supertype, null, null, 'D'); 695 checkTypeRef(cls.supertype, null, null, 'D');
688 expect(cls.hasNoSupertype, isFalse); 696 expect(cls.hasNoSupertype, isFalse);
689 } 697 }
690 698
691 test_class_concrete() { 699 test_class_concrete() {
692 UnlinkedClass cls = serializeClassText('class C {}'); 700 UnlinkedClass cls = serializeClassText('class C {}');
693 expect(cls.isAbstract, false); 701 expect(cls.isAbstract, false);
702 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
703 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
704 PrelinkedReferenceKind.classOrEnum);
705 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C');
694 } 706 }
695 707
696 test_class_interface() { 708 test_class_interface() {
697 UnlinkedClass cls = serializeClassText(''' 709 UnlinkedClass cls = serializeClassText('''
698 class C implements D {} 710 class C implements D {}
699 class D {} 711 class D {}
700 '''); 712 ''');
701 expect(cls.interfaces, hasLength(1)); 713 expect(cls.interfaces, hasLength(1));
702 checkTypeRef(cls.interfaces[0], null, null, 'D'); 714 checkTypeRef(cls.interfaces[0], null, null, 'D');
703 } 715 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 test_class_no_type_param() { 770 test_class_no_type_param() {
759 UnlinkedClass cls = serializeClassText('class C {}'); 771 UnlinkedClass cls = serializeClassText('class C {}');
760 expect(cls.typeParameters, isEmpty); 772 expect(cls.typeParameters, isEmpty);
761 } 773 }
762 774
763 test_class_non_alias_flag() { 775 test_class_non_alias_flag() {
764 UnlinkedClass cls = serializeClassText('class C {}'); 776 UnlinkedClass cls = serializeClassText('class C {}');
765 expect(cls.isMixinApplication, false); 777 expect(cls.isMixinApplication, false);
766 } 778 }
767 779
780 test_class_private() {
781 serializeClassText('class _C {}', '_C');
782 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
783 }
784
768 test_class_superclass() { 785 test_class_superclass() {
769 UnlinkedClass cls = serializeClassText('class C {}'); 786 UnlinkedClass cls = serializeClassText('class C {}');
770 expect(cls.supertype, isNull); 787 expect(cls.supertype, isNull);
771 expect(cls.hasNoSupertype, isFalse); 788 expect(cls.hasNoSupertype, isFalse);
772 } 789 }
773 790
774 test_class_superclass_explicit() { 791 test_class_superclass_explicit() {
775 UnlinkedClass cls = serializeClassText('class C extends D {} class D {}'); 792 UnlinkedClass cls = serializeClassText('class C extends D {} class D {}');
776 expect(cls.supertype, isNotNull); 793 expect(cls.supertype, isNotNull);
777 checkTypeRef(cls.supertype, null, null, 'D'); 794 checkTypeRef(cls.supertype, null, null, 'D');
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 expect(findVariable('v', variables: unit.variables), isNotNull); 1149 expect(findVariable('v', variables: unit.variables), isNotNull);
1133 expect(findExecutable('f', executables: unit.executables), isNotNull); 1150 expect(findExecutable('f', executables: unit.executables), isNotNull);
1134 expect(findTypedef('F', unit: unit), isNotNull); 1151 expect(findTypedef('F', unit: unit), isNotNull);
1135 } 1152 }
1136 1153
1137 test_enum() { 1154 test_enum() {
1138 UnlinkedEnum e = serializeEnumText('enum E { v1 }'); 1155 UnlinkedEnum e = serializeEnumText('enum E { v1 }');
1139 expect(e.name, 'E'); 1156 expect(e.name, 'E');
1140 expect(e.values, hasLength(1)); 1157 expect(e.values, hasLength(1));
1141 expect(e.values[0].name, 'v1'); 1158 expect(e.values[0].name, 'v1');
1159 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
1160 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
1161 PrelinkedReferenceKind.classOrEnum);
1162 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'E');
1142 } 1163 }
1143 1164
1144 test_enum_order() { 1165 test_enum_order() {
1145 UnlinkedEnum e = serializeEnumText('enum E { v1, v2 }'); 1166 UnlinkedEnum e = serializeEnumText('enum E { v1, v2 }');
1146 expect(e.values, hasLength(2)); 1167 expect(e.values, hasLength(2));
1147 expect(e.values[0].name, 'v1'); 1168 expect(e.values[0].name, 'v1');
1148 expect(e.values[1].name, 'v2'); 1169 expect(e.values[1].name, 'v2');
1149 } 1170 }
1150 1171
1172 test_enum_private() {
1173 serializeEnumText('enum _E { v1 }', '_E');
1174 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
1175 }
1176
1151 test_executable_abstract() { 1177 test_executable_abstract() {
1152 UnlinkedExecutable executable = 1178 UnlinkedExecutable executable =
1153 serializeClassText('abstract class C { f(); }').executables[0]; 1179 serializeClassText('abstract class C { f(); }').executables[0];
1154 expect(executable.isAbstract, isTrue); 1180 expect(executable.isAbstract, isTrue);
1155 } 1181 }
1156 1182
1157 test_executable_concrete() { 1183 test_executable_concrete() {
1158 UnlinkedExecutable executable = 1184 UnlinkedExecutable executable =
1159 serializeClassText('abstract class C { f() {} }').executables[0]; 1185 serializeClassText('abstract class C { f() {} }').executables[0];
1160 expect(executable.isAbstract, isFalse); 1186 expect(executable.isAbstract, isFalse);
1161 } 1187 }
1162 1188
1163 test_executable_function() { 1189 test_executable_function() {
1164 UnlinkedExecutable executable = serializeExecutableText('f() {}'); 1190 UnlinkedExecutable executable = serializeExecutableText('f() {}');
1165 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); 1191 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod);
1166 expect(executable.hasImplicitReturnType, isTrue); 1192 expect(executable.hasImplicitReturnType, isTrue);
1167 checkDynamicTypeRef(executable.returnType); 1193 checkDynamicTypeRef(executable.returnType);
1168 expect(executable.isExternal, isFalse); 1194 expect(executable.isExternal, isFalse);
1195 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
1196 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
1197 PrelinkedReferenceKind.other);
1198 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f');
1169 } 1199 }
1170 1200
1171 test_executable_function_explicit_return() { 1201 test_executable_function_explicit_return() {
1172 UnlinkedExecutable executable = 1202 UnlinkedExecutable executable =
1173 serializeExecutableText('dynamic f() => null;'); 1203 serializeExecutableText('dynamic f() => null;');
1174 expect(executable.hasImplicitReturnType, isFalse); 1204 expect(executable.hasImplicitReturnType, isFalse);
1175 checkDynamicTypeRef(executable.returnType); 1205 checkDynamicTypeRef(executable.returnType);
1176 } 1206 }
1177 1207
1178 test_executable_function_external() { 1208 test_executable_function_external() {
1179 UnlinkedExecutable executable = serializeExecutableText('external f();'); 1209 UnlinkedExecutable executable = serializeExecutableText('external f();');
1180 expect(executable.isExternal, isTrue); 1210 expect(executable.isExternal, isTrue);
1181 } 1211 }
1182 1212
1213 test_executable_function_private() {
1214 serializeExecutableText('_f() {}', '_f');
1215 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
1216 }
1217
1183 test_executable_getter() { 1218 test_executable_getter() {
1184 UnlinkedExecutable executable = serializeExecutableText('int get f => 1;'); 1219 UnlinkedExecutable executable = serializeExecutableText('int get f => 1;');
1185 expect(executable.kind, UnlinkedExecutableKind.getter); 1220 expect(executable.kind, UnlinkedExecutableKind.getter);
1186 expect(executable.hasImplicitReturnType, isFalse); 1221 expect(executable.hasImplicitReturnType, isFalse);
1187 expect(executable.isExternal, isFalse); 1222 expect(executable.isExternal, isFalse);
1188 expect(findVariable('f'), isNull); 1223 expect(findVariable('f'), isNull);
1189 expect(findExecutable('f='), isNull); 1224 expect(findExecutable('f='), isNull);
1225 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
1226 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
1227 PrelinkedReferenceKind.other);
1228 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f');
1190 } 1229 }
1191 1230
1192 test_executable_getter_external() { 1231 test_executable_getter_external() {
1193 UnlinkedExecutable executable = 1232 UnlinkedExecutable executable =
1194 serializeExecutableText('external int get f;'); 1233 serializeExecutableText('external int get f;');
1195 expect(executable.isExternal, isTrue); 1234 expect(executable.isExternal, isTrue);
1196 } 1235 }
1197 1236
1237 test_executable_getter_private() {
1238 serializeExecutableText('int get _f => 1;', '_f');
1239 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
1240 }
1241
1198 test_executable_getter_type() { 1242 test_executable_getter_type() {
1199 UnlinkedExecutable executable = serializeExecutableText('int get f => 1;'); 1243 UnlinkedExecutable executable = serializeExecutableText('int get f => 1;');
1200 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'int'); 1244 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'int');
1201 expect(executable.parameters, isEmpty); 1245 expect(executable.parameters, isEmpty);
1202 } 1246 }
1203 1247
1204 test_executable_getter_type_implicit() { 1248 test_executable_getter_type_implicit() {
1205 UnlinkedExecutable executable = serializeExecutableText('get f => 1;'); 1249 UnlinkedExecutable executable = serializeExecutableText('get f => 1;');
1206 checkDynamicTypeRef(executable.returnType); 1250 checkDynamicTypeRef(executable.returnType);
1207 expect(executable.hasImplicitReturnType, isTrue); 1251 expect(executable.hasImplicitReturnType, isTrue);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 expect(executable.isConst, false); 1394 expect(executable.isConst, false);
1351 expect(executable.isFactory, false); 1395 expect(executable.isFactory, false);
1352 expect(executable.isStatic, false); 1396 expect(executable.isStatic, false);
1353 expect(executable.parameters, hasLength(1)); 1397 expect(executable.parameters, hasLength(1));
1354 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'bool'); 1398 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'bool');
1355 expect(executable.typeParameters, isEmpty); 1399 expect(executable.typeParameters, isEmpty);
1356 } 1400 }
1357 1401
1358 test_executable_operator_index_set() { 1402 test_executable_operator_index_set() {
1359 UnlinkedExecutable executable = serializeClassText( 1403 UnlinkedExecutable executable = serializeClassText(
1360 'class C { void operator[]=(int i, bool v) => null; }') 1404 'class C { void operator[]=(int i, bool v) => null; }').executables[0];
1361 .executables[0];
1362 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); 1405 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod);
1363 expect(executable.name, '[]='); 1406 expect(executable.name, '[]=');
1364 expect(executable.hasImplicitReturnType, false); 1407 expect(executable.hasImplicitReturnType, false);
1365 expect(executable.isAbstract, false); 1408 expect(executable.isAbstract, false);
1366 expect(executable.isConst, false); 1409 expect(executable.isConst, false);
1367 expect(executable.isFactory, false); 1410 expect(executable.isFactory, false);
1368 expect(executable.isStatic, false); 1411 expect(executable.isStatic, false);
1369 expect(executable.parameters, hasLength(2)); 1412 expect(executable.parameters, hasLength(2));
1370 expect(executable.returnType, isNull); 1413 expect(executable.returnType, isNull);
1371 expect(executable.typeParameters, isEmpty); 1414 expect(executable.typeParameters, isEmpty);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 } 1543 }
1501 1544
1502 test_executable_setter() { 1545 test_executable_setter() {
1503 UnlinkedExecutable executable = 1546 UnlinkedExecutable executable =
1504 serializeExecutableText('void set f(value) {}', 'f='); 1547 serializeExecutableText('void set f(value) {}', 'f=');
1505 expect(executable.kind, UnlinkedExecutableKind.setter); 1548 expect(executable.kind, UnlinkedExecutableKind.setter);
1506 expect(executable.hasImplicitReturnType, isFalse); 1549 expect(executable.hasImplicitReturnType, isFalse);
1507 expect(executable.isExternal, isFalse); 1550 expect(executable.isExternal, isFalse);
1508 expect(findVariable('f'), isNull); 1551 expect(findVariable('f'), isNull);
1509 expect(findExecutable('f'), isNull); 1552 expect(findExecutable('f'), isNull);
1553 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
1554 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
1555 PrelinkedReferenceKind.other);
1556 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f=');
1510 } 1557 }
1511 1558
1512 test_executable_setter_external() { 1559 test_executable_setter_external() {
1513 UnlinkedExecutable executable = 1560 UnlinkedExecutable executable =
1514 serializeExecutableText('external void set f(value);', 'f='); 1561 serializeExecutableText('external void set f(value);', 'f=');
1515 expect(executable.isExternal, isTrue); 1562 expect(executable.isExternal, isTrue);
1516 } 1563 }
1517 1564
1518 test_executable_setter_implicit_return() { 1565 test_executable_setter_implicit_return() {
1519 UnlinkedExecutable executable = 1566 UnlinkedExecutable executable =
1520 serializeExecutableText('set f(value) {}', 'f='); 1567 serializeExecutableText('set f(value) {}', 'f=');
1521 // For setters, hasImplicitReturnType is always false. 1568 // For setters, hasImplicitReturnType is always false.
1522 expect(executable.hasImplicitReturnType, isFalse); 1569 expect(executable.hasImplicitReturnType, isFalse);
1523 checkDynamicTypeRef(executable.returnType); 1570 checkDynamicTypeRef(executable.returnType);
1524 } 1571 }
1525 1572
1573 test_executable_setter_private() {
1574 serializeExecutableText('void set _f(value) {}', '_f=');
1575 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
1576 }
1577
1526 test_executable_setter_type() { 1578 test_executable_setter_type() {
1527 UnlinkedExecutable executable = 1579 UnlinkedExecutable executable =
1528 serializeExecutableText('void set f(int value) {}', 'f='); 1580 serializeExecutableText('void set f(int value) {}', 'f=');
1529 expect(executable.returnType, isNull); 1581 expect(executable.returnType, isNull);
1530 expect(executable.parameters, hasLength(1)); 1582 expect(executable.parameters, hasLength(1));
1531 expect(executable.parameters[0].name, 'value'); 1583 expect(executable.parameters[0].name, 'value');
1532 checkTypeRef( 1584 checkTypeRef(
1533 executable.parameters[0].type, 'dart:core', 'dart:core', 'int'); 1585 executable.parameters[0].type, 'dart:core', 'dart:core', 'int');
1534 } 1586 }
1535 1587
(...skipping 26 matching lines...) Expand all
1562 } 1614 }
1563 1615
1564 test_executable_type_param_in_return_type() { 1616 test_executable_type_param_in_return_type() {
1565 // TODO(paulberry): also test top level executables. 1617 // TODO(paulberry): also test top level executables.
1566 UnlinkedExecutable ex = serializeMethodText('T f<T>() => null;'); 1618 UnlinkedExecutable ex = serializeMethodText('T f<T>() => null;');
1567 checkParamTypeRef(ex.returnType, 1); 1619 checkParamTypeRef(ex.returnType, 1);
1568 } 1620 }
1569 1621
1570 test_export_hide_order() { 1622 test_export_hide_order() {
1571 serializeLibraryText('export "dart:async" hide Future, Stream;'); 1623 serializeLibraryText('export "dart:async" hide Future, Stream;');
1572 expect(unlinkedUnits[0].exports, hasLength(1)); 1624 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1));
1573 expect(unlinkedUnits[0].exports[0].combinators, hasLength(1)); 1625 expect(
1574 expect(unlinkedUnits[0].exports[0].combinators[0].shows, isEmpty); 1626 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1));
1575 expect(unlinkedUnits[0].exports[0].combinators[0].hides, hasLength(2)); 1627 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows,
1628 isEmpty);
1629 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides,
1630 hasLength(2));
1576 checkCombinatorName( 1631 checkCombinatorName(
1577 unlinkedUnits[0].exports[0].combinators[0].hides[0], 'Future'); 1632 unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides[0],
1633 'Future');
1578 checkCombinatorName( 1634 checkCombinatorName(
1579 unlinkedUnits[0].exports[0].combinators[0].hides[1], 'Stream'); 1635 unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides[1],
1636 'Stream');
1580 } 1637 }
1581 1638
1582 test_export_no_combinators() { 1639 test_export_no_combinators() {
1583 serializeLibraryText('export "dart:async";'); 1640 serializeLibraryText('export "dart:async";');
1584 expect(unlinkedUnits[0].exports, hasLength(1)); 1641 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1));
1585 expect(unlinkedUnits[0].exports[0].combinators, isEmpty); 1642 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators, isEmpty);
1586 } 1643 }
1587 1644
1588 test_export_show_order() { 1645 test_export_show_order() {
1589 serializeLibraryText('export "dart:async" show Future, Stream;'); 1646 serializeLibraryText('export "dart:async" show Future, Stream;');
1590 expect(unlinkedUnits[0].exports, hasLength(1)); 1647 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1));
1591 expect(unlinkedUnits[0].exports[0].combinators, hasLength(1)); 1648 expect(
1592 expect(unlinkedUnits[0].exports[0].combinators[0].shows, hasLength(2)); 1649 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1));
1593 expect(unlinkedUnits[0].exports[0].combinators[0].hides, isEmpty); 1650 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows,
1651 hasLength(2));
1652 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides,
1653 isEmpty);
1594 checkCombinatorName( 1654 checkCombinatorName(
1595 unlinkedUnits[0].exports[0].combinators[0].shows[0], 'Future'); 1655 unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[0],
1656 'Future');
1596 checkCombinatorName( 1657 checkCombinatorName(
1597 unlinkedUnits[0].exports[0].combinators[0].shows[1], 'Stream'); 1658 unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[1],
1659 'Stream');
1598 } 1660 }
1599 1661
1600 test_export_uri() { 1662 test_export_uri() {
1601 addNamedSource('/a.dart', 'library my.lib;'); 1663 addNamedSource('/a.dart', 'library my.lib;');
1602 String uriString = '"a.dart"'; 1664 String uriString = '"a.dart"';
1603 String libraryText = 'export $uriString;'; 1665 String libraryText = 'export $uriString;';
1604 serializeLibraryText(libraryText); 1666 serializeLibraryText(libraryText);
1605 expect(unlinkedUnits[0].exports, hasLength(1)); 1667 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1));
1606 expect(unlinkedUnits[0].exports[0].uri, 'a.dart'); 1668 expect(unlinkedUnits[0].publicNamespace.exports[0].uri, 'a.dart');
1607 } 1669 }
1608 1670
1609 test_field() { 1671 test_field() {
1610 UnlinkedClass cls = serializeClassText('class C { int i; }'); 1672 UnlinkedClass cls = serializeClassText('class C { int i; }');
1611 UnlinkedVariable variable = findVariable('i', variables: cls.fields); 1673 UnlinkedVariable variable = findVariable('i', variables: cls.fields);
1612 expect(variable, isNotNull); 1674 expect(variable, isNotNull);
1613 expect(variable.isConst, isFalse); 1675 expect(variable.isConst, isFalse);
1614 expect(variable.isStatic, isFalse); 1676 expect(variable.isStatic, isFalse);
1615 expect(variable.isFinal, isFalse); 1677 expect(variable.isFinal, isFalse);
1616 expect(findExecutable('i', executables: cls.executables), isNull); 1678 expect(findExecutable('i', executables: cls.executables), isNull);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 checkPrefix(unlinkedUnits[0].imports[0].prefixReference, 'a'); 1801 checkPrefix(unlinkedUnits[0].imports[0].prefixReference, 'a');
1740 } 1802 }
1741 1803
1742 test_import_prefix_none() { 1804 test_import_prefix_none() {
1743 serializeLibraryText('import "dart:async"; Future x;'); 1805 serializeLibraryText('import "dart:async"; Future x;');
1744 // Second import is the implicit import of dart:core 1806 // Second import is the implicit import of dart:core
1745 expect(unlinkedUnits[0].imports, hasLength(2)); 1807 expect(unlinkedUnits[0].imports, hasLength(2));
1746 expect(unlinkedUnits[0].imports[0].prefixReference, 0); 1808 expect(unlinkedUnits[0].imports[0].prefixReference, 0);
1747 } 1809 }
1748 1810
1811 test_import_prefix_not_in_public_namespace() {
1812 serializeLibraryText('import "dart:async" as a; a.Future v;');
1813 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2));
1814 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'v');
1815 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'v=');
1816 }
1817
1749 test_import_prefix_reference() { 1818 test_import_prefix_reference() {
1750 UnlinkedVariable variable = 1819 UnlinkedVariable variable =
1751 serializeVariableText('import "dart:async" as a; a.Future v;'); 1820 serializeVariableText('import "dart:async" as a; a.Future v;');
1752 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', 1821 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future',
1753 expectedPrefix: 'a'); 1822 expectedPrefix: 'a');
1754 } 1823 }
1755 1824
1756 test_import_reference() { 1825 test_import_reference() {
1757 UnlinkedVariable variable = 1826 UnlinkedVariable variable =
1758 serializeVariableText('import "dart:async"; Future v;'); 1827 serializeVariableText('import "dart:async"; Future v;');
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 } 1885 }
1817 1886
1818 test_library_unnamed() { 1887 test_library_unnamed() {
1819 serializeLibraryText(''); 1888 serializeLibraryText('');
1820 expect(unlinkedUnits[0].libraryName, isEmpty); 1889 expect(unlinkedUnits[0].libraryName, isEmpty);
1821 } 1890 }
1822 1891
1823 test_parts_defining_compilation_unit() { 1892 test_parts_defining_compilation_unit() {
1824 serializeLibraryText(''); 1893 serializeLibraryText('');
1825 expect(prelinked.units, hasLength(1)); 1894 expect(prelinked.units, hasLength(1));
1826 expect(unlinkedUnits[0].parts, isEmpty); 1895 expect(unlinkedUnits[0].publicNamespace.parts, isEmpty);
1827 } 1896 }
1828 1897
1829 test_parts_included() { 1898 test_parts_included() {
1830 addNamedSource('/part1.dart', 'part of my.lib;'); 1899 addNamedSource('/part1.dart', 'part of my.lib;');
1831 String partString = '"part1.dart"'; 1900 String partString = '"part1.dart"';
1832 String libraryText = 'library my.lib; part $partString;'; 1901 String libraryText = 'library my.lib; part $partString;';
1833 serializeLibraryText(libraryText); 1902 serializeLibraryText(libraryText);
1834 expect(prelinked.units, hasLength(2)); 1903 expect(prelinked.units, hasLength(2));
1835 expect(unlinkedUnits[0].parts, hasLength(1)); 1904 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1));
1836 expect(unlinkedUnits[0].parts[0].uri, 'part1.dart'); 1905 expect(unlinkedUnits[0].publicNamespace.parts[0].uri, 'part1.dart');
1906 }
1907
1908 test_public_namespace_of_part() {
1909 addNamedSource('/a.dart', 'part of foo; class C {}');
1910 serializeLibraryText('library foo; part "a.dart";');
1911 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
1912 expect(unlinkedUnits[1].publicNamespace.names, hasLength(1));
1913 expect(unlinkedUnits[1].publicNamespace.names[0].name, 'C');
1837 } 1914 }
1838 1915
1839 test_type_arguments_explicit() { 1916 test_type_arguments_explicit() {
1840 UnlinkedTypeRef typeRef = serializeTypeText('List<int>'); 1917 UnlinkedTypeRef typeRef = serializeTypeText('List<int>');
1841 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', 1918 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List',
1842 allowTypeParameters: true); 1919 allowTypeParameters: true);
1843 expect(typeRef.typeArguments, hasLength(1)); 1920 expect(typeRef.typeArguments, hasLength(1));
1844 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); 1921 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int');
1845 } 1922 }
1846 1923
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 } 2110 }
2034 2111
2035 test_type_unresolved() { 2112 test_type_unresolved() {
2036 UnlinkedTypeRef typeRef = serializeTypeText('Foo', allowErrors: true); 2113 UnlinkedTypeRef typeRef = serializeTypeText('Foo', allowErrors: true);
2037 checkUnresolvedTypeRef(typeRef, null, 'Foo'); 2114 checkUnresolvedTypeRef(typeRef, null, 'Foo');
2038 } 2115 }
2039 2116
2040 test_typedef_name() { 2117 test_typedef_name() {
2041 UnlinkedTypedef type = serializeTypedefText('typedef F();'); 2118 UnlinkedTypedef type = serializeTypedefText('typedef F();');
2042 expect(type.name, 'F'); 2119 expect(type.name, 'F');
2120 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
2121 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
2122 PrelinkedReferenceKind.typedef);
2123 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'F');
2043 } 2124 }
2044 2125
2045 test_typedef_param_none() { 2126 test_typedef_param_none() {
2046 UnlinkedTypedef type = serializeTypedefText('typedef F();'); 2127 UnlinkedTypedef type = serializeTypedefText('typedef F();');
2047 expect(type.parameters, isEmpty); 2128 expect(type.parameters, isEmpty);
2048 } 2129 }
2049 2130
2050 test_typedef_param_order() { 2131 test_typedef_param_order() {
2051 UnlinkedTypedef type = serializeTypedefText('typedef F(x, y);'); 2132 UnlinkedTypedef type = serializeTypedefText('typedef F(x, y);');
2052 expect(type.parameters, hasLength(2)); 2133 expect(type.parameters, hasLength(2));
2053 expect(type.parameters[0].name, 'x'); 2134 expect(type.parameters[0].name, 'x');
2054 expect(type.parameters[1].name, 'y'); 2135 expect(type.parameters[1].name, 'y');
2055 } 2136 }
2056 2137
2138 test_typedef_private() {
2139 serializeTypedefText('typedef _F();', '_F');
2140 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
2141 }
2142
2057 test_typedef_return_type_explicit() { 2143 test_typedef_return_type_explicit() {
2058 UnlinkedTypedef type = serializeTypedefText('typedef int F();'); 2144 UnlinkedTypedef type = serializeTypedefText('typedef int F();');
2059 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int'); 2145 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int');
2060 } 2146 }
2061 2147
2062 test_typedef_type_param_in_parameter() { 2148 test_typedef_type_param_in_parameter() {
2063 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);'); 2149 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);');
2064 checkParamTypeRef(type.parameters[0].type, 1); 2150 checkParamTypeRef(type.parameters[0].type, 1);
2065 } 2151 }
2066 2152
(...skipping 11 matching lines...) Expand all
2078 UnlinkedTypedef type = serializeTypedefText('typedef F<T, U>();'); 2164 UnlinkedTypedef type = serializeTypedefText('typedef F<T, U>();');
2079 expect(type.typeParameters, hasLength(2)); 2165 expect(type.typeParameters, hasLength(2));
2080 expect(type.typeParameters[0].name, 'T'); 2166 expect(type.typeParameters[0].name, 'T');
2081 expect(type.typeParameters[1].name, 'U'); 2167 expect(type.typeParameters[1].name, 'U');
2082 } 2168 }
2083 2169
2084 test_variable() { 2170 test_variable() {
2085 serializeVariableText('int i;', variableName: 'i'); 2171 serializeVariableText('int i;', variableName: 'i');
2086 expect(findExecutable('i'), isNull); 2172 expect(findExecutable('i'), isNull);
2087 expect(findExecutable('i='), isNull); 2173 expect(findExecutable('i='), isNull);
2174 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2));
2175 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
2176 PrelinkedReferenceKind.other);
2177 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'i');
2178 expect(unlinkedUnits[0].publicNamespace.names[1].kind,
2179 PrelinkedReferenceKind.other);
2180 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'i=');
2088 } 2181 }
2089 2182
2090 test_variable_const() { 2183 test_variable_const() {
2091 UnlinkedVariable variable = 2184 UnlinkedVariable variable =
2092 serializeVariableText('const int i = 0;', variableName: 'i'); 2185 serializeVariableText('const int i = 0;', variableName: 'i');
2093 expect(variable.isConst, isTrue); 2186 expect(variable.isConst, isTrue);
2094 } 2187 }
2095 2188
2096 test_variable_explicit_dynamic() { 2189 test_variable_explicit_dynamic() {
2097 UnlinkedVariable variable = serializeVariableText('dynamic v;'); 2190 UnlinkedVariable variable = serializeVariableText('dynamic v;');
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 UnlinkedVariable variable = 2247 UnlinkedVariable variable =
2155 serializeClassText('class C { static int i; }').fields[0]; 2248 serializeClassText('class C { static int i; }').fields[0];
2156 expect(variable.isStatic, isTrue); 2249 expect(variable.isStatic, isTrue);
2157 } 2250 }
2158 2251
2159 test_variable_type() { 2252 test_variable_type() {
2160 UnlinkedVariable variable = 2253 UnlinkedVariable variable =
2161 serializeVariableText('int i;', variableName: 'i'); 2254 serializeVariableText('int i;', variableName: 'i');
2162 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); 2255 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int');
2163 } 2256 }
2257
2258 test_varible_private() {
2259 serializeVariableText('int _i;', variableName: '_i');
2260 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
2261 }
2164 } 2262 }
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