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

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

Issue 2043783002: Resynthesize enums lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 6d085fcb9d062c067c457a291681ea7677be0af8..bc2b7d04b89fc3c2d1a3224c56e30ef60da79e85 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -1323,7 +1323,7 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
/**
* A list containing all of the enums contained in this compilation unit.
*/
- List<ClassElement> _enums = ClassElement.EMPTY_LIST;
+ List<ClassElement> _enums;
/**
* A list containing all of the top-level functions contained in this
@@ -1450,12 +1450,20 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
}
@override
- List<ClassElement> get enums => _enums;
+ List<ClassElement> get enums {
+ if (_unlinkedUnit != null) {
+ _enums ??= _unlinkedUnit.enums
+ .map((e) => new EnumElementImpl.forSerialized(e, this))
+ .toList(growable: false);
+ }
+ return _enums ?? const <ClassElement>[];
+ }
/**
* Set the enums contained in this compilation unit to the given [enums].
*/
void set enums(List<ClassElement> enums) {
+ assert(_unlinkedUnit == null);
for (ClassElement enumDeclaration in enums) {
(enumDeclaration as EnumElementImpl).enclosingElement = this;
}
« 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