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

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

Issue 1639533003: Record static constant public fields. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Serialize only constant constructors. 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 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_constMembers() {
1070 UnlinkedClass cls = serializeClassText('''
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;
1078 static void methodStaticPublic() {}
1079 static void _methodStaticPrivate() {}
1080 void methodInstancePublic() {}
1081 C operator+(C c) => null;
1082 }
1083 ''');
1084 expect(cls.isAbstract, false);
1085 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
1086 UnlinkedPublicName className = unlinkedUnits[0].publicNamespace.names[0];
1087 expect(className.kind, ReferenceKind.classOrEnum);
1088 expect(className.name, 'C');
1089 expect(className.numTypeParameters, 0);
1090 // executables
1091 Map<String, UnlinkedPublicName> executablesMap =
1092 <String, UnlinkedPublicName>{};
1093 className.constMembers.forEach((e) => executablesMap[e.name] = e);
1094 expect(executablesMap, hasLength(2));
1095 {
1096 UnlinkedPublicName executable = executablesMap['fieldStaticConst'];
1097 expect(executable.kind, ReferenceKind.constField);
1098 expect(executable.constMembers, isEmpty);
1099 }
1100 {
1101 UnlinkedPublicName executable = executablesMap['methodStaticPublic'];
1102 expect(executable.kind, ReferenceKind.staticMethod);
1103 expect(executable.constMembers, isEmpty);
1104 }
1105 }
1106
1107 test_class_constMembers_constructors() {
1108 UnlinkedClass cls = serializeClassText('''
1109 class C {
1110 const C();
1111 const C.constructorNamedPublicConst();
1112 C.constructorNamedPublic();
1113 C._constructorNamedPrivate();
1114 }
1115 ''');
1116 expect(cls.isAbstract, false);
1117 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
1118 UnlinkedPublicName className = unlinkedUnits[0].publicNamespace.names[0];
1119 expect(className.kind, ReferenceKind.classOrEnum);
1120 expect(className.name, 'C');
1121 expect(className.numTypeParameters, 0);
1122 // executables
1123 Map<String, UnlinkedPublicName> executablesMap =
1124 <String, UnlinkedPublicName>{};
1125 className.constMembers.forEach((e) => executablesMap[e.name] = e);
1126 expect(executablesMap, hasLength(2));
1127 {
1128 UnlinkedPublicName executable = executablesMap[''];
1129 expect(executable.kind, ReferenceKind.constructor);
1130 expect(executable.constMembers, isEmpty);
1131 }
1132 {
1133 UnlinkedPublicName executable =
1134 executablesMap['constructorNamedPublicConst'];
1135 expect(executable.kind, ReferenceKind.constructor);
1136 expect(executable.constMembers, isEmpty);
1137 }
1138 }
1139
1069 test_class_documented() { 1140 test_class_documented() {
1070 String text = ''' 1141 String text = '''
1071 // Extra comment so doc comment offset != 0 1142 // Extra comment so doc comment offset != 0
1072 /** 1143 /**
1073 * Docs 1144 * Docs
1074 */ 1145 */
1075 class C {}'''; 1146 class C {}''';
1076 UnlinkedClass cls = serializeClassText(text); 1147 UnlinkedClass cls = serializeClassText(text);
1077 expect(cls.documentationComment, isNotNull); 1148 expect(cls.documentationComment, isNotNull);
1078 checkDocumentationComment(cls.documentationComment, text); 1149 checkDocumentationComment(cls.documentationComment, text);
(...skipping 14 matching lines...) Expand all
1093 checkDocumentationComment(cls.documentationComment, text); 1164 checkDocumentationComment(cls.documentationComment, text);
1094 } 1165 }
1095 1166
1096 test_class_documented_with_with_windows_line_endings() { 1167 test_class_documented_with_with_windows_line_endings() {
1097 String text = '/**\r\n * Docs\r\n */\r\nclass C {}'; 1168 String text = '/**\r\n * Docs\r\n */\r\nclass C {}';
1098 UnlinkedClass cls = serializeClassText(text); 1169 UnlinkedClass cls = serializeClassText(text);
1099 expect(cls.documentationComment, isNotNull); 1170 expect(cls.documentationComment, isNotNull);
1100 checkDocumentationComment(cls.documentationComment, text); 1171 checkDocumentationComment(cls.documentationComment, text);
1101 } 1172 }
1102 1173
1103 test_class_executables() {
1104 UnlinkedClass cls = serializeClassText('''
1105 class C {
1106 static void methodStaticPublic() {}
1107 static void _methodStaticPrivate() {}
1108 C();
1109 C.constructorNamedPublic();
1110 C._constructorNamedPrivate();
1111 void methodInstancePublic() {}
1112 C operator+(C c) => null;
1113 }
1114 ''');
1115 expect(cls.isAbstract, false);
1116 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
1117 UnlinkedPublicName className = unlinkedUnits[0].publicNamespace.names[0];
1118 expect(className.kind, ReferenceKind.classOrEnum);
1119 expect(className.name, 'C');
1120 expect(className.numTypeParameters, 0);
1121 // executables
1122 Map<String, UnlinkedPublicName> executablesMap =
1123 <String, UnlinkedPublicName>{};
1124 className.executables.forEach((e) => executablesMap[e.name] = e);
1125 expect(executablesMap, hasLength(3));
1126 {
1127 UnlinkedPublicName executable = executablesMap['methodStaticPublic'];
1128 expect(executable.kind, ReferenceKind.staticMethod);
1129 expect(executable.executables, isEmpty);
1130 }
1131 {
1132 UnlinkedPublicName executable = executablesMap[''];
1133 expect(executable.kind, ReferenceKind.constructor);
1134 expect(executable.executables, isEmpty);
1135 }
1136 {
1137 UnlinkedPublicName executable = executablesMap['constructorNamedPublic'];
1138 expect(executable.kind, ReferenceKind.constructor);
1139 expect(executable.executables, isEmpty);
1140 }
1141 }
1142
1143 test_class_interface() { 1174 test_class_interface() {
1144 UnlinkedClass cls = serializeClassText(''' 1175 UnlinkedClass cls = serializeClassText('''
1145 class C implements D {} 1176 class C implements D {}
1146 class D {} 1177 class D {}
1147 '''); 1178 ''');
1148 expect(cls.interfaces, hasLength(1)); 1179 expect(cls.interfaces, hasLength(1));
1149 checkTypeRef(cls.interfaces[0], null, null, 'D'); 1180 checkTypeRef(cls.interfaces[0], null, null, 'D');
1150 } 1181 }
1151 1182
1152 test_class_interface_order() { 1183 test_class_interface_order() {
(...skipping 3519 matching lines...) Expand 10 before | Expand all | Expand 10 after
4672 */ 4703 */
4673 class _PrefixExpectation { 4704 class _PrefixExpectation {
4674 final ReferenceKind kind; 4705 final ReferenceKind kind;
4675 final String name; 4706 final String name;
4676 final bool inLibraryDefiningUnit; 4707 final bool inLibraryDefiningUnit;
4677 final int numTypeParameters; 4708 final int numTypeParameters;
4678 4709
4679 _PrefixExpectation(this.kind, this.name, 4710 _PrefixExpectation(this.kind, this.name,
4680 {this.inLibraryDefiningUnit: false, this.numTypeParameters: 0}); 4711 {this.inLibraryDefiningUnit: false, this.numTypeParameters: 0});
4681 } 4712 }
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