| OLD | NEW |
| 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 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 test_class_concrete() { | 1059 test_class_concrete() { |
| 1060 UnlinkedClass cls = serializeClassText('class C {}'); | 1060 UnlinkedClass cls = serializeClassText('class C {}'); |
| 1061 expect(cls.isAbstract, false); | 1061 expect(cls.isAbstract, false); |
| 1062 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 1062 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 1063 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 1063 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 1064 ReferenceKind.classOrEnum); | 1064 ReferenceKind.classOrEnum); |
| 1065 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); | 1065 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); |
| 1066 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); | 1066 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); |
| 1067 } | 1067 } |
| 1068 | 1068 |
| 1069 test_class_documented() { | 1069 test_class_constMembers() { |
| 1070 String text = ''' | |
| 1071 // Extra comment so doc comment offset != 0 | |
| 1072 /** | |
| 1073 * Docs | |
| 1074 */ | |
| 1075 class C {}'''; | |
| 1076 UnlinkedClass cls = serializeClassText(text); | |
| 1077 expect(cls.documentationComment, isNotNull); | |
| 1078 checkDocumentationComment(cls.documentationComment, text); | |
| 1079 } | |
| 1080 | |
| 1081 test_class_documented_with_references() { | |
| 1082 String text = ''' | |
| 1083 // Extra comment so doc comment offset != 0 | |
| 1084 /** | |
| 1085 * Docs referring to [D] and [E] | |
| 1086 */ | |
| 1087 class C {} | |
| 1088 | |
| 1089 class D {} | |
| 1090 class E {}'''; | |
| 1091 UnlinkedClass cls = serializeClassText(text); | |
| 1092 expect(cls.documentationComment, isNotNull); | |
| 1093 checkDocumentationComment(cls.documentationComment, text); | |
| 1094 } | |
| 1095 | |
| 1096 test_class_documented_with_with_windows_line_endings() { | |
| 1097 String text = '/**\r\n * Docs\r\n */\r\nclass C {}'; | |
| 1098 UnlinkedClass cls = serializeClassText(text); | |
| 1099 expect(cls.documentationComment, isNotNull); | |
| 1100 checkDocumentationComment(cls.documentationComment, text); | |
| 1101 } | |
| 1102 | |
| 1103 test_class_executables() { | |
| 1104 UnlinkedClass cls = serializeClassText(''' | 1070 UnlinkedClass cls = serializeClassText(''' |
| 1105 class C { | 1071 class C { |
| 1072 int fieldInstance = 0; |
| 1073 final int fieldInstanceFinal = 0; |
| 1074 static int fieldStatic = 0; |
| 1075 static final int fieldStaticFinal = 0; |
| 1076 static const int fieldStaticConst = 0; |
| 1077 static const int _fieldStaticConstPrivate = 0; |
| 1106 static void methodStaticPublic() {} | 1078 static void methodStaticPublic() {} |
| 1107 static void _methodStaticPrivate() {} | 1079 static void _methodStaticPrivate() {} |
| 1108 C(); | 1080 C(); |
| 1109 C.constructorNamedPublic(); | 1081 C.constructorNamedPublic(); |
| 1110 C._constructorNamedPrivate(); | 1082 C._constructorNamedPrivate(); |
| 1111 void methodInstancePublic() {} | 1083 void methodInstancePublic() {} |
| 1112 C operator+(C c) => null; | 1084 C operator+(C c) => null; |
| 1113 } | 1085 } |
| 1114 '''); | 1086 '''); |
| 1115 expect(cls.isAbstract, false); | 1087 expect(cls.isAbstract, false); |
| 1116 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 1088 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 1117 UnlinkedPublicName className = unlinkedUnits[0].publicNamespace.names[0]; | 1089 UnlinkedPublicName className = unlinkedUnits[0].publicNamespace.names[0]; |
| 1118 expect(className.kind, ReferenceKind.classOrEnum); | 1090 expect(className.kind, ReferenceKind.classOrEnum); |
| 1119 expect(className.name, 'C'); | 1091 expect(className.name, 'C'); |
| 1120 expect(className.numTypeParameters, 0); | 1092 expect(className.numTypeParameters, 0); |
| 1121 // executables | 1093 // executables |
| 1122 Map<String, UnlinkedPublicName> executablesMap = | 1094 Map<String, UnlinkedPublicName> executablesMap = |
| 1123 <String, UnlinkedPublicName>{}; | 1095 <String, UnlinkedPublicName>{}; |
| 1124 className.executables.forEach((e) => executablesMap[e.name] = e); | 1096 className.constMembers.forEach((e) => executablesMap[e.name] = e); |
| 1125 expect(executablesMap, hasLength(3)); | 1097 expect(executablesMap, hasLength(4)); |
| 1098 { |
| 1099 UnlinkedPublicName executable = executablesMap['fieldStaticConst']; |
| 1100 expect(executable.kind, ReferenceKind.constField); |
| 1101 expect(executable.constMembers, isEmpty); |
| 1102 } |
| 1126 { | 1103 { |
| 1127 UnlinkedPublicName executable = executablesMap['methodStaticPublic']; | 1104 UnlinkedPublicName executable = executablesMap['methodStaticPublic']; |
| 1128 expect(executable.kind, ReferenceKind.staticMethod); | 1105 expect(executable.kind, ReferenceKind.staticMethod); |
| 1129 expect(executable.executables, isEmpty); | 1106 expect(executable.constMembers, isEmpty); |
| 1130 } | 1107 } |
| 1131 { | 1108 { |
| 1132 UnlinkedPublicName executable = executablesMap['']; | 1109 UnlinkedPublicName executable = executablesMap['']; |
| 1133 expect(executable.kind, ReferenceKind.constructor); | 1110 expect(executable.kind, ReferenceKind.constructor); |
| 1134 expect(executable.executables, isEmpty); | 1111 expect(executable.constMembers, isEmpty); |
| 1135 } | 1112 } |
| 1136 { | 1113 { |
| 1137 UnlinkedPublicName executable = executablesMap['constructorNamedPublic']; | 1114 UnlinkedPublicName executable = executablesMap['constructorNamedPublic']; |
| 1138 expect(executable.kind, ReferenceKind.constructor); | 1115 expect(executable.kind, ReferenceKind.constructor); |
| 1139 expect(executable.executables, isEmpty); | 1116 expect(executable.constMembers, isEmpty); |
| 1140 } | 1117 } |
| 1141 } | 1118 } |
| 1142 | 1119 |
| 1120 test_class_documented() { |
| 1121 String text = ''' |
| 1122 // Extra comment so doc comment offset != 0 |
| 1123 /** |
| 1124 * Docs |
| 1125 */ |
| 1126 class C {}'''; |
| 1127 UnlinkedClass cls = serializeClassText(text); |
| 1128 expect(cls.documentationComment, isNotNull); |
| 1129 checkDocumentationComment(cls.documentationComment, text); |
| 1130 } |
| 1131 |
| 1132 test_class_documented_with_references() { |
| 1133 String text = ''' |
| 1134 // Extra comment so doc comment offset != 0 |
| 1135 /** |
| 1136 * Docs referring to [D] and [E] |
| 1137 */ |
| 1138 class C {} |
| 1139 |
| 1140 class D {} |
| 1141 class E {}'''; |
| 1142 UnlinkedClass cls = serializeClassText(text); |
| 1143 expect(cls.documentationComment, isNotNull); |
| 1144 checkDocumentationComment(cls.documentationComment, text); |
| 1145 } |
| 1146 |
| 1147 test_class_documented_with_with_windows_line_endings() { |
| 1148 String text = '/**\r\n * Docs\r\n */\r\nclass C {}'; |
| 1149 UnlinkedClass cls = serializeClassText(text); |
| 1150 expect(cls.documentationComment, isNotNull); |
| 1151 checkDocumentationComment(cls.documentationComment, text); |
| 1152 } |
| 1153 |
| 1143 test_class_interface() { | 1154 test_class_interface() { |
| 1144 UnlinkedClass cls = serializeClassText(''' | 1155 UnlinkedClass cls = serializeClassText(''' |
| 1145 class C implements D {} | 1156 class C implements D {} |
| 1146 class D {} | 1157 class D {} |
| 1147 '''); | 1158 '''); |
| 1148 expect(cls.interfaces, hasLength(1)); | 1159 expect(cls.interfaces, hasLength(1)); |
| 1149 checkTypeRef(cls.interfaces[0], null, null, 'D'); | 1160 checkTypeRef(cls.interfaces[0], null, null, 'D'); |
| 1150 } | 1161 } |
| 1151 | 1162 |
| 1152 test_class_interface_order() { | 1163 test_class_interface_order() { |
| (...skipping 3519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4672 */ | 4683 */ |
| 4673 class _PrefixExpectation { | 4684 class _PrefixExpectation { |
| 4674 final ReferenceKind kind; | 4685 final ReferenceKind kind; |
| 4675 final String name; | 4686 final String name; |
| 4676 final bool inLibraryDefiningUnit; | 4687 final bool inLibraryDefiningUnit; |
| 4677 final int numTypeParameters; | 4688 final int numTypeParameters; |
| 4678 | 4689 |
| 4679 _PrefixExpectation(this.kind, this.name, | 4690 _PrefixExpectation(this.kind, this.name, |
| 4680 {this.inLibraryDefiningUnit: false, this.numTypeParameters: 0}); | 4691 {this.inLibraryDefiningUnit: false, this.numTypeParameters: 0}); |
| 4681 } | 4692 } |
| OLD | NEW |