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

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

Issue 1619253003: Include explicit constructors and static methods into UnlinkedPublicName (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 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 kind: ReferenceKind.topLevelPropertyAccessor, 173 kind: ReferenceKind.topLevelPropertyAccessor,
174 name: accessor.name, 174 name: accessor.name,
175 numTypeParameters: accessor.typeParameters.length)); 175 numTypeParameters: accessor.typeParameters.length));
176 } 176 }
177 } 177 }
178 for (ClassElement cls in compilationUnit.types) { 178 for (ClassElement cls in compilationUnit.types) {
179 if (cls.isPublic) { 179 if (cls.isPublic) {
180 names.add(new UnlinkedPublicNameBuilder( 180 names.add(new UnlinkedPublicNameBuilder(
181 kind: ReferenceKind.classOrEnum, 181 kind: ReferenceKind.classOrEnum,
182 name: cls.name, 182 name: cls.name,
183 numTypeParameters: cls.typeParameters.length)); 183 numTypeParameters: cls.typeParameters.length,
184 executables: serializePublicStaticMethodsAndConstructors(cls)));
184 } 185 }
185 } 186 }
186 for (ClassElement enm in compilationUnit.enums) { 187 for (ClassElement enm in compilationUnit.enums) {
187 if (enm.isPublic) { 188 if (enm.isPublic) {
188 names.add(new UnlinkedPublicNameBuilder( 189 names.add(new UnlinkedPublicNameBuilder(
189 kind: ReferenceKind.classOrEnum, name: enm.name)); 190 kind: ReferenceKind.classOrEnum, name: enm.name));
190 } 191 }
191 } 192 }
192 for (FunctionElement function in compilationUnit.functions) { 193 for (FunctionElement function in compilationUnit.functions) {
193 if (function.isPublic) { 194 if (function.isPublic) {
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 assert(unlinkedReferences.length == linkedReferences.length); 561 assert(unlinkedReferences.length == linkedReferences.length);
561 int index = unlinkedReferences.length; 562 int index = unlinkedReferences.length;
562 unlinkedReferences.add(new UnlinkedReferenceBuilder(name: element.name)); 563 unlinkedReferences.add(new UnlinkedReferenceBuilder(name: element.name));
563 linkedReferences 564 linkedReferences
564 .add(new LinkedReferenceBuilder(kind: ReferenceKind.prefix)); 565 .add(new LinkedReferenceBuilder(kind: ReferenceKind.prefix));
565 return index; 566 return index;
566 }); 567 });
567 } 568 }
568 569
569 /** 570 /**
571 * If [cls] is a class, return the list of its public static methods and
572 * constructors. Otherwise return `null`.
573 */
574 List<UnlinkedPublicNameBuilder> serializePublicStaticMethodsAndConstructors(
575 ClassElement cls) {
576 if (cls.kind == ElementKind.CLASS) {
577 List<UnlinkedPublicNameBuilder> bs = <UnlinkedPublicNameBuilder>[];
578 for (MethodElement method in cls.methods) {
579 if (method.isStatic && method.isPublic) {
Paul Berry 2016/01/25 13:10:04 Do we need to filter out operators or does `method
scheglov 2016/01/25 17:27:09 Operators cannot be static, so we don't have stati
580 bs.add(new UnlinkedPublicNameBuilder(
581 name: method.name,
582 kind: ReferenceKind.staticMethod,
583 numTypeParameters: method.typeParameters.length));
584 }
585 }
586 for (ConstructorElement constructor in cls.constructors) {
587 if (constructor.isPublic && !constructor.isSynthetic) {
588 bs.add(new UnlinkedPublicNameBuilder(
589 name: constructor.name,
590 kind: ReferenceKind.constructor,
591 numTypeParameters: 0));
592 }
593 }
594 return bs;
595 }
596 return null;
597 }
598
599 /**
570 * Compute the reference index which should be stored in a [EntityRef]. 600 * Compute the reference index which should be stored in a [EntityRef].
571 * 601 *
572 * If [linked] is true, and a new reference has to be created, the reference 602 * If [linked] is true, and a new reference has to be created, the reference
573 * will only be stored in [linkedReferences]. 603 * will only be stored in [linkedReferences].
574 */ 604 */
575 int serializeReferenceForType(DartType type, bool linked) { 605 int serializeReferenceForType(DartType type, bool linked) {
576 Element element = type.element; 606 Element element = type.element;
577 LibraryElement dependentLibrary = element?.library; 607 LibraryElement dependentLibrary = element?.library;
578 if (dependentLibrary == null) { 608 if (dependentLibrary == null) {
579 assert(type.isDynamic || type.isVoid); 609 assert(type.isDynamic || type.isVoid);
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 exportNames.add(new LinkedExportNameBuilder( 1003 exportNames.add(new LinkedExportNameBuilder(
974 name: name, 1004 name: name,
975 dependency: serializeDependency(dependentLibrary), 1005 dependency: serializeDependency(dependentLibrary),
976 unit: unit, 1006 unit: unit,
977 kind: kind)); 1007 kind: kind));
978 } 1008 }
979 pb.exportNames = exportNames; 1009 pb.exportNames = exportNames;
980 return pb; 1010 return pb;
981 } 1011 }
982 } 1012 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698