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

Unified Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 1983293002: Delay resynthesizing metadata to Impl classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixes for review comments. Created 4 years, 7 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/element.dart
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index a18876bb8a4ec25383f23c664068eabb5dfb9412..ba70b89ee90b29da0602bebe3873f909476b2de3 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -422,6 +422,16 @@ class ClassElementImpl extends ElementImpl
ElementKind get kind => ElementKind.CLASS;
@override
+ List<ElementAnnotation> get metadata {
+ if (_unlinkedClass != null) {
+ return _metadata ??= _unlinkedClass.annotations
+ .map(resynthesizerContext.buildAnnotation)
+ .toList();
+ }
+ return super.metadata;
+ }
+
+ @override
List<MethodElement> get methods => _methods;
/**
@@ -1238,9 +1248,9 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
*/
List<ElementAnnotation> getAnnotations(int offset) {
if (annotationMap == null) {
- return ElementAnnotation.EMPTY_LIST;
+ return const <ElementAnnotation>[];
}
- return annotationMap[offset] ?? ElementAnnotation.EMPTY_LIST;
+ return annotationMap[offset] ?? const <ElementAnnotation>[];
}
@override
@@ -1878,7 +1888,7 @@ abstract class ElementImpl implements Element {
/**
* A list containing all of the metadata associated with this element.
*/
- List<ElementAnnotation> metadata = ElementAnnotation.EMPTY_LIST;
+ List<ElementAnnotation> _metadata;
/**
* A cached copy of the calculated hashCode for this element.
@@ -2086,6 +2096,15 @@ abstract class ElementImpl implements Element {
return _cachedLocation;
}
+ List<ElementAnnotation> get metadata {
+ return _metadata ?? const <ElementAnnotation>[];
+ }
+
+ void set metadata(List<ElementAnnotation> metadata) {
+ assert(resynthesizerContext == null);
+ _metadata = metadata;
+ }
+
@override
String get name => _name;
@@ -2708,6 +2727,16 @@ abstract class ExecutableElementImpl extends ElementImpl
}
@override
+ List<ElementAnnotation> get metadata {
+ if (serializedExecutable != null) {
+ return _metadata ??= serializedExecutable.annotations
+ .map(resynthesizerContext.buildAnnotation)
+ .toList();
+ }
+ return super.metadata;
+ }
+
+ @override
String get name {
if (serializedExecutable != null) {
return serializedExecutable.name;
@@ -3198,6 +3227,16 @@ class FunctionTypeAliasElementImpl extends ElementImpl
ElementKind get kind => ElementKind.FUNCTION_TYPE_ALIAS;
@override
+ List<ElementAnnotation> get metadata {
+ if (_unlinkedTypedef != null) {
+ return _metadata ??= _unlinkedTypedef.annotations
+ .map(resynthesizerContext.buildAnnotation)
+ .toList();
+ }
+ return super.metadata;
+ }
+
+ @override
String get name {
if (_unlinkedTypedef != null) {
return _unlinkedTypedef.name;
@@ -4441,7 +4480,7 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
ElementLocation get location => null;
@override
- List<ElementAnnotation> get metadata => ElementAnnotation.EMPTY_LIST;
+ List<ElementAnnotation> get metadata => const <ElementAnnotation>[];
@override
String get name => _name;
@@ -5068,6 +5107,11 @@ abstract class PropertyInducingElementImpl extends VariableElementImpl
*/
abstract class ResynthesizerContext {
/**
+ * Build [ElementAnnotationImpl] for the given [UnlinkedConst].
+ */
+ ElementAnnotationImpl buildAnnotation(UnlinkedConst uc);
+
+ /**
* Resolve an [EntityRef] into a type. If the reference is
* unresolved, return [DynamicTypeImpl.instance].
*
@@ -5269,6 +5313,16 @@ class TypeParameterElementImpl extends ElementImpl
ElementKind get kind => ElementKind.TYPE_PARAMETER;
@override
+ List<ElementAnnotation> get metadata {
+ if (_unlinkedTypeParam != null) {
+ return _metadata ??= _unlinkedTypeParam.annotations
+ .map(resynthesizerContext.buildAnnotation)
+ .toList();
+ }
+ return super.metadata;
+ }
+
+ @override
String get name {
if (_unlinkedTypeParam != null) {
return _unlinkedTypeParam.name;
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698