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

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

Issue 2032053002: Resynthesize class methods lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 8282aa319244f372b0a37e97683213c24682f537..84eff00310724fda8ae87f290e4bf10d95374738 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -481,7 +481,7 @@ class ClassElementImpl extends AbstractClassElementImpl {
/**
* A list containing all of the methods contained in this class.
*/
- List<MethodElement> _methods = MethodElement.EMPTY_LIST;
+ List<MethodElement> _methods;
/**
* A flag indicating whether the types associated with the instance members of
@@ -676,7 +676,7 @@ class ClassElementImpl extends AbstractClassElementImpl {
@override
bool get hasStaticMember {
- for (MethodElement method in _methods) {
+ for (MethodElement method in methods) {
if (method.isStatic) {
return true;
}
@@ -766,16 +766,25 @@ class ClassElementImpl extends AbstractClassElementImpl {
}
@override
- List<MethodElement> get methods => _methods;
+ List<MethodElement> get methods {
+ if (_unlinkedClass != null) {
+ _methods ??= _unlinkedClass.executables
+ .where((e) => e.kind == UnlinkedExecutableKind.functionOrMethod)
+ .map((e) => new MethodElementImpl.forSerialized(e, this))
+ .toList(growable: false);
+ }
+ return _methods ?? const <MethodElement>[];
+ }
/**
* Set the methods contained in this class to the given [methods].
*/
void set methods(List<MethodElement> methods) {
+ assert(_unlinkedClass == null);
for (MethodElement method in methods) {
(method as MethodElementImpl).enclosingElement = this;
}
- this._methods = methods;
+ _methods = methods;
}
/**
@@ -927,7 +936,7 @@ class ClassElementImpl extends AbstractClassElementImpl {
return constructorImpl;
}
}
- for (MethodElement method in _methods) {
+ for (MethodElement method in methods) {
MethodElementImpl methodImpl = method;
if (methodImpl.identifier == identifier) {
return methodImpl;
@@ -944,9 +953,9 @@ class ClassElementImpl extends AbstractClassElementImpl {
@override
MethodElement getMethod(String methodName) {
- int length = _methods.length;
+ int length = methods.length;
for (int i = 0; i < length; i++) {
- MethodElement method = _methods[i];
+ MethodElement method = methods[i];
if (method.name == methodName) {
return method;
}
@@ -986,7 +995,7 @@ class ClassElementImpl extends AbstractClassElementImpl {
void visitChildren(ElementVisitor visitor) {
super.visitChildren(visitor);
safelyVisitChildren(_constructors, visitor);
- safelyVisitChildren(_methods, visitor);
+ safelyVisitChildren(methods, visitor);
safelyVisitChildren(_typeParameters, visitor);
}
« 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