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

Side by Side Diff: pkg/analyzer/lib/src/summary/summarize_elements.dart

Issue 1685713002: Rework UnlinkedPublicName.constMembers. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 serialization.elements; 5 library serialization.elements;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/dart/element/type.dart'; 8 import 'package:analyzer/dart/element/type.dart';
9 import 'package:analyzer/src/dart/element/element.dart'; 9 import 'package:analyzer/src/dart/element/element.dart';
10 import 'package:analyzer/src/dart/element/type.dart'; 10 import 'package:analyzer/src/dart/element/type.dart';
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 name: accessor.name, 180 name: accessor.name,
181 numTypeParameters: accessor.typeParameters.length)); 181 numTypeParameters: accessor.typeParameters.length));
182 } 182 }
183 } 183 }
184 for (ClassElement cls in compilationUnit.types) { 184 for (ClassElement cls in compilationUnit.types) {
185 if (cls.isPublic) { 185 if (cls.isPublic) {
186 names.add(new UnlinkedPublicNameBuilder( 186 names.add(new UnlinkedPublicNameBuilder(
187 kind: ReferenceKind.classOrEnum, 187 kind: ReferenceKind.classOrEnum,
188 name: cls.name, 188 name: cls.name,
189 numTypeParameters: cls.typeParameters.length, 189 numTypeParameters: cls.typeParameters.length,
190 constMembers: serializeClassConstMembers(cls))); 190 members: serializeClassConstMembers(cls)));
191 } 191 }
192 } 192 }
193 for (ClassElement enm in compilationUnit.enums) { 193 for (ClassElement enm in compilationUnit.enums) {
194 if (enm.isPublic) { 194 if (enm.isPublic) {
195 names.add(new UnlinkedPublicNameBuilder( 195 names.add(new UnlinkedPublicNameBuilder(
196 kind: ReferenceKind.classOrEnum, name: enm.name)); 196 kind: ReferenceKind.classOrEnum, name: enm.name));
197 } 197 }
198 } 198 }
199 for (FunctionElement function in compilationUnit.functions) { 199 for (FunctionElement function in compilationUnit.functions) {
200 if (function.isPublic) { 200 if (function.isPublic) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 b.annotations = serializeAnnotations(classElement); 397 b.annotations = serializeAnnotations(classElement);
398 return b; 398 return b;
399 } 399 }
400 400
401 /** 401 /**
402 * If [cls] is a class, return the list of its members available for 402 * If [cls] is a class, return the list of its members available for
403 * constants - static constant fields, static methods and constructors. 403 * constants - static constant fields, static methods and constructors.
404 * Otherwise return `null`. 404 * Otherwise return `null`.
405 */ 405 */
406 List<UnlinkedPublicNameBuilder> serializeClassConstMembers(ClassElement cls) { 406 List<UnlinkedPublicNameBuilder> serializeClassConstMembers(ClassElement cls) {
407 if (cls.isMixinApplication) {
408 // Mixin application members can't be determined directly from the AST so
409 // we can't store them in UnlinkedPublicName.
410 // TODO(paulberry): find somewhere else to store them.
411 return null;
412 }
407 if (cls.kind == ElementKind.CLASS) { 413 if (cls.kind == ElementKind.CLASS) {
408 List<UnlinkedPublicNameBuilder> bs = <UnlinkedPublicNameBuilder>[]; 414 List<UnlinkedPublicNameBuilder> bs = <UnlinkedPublicNameBuilder>[];
409 for (FieldElement field in cls.fields) { 415 for (FieldElement field in cls.fields) {
410 if (field.isStatic && field.isConst && field.isPublic) { 416 if (field.isStatic && field.isConst && field.isPublic) {
411 // TODO(paulberry): should numTypeParameters include class params? 417 // TODO(paulberry): should numTypeParameters include class params?
412 bs.add(new UnlinkedPublicNameBuilder( 418 bs.add(new UnlinkedPublicNameBuilder(
413 name: field.name, 419 name: field.name,
414 kind: ReferenceKind.propertyAccessor, 420 kind: ReferenceKind.propertyAccessor,
415 numTypeParameters: 0)); 421 numTypeParameters: 0));
416 } 422 }
417 } 423 }
418 for (MethodElement method in cls.methods) { 424 for (MethodElement method in cls.methods) {
419 if (method.isStatic && method.isPublic) { 425 if (method.isStatic && method.isPublic) {
420 // TODO(paulberry): should numTypeParameters include class params? 426 // TODO(paulberry): should numTypeParameters include class params?
421 bs.add(new UnlinkedPublicNameBuilder( 427 bs.add(new UnlinkedPublicNameBuilder(
422 name: method.name, 428 name: method.name,
423 kind: ReferenceKind.method, 429 kind: ReferenceKind.method,
424 numTypeParameters: method.typeParameters.length)); 430 numTypeParameters: method.typeParameters.length));
425 } 431 }
426 } 432 }
427 for (ConstructorElement constructor in cls.constructors) { 433 for (ConstructorElement constructor in cls.constructors) {
428 if (constructor.isConst && constructor.isPublic) { 434 if (constructor.isPublic &&
435 constructor.name.isNotEmpty) {
429 // TODO(paulberry): should numTypeParameters include class params? 436 // TODO(paulberry): should numTypeParameters include class params?
430 bs.add(new UnlinkedPublicNameBuilder( 437 bs.add(new UnlinkedPublicNameBuilder(
431 name: constructor.name, 438 name: constructor.name,
432 kind: ReferenceKind.constructor, 439 kind: ReferenceKind.constructor,
433 numTypeParameters: 0)); 440 numTypeParameters: 0));
434 } 441 }
435 } 442 }
436 return bs; 443 return bs;
437 } 444 }
438 return null; 445 return null;
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 exportNames.add(new LinkedExportNameBuilder( 1253 exportNames.add(new LinkedExportNameBuilder(
1247 name: name, 1254 name: name,
1248 dependency: serializeDependency(dependentLibrary), 1255 dependency: serializeDependency(dependentLibrary),
1249 unit: unit, 1256 unit: unit,
1250 kind: kind)); 1257 kind: kind));
1251 } 1258 }
1252 pb.exportNames = exportNames; 1259 pb.exportNames = exportNames;
1253 return pb; 1260 return pb;
1254 } 1261 }
1255 } 1262 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/public_namespace_computer.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698