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

Unified Diff: pkg/analyzer/lib/src/summary/summarize_elements.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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/summary/summarize_elements.dart
diff --git a/pkg/analyzer/lib/src/summary/summarize_elements.dart b/pkg/analyzer/lib/src/summary/summarize_elements.dart
index 26665db4aa98ab95157e2a6f9e96faac67db8356..22ed96f3609d7bd26e86b31d7453ae84cdba4d65 100644
--- a/pkg/analyzer/lib/src/summary/summarize_elements.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_elements.dart
@@ -183,7 +183,7 @@ class _CompilationUnitSerializer {
kind: ReferenceKind.classOrEnum,
name: cls.name,
numTypeParameters: cls.typeParameters.length,
- executables: serializePublicStaticMethodsAndConstructors(cls)));
+ constMembers: serializeClassConstMembers(cls)));
}
}
for (ClassElement enm in compilationUnit.enums) {
@@ -376,6 +376,43 @@ class _CompilationUnitSerializer {
}
/**
+ * If [cls] is a class, return the list of its members available for
+ * constants - static constant fields, static methods and constructors.
+ * Otherwise return `null`.
+ */
+ List<UnlinkedPublicNameBuilder> serializeClassConstMembers(ClassElement cls) {
+ if (cls.kind == ElementKind.CLASS) {
+ List<UnlinkedPublicNameBuilder> bs = <UnlinkedPublicNameBuilder>[];
+ for (FieldElement field in cls.fields) {
+ if (field.isStatic && field.isConst && field.isPublic) {
+ bs.add(new UnlinkedPublicNameBuilder(
+ name: field.name,
+ kind: ReferenceKind.constField,
+ numTypeParameters: 0));
+ }
+ }
+ for (MethodElement method in cls.methods) {
+ if (method.isStatic && method.isPublic) {
+ bs.add(new UnlinkedPublicNameBuilder(
+ name: method.name,
+ kind: ReferenceKind.staticMethod,
+ numTypeParameters: method.typeParameters.length));
+ }
+ }
+ for (ConstructorElement constructor in cls.constructors) {
+ if (constructor.isConst && constructor.isPublic) {
+ bs.add(new UnlinkedPublicNameBuilder(
+ name: constructor.name,
+ kind: ReferenceKind.constructor,
+ numTypeParameters: 0));
+ }
+ }
+ return bs;
+ }
+ return null;
+ }
+
+ /**
* Serialize the given [combinator] into an [UnlinkedCombinator].
*/
UnlinkedCombinatorBuilder serializeCombinator(
@@ -582,35 +619,6 @@ class _CompilationUnitSerializer {
}
/**
- * If [cls] is a class, return the list of its public static methods and
- * constructors. Otherwise return `null`.
- */
- List<UnlinkedPublicNameBuilder> serializePublicStaticMethodsAndConstructors(
- ClassElement cls) {
- if (cls.kind == ElementKind.CLASS) {
- List<UnlinkedPublicNameBuilder> bs = <UnlinkedPublicNameBuilder>[];
- for (MethodElement method in cls.methods) {
- if (method.isStatic && method.isPublic) {
- bs.add(new UnlinkedPublicNameBuilder(
- name: method.name,
- kind: ReferenceKind.staticMethod,
- numTypeParameters: method.typeParameters.length));
- }
- }
- for (ConstructorElement constructor in cls.constructors) {
- if (constructor.isPublic && !constructor.isSynthetic) {
- bs.add(new UnlinkedPublicNameBuilder(
- name: constructor.name,
- kind: ReferenceKind.constructor,
- numTypeParameters: 0));
- }
- }
- return bs;
- }
- return null;
- }
-
- /**
* Compute the reference index which should be stored in a [EntityRef].
*
* If [linked] is true, and a new reference has to be created, the reference
« 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