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

Unified Diff: pkg/analyzer/lib/src/summary/summarize_elements.dart

Issue 1636113002: Serialize static constant field references. (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 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 22ed96f3609d7bd26e86b31d7453ae84cdba4d65..e5e4f04e7816b82c9f1b1393f799ccedacb051fa 100644
--- a/pkg/analyzer/lib/src/summary/summarize_elements.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_elements.dart
@@ -28,23 +28,24 @@ LibrarySerializationResult serializeLibrary(
}
ReferenceKind _getReferenceKind(Element element) {
- ReferenceKind kind;
if (element == null ||
element is ClassElement ||
element is DynamicElementImpl) {
- kind = ReferenceKind.classOrEnum;
+ return ReferenceKind.classOrEnum;
} else if (element is ConstructorElement) {
- kind = ReferenceKind.constructor;
+ return ReferenceKind.constructor;
} else if (element is FunctionElement) {
- kind = ReferenceKind.topLevelFunction;
+ return ReferenceKind.topLevelFunction;
} else if (element is FunctionTypeAliasElement) {
- kind = ReferenceKind.typedef;
+ return ReferenceKind.typedef;
} else if (element is PropertyAccessorElement) {
- kind = ReferenceKind.topLevelPropertyAccessor;
+ if (element.enclosingElement is ClassElement) {
+ return ReferenceKind.constField;
+ }
+ return ReferenceKind.topLevelPropertyAccessor;
} else {
throw new Exception('Unexpected element kind: ${element.runtimeType}');
}
- return kind;
}
/**
@@ -870,7 +871,14 @@ class _ConstExprSerializer extends AbstractConstExprSerializer {
EntityRefBuilder serializeIdentifier(Identifier identifier) {
Element element = identifier.staticElement;
assert(element != null);
- // TODO(scheglov) how to serialize element references?
+ return new EntityRefBuilder(
+ reference: serializer._getElementReferenceId(element));
+ }
+
+ @override
+ EntityRefBuilder serializePropertyAccess(PropertyAccess access) {
+ Element element = access.propertyName.staticElement;
+ assert(element != null);
return new EntityRefBuilder(
reference: serializer._getElementReferenceId(element));
}

Powered by Google App Engine
This is Rietveld 408576698