@@ -42,7 +42,6 @@ import 'package:analyzer/src/generated/utilities_collection.dart';
4242import 'package:analyzer/src/generated/utilities_dart.dart' ;
4343import 'package:analyzer/src/generated/utilities_general.dart' ;
4444import 'package:analyzer/src/summary/idl.dart' ;
45- import 'package:analyzer/src/summary2/lazy_ast.dart' ;
4645import 'package:analyzer/src/summary2/linked_unit_context.dart' ;
4746import 'package:analyzer/src/summary2/reference.dart' ;
4847import 'package:analyzer/src/util/comment.dart' ;
@@ -501,7 +500,6 @@ class ClassElementImpl extends AbstractClassElementImpl
501500
502501 if (linkedNode != null ) {
503502 if (linkedNode is ClassOrMixinDeclaration ) {
504- LazyAst .applyResolution (linkedNode);
505503 _createPropertiesAndAccessors ();
506504 assert (_accessors != null );
507505 return _accessors;
@@ -546,7 +544,6 @@ class ClassElementImpl extends AbstractClassElementImpl
546544 }
547545
548546 if (linkedNode != null ) {
549- LazyAst .applyResolution (linkedNode);
550547 var context = enclosingUnit.linkedContext;
551548 var containerRef = reference.getChild ('@constructor' );
552549 _constructors = context.getConstructors (linkedNode).map ((node) {
@@ -608,7 +605,6 @@ class ClassElementImpl extends AbstractClassElementImpl
608605
609606 if (linkedNode != null ) {
610607 if (linkedNode is ClassOrMixinDeclaration ) {
611- LazyAst .applyResolution (linkedNode);
612608 _createPropertiesAndAccessors ();
613609 assert (_fields != null );
614610 return _fields;
@@ -709,7 +705,6 @@ class ClassElementImpl extends AbstractClassElementImpl
709705 }
710706
711707 if (linkedNode != null ) {
712- LazyAst .applyResolution (linkedNode);
713708 var context = enclosingUnit.linkedContext;
714709 var implementsClause = context.getImplementsClause (linkedNode);
715710 if (implementsClause != null ) {
@@ -785,7 +780,6 @@ class ClassElementImpl extends AbstractClassElementImpl
785780 }
786781
787782 if (linkedNode != null ) {
788- LazyAst .applyResolution (linkedNode);
789783 var context = enclosingUnit.linkedContext;
790784 var containerRef = reference.getChild ('@method' );
791785 return _methods = context
@@ -822,7 +816,6 @@ class ClassElementImpl extends AbstractClassElementImpl
822816 }
823817
824818 if (linkedNode != null ) {
825- LazyAst .applyResolution (linkedNode);
826819 var context = enclosingUnit.linkedContext;
827820 var withClause = context.getWithClause (linkedNode);
828821 if (withClause != null ) {
@@ -872,18 +865,7 @@ class ClassElementImpl extends AbstractClassElementImpl
872865 }
873866
874867 if (linkedNode != null ) {
875- var node = linkedNode;
876- LazyAst .applyResolution (node);
877-
878- DartType type;
879- if (node is ClassDeclaration ) {
880- type = node.extendsClause? .superclass? .type;
881- } else if (node is ClassTypeAlias ) {
882- type = linkedContext.getSuperclass (linkedNode)? .type;
883- } else {
884- throw UnimplementedError ('${node .runtimeType }' );
885- }
886-
868+ var type = linkedContext.getSuperclass (linkedNode)? .type;
887869 if (_isInterfaceTypeClass (type)) {
888870 return _supertype = type;
889871 }
@@ -1982,9 +1964,9 @@ class ConstructorElementImpl extends ExecutableElementImpl
19821964 if (_constantInitializers != null ) return _constantInitializers;
19831965
19841966 if (linkedNode != null ) {
1985- var node = linkedNode as ConstructorDeclaration ;
1986- LazyAst . applyResolution (node);
1987- return _constantInitializers = node.initializers ;
1967+ return _constantInitializers = linkedContext. getConstructorInitializers (
1968+ linkedNode,
1969+ ) ;
19881970 }
19891971
19901972 return _constantInitializers;
@@ -2098,13 +2080,13 @@ class ConstructorElementImpl extends ExecutableElementImpl
20982080 if (_redirectedConstructor != null ) return _redirectedConstructor;
20992081
21002082 if (linkedNode != null ) {
2101- var node = linkedNode as ConstructorDeclaration ;
2102- LazyAst .applyResolution (node);
2083+ var context = enclosingUnit.linkedContext;
21032084 if (isFactory) {
2104- return _redirectedConstructor =
2105- node.redirectedConstructor ? .staticElement;
2085+ var node = context. getConstructorRedirected (linkedNode);
2086+ return _redirectedConstructor = node? .staticElement;
21062087 } else {
2107- for (var initializer in node.initializers) {
2088+ var initializers = context.getConstructorInitializers (linkedNode);
2089+ for (var initializer in initializers) {
21082090 if (initializer is RedirectingConstructorInvocation ) {
21092091 return _redirectedConstructor = initializer.staticElement;
21102092 }
@@ -2232,7 +2214,6 @@ mixin ConstVariableElement implements ElementImpl, ConstantEvaluationTarget {
22322214 if (_constantInitializer != null ) return _constantInitializer;
22332215
22342216 if (linkedNode != null ) {
2235- LazyAst .applyResolution (linkedNode);
22362217 var context = enclosingUnit.linkedContext;
22372218 return _constantInitializer = context.readInitializer (linkedNode);
22382219 }
@@ -3001,10 +2982,8 @@ abstract class ElementImpl implements Element {
30012982
30022983 @override
30032984 List <ElementAnnotation > get metadata {
3004- if (_metadata != null ) return _metadata;
3005-
30062985 if (linkedNode != null ) {
3007- LazyAst . applyResolution (linkedNode) ;
2986+ if (_metadata != null ) return _metadata ;
30082987 var metadata = linkedContext.getMetadata (linkedNode);
30092988 return _metadata = _buildAnnotations2 (enclosingUnit, metadata);
30102989 }
@@ -3510,9 +3489,6 @@ class EnumElementImpl extends AbstractClassElementImpl {
35103489 ConstructorElement getNamedConstructor (String name) => null ;
35113490
35123491 void _resynthesizeMembers2 () {
3513- var node = linkedNode as EnumDeclaration ;
3514- LazyAst .applyResolution (node);
3515-
35163492 var fields = < FieldElementImpl > [];
35173493 var getters = < PropertyAccessorElementImpl > [];
35183494
@@ -3540,7 +3516,7 @@ class EnumElementImpl extends AbstractClassElementImpl {
35403516
35413517 // Build fields for all enum constants.
35423518 var containerRef = reference.getChild ('@constant' );
3543- var constants = node.constants ;
3519+ var constants = linkedContext. getEnumConstants (linkedNode) ;
35443520 for (var i = 0 ; i < constants.length; ++ i) {
35453521 var constant = constants[i];
35463522 var name = constant.name.name;
@@ -3725,11 +3701,10 @@ abstract class ExecutableElementImpl extends ElementImpl
37253701 if (_parameters != null ) return _parameters;
37263702
37273703 if (linkedNode != null ) {
3728- LazyAst .applyResolution (linkedNode);
37293704 var context = enclosingUnit.linkedContext;
37303705 var containerRef = reference.getChild ('@parameter' );
37313706 var formalParameters = context.getFormalParameters (linkedNode);
3732- return _parameters = ParameterElementImpl .forLinkedNodeList (
3707+ _parameters = ParameterElementImpl .forLinkedNodeList (
37333708 this ,
37343709 context,
37353710 containerRef,
@@ -3764,7 +3739,6 @@ abstract class ExecutableElementImpl extends ElementImpl
37643739 if (_returnType != null ) return _returnType;
37653740
37663741 if (linkedNode != null ) {
3767- LazyAst .applyResolution (linkedNode);
37683742 var context = enclosingUnit.linkedContext;
37693743 return _returnType = context.getReturnType (linkedNode);
37703744 }
@@ -3953,7 +3927,6 @@ class ExtensionElementImpl extends ElementImpl
39533927
39543928 if (linkedNode != null ) {
39553929 if (linkedNode is ExtensionDeclaration ) {
3956- LazyAst .applyResolution (linkedNode);
39573930 _createPropertiesAndAccessors ();
39583931 assert (_accessors != null );
39593932 return _accessors;
@@ -4013,9 +3986,7 @@ class ExtensionElementImpl extends ElementImpl
40133986 if (_extendedType != null ) return _extendedType;
40143987
40153988 if (linkedNode != null ) {
4016- var node = linkedNode as ExtensionDeclaration ;
4017- LazyAst .applyResolution (linkedNode);
4018- return _extendedType = node.extendedType.type;
3989+ return _extendedType = linkedContext.getExtendedType (linkedNode).type;
40193990 }
40203991
40213992 return _extendedType;
@@ -4029,7 +4000,6 @@ class ExtensionElementImpl extends ElementImpl
40294000
40304001 if (linkedNode != null ) {
40314002 if (linkedNode is ExtensionDeclaration ) {
4032- LazyAst .applyResolution (linkedNode);
40334003 _createPropertiesAndAccessors ();
40344004 assert (_fields != null );
40354005 return _fields;
@@ -4069,7 +4039,6 @@ class ExtensionElementImpl extends ElementImpl
40694039 }
40704040
40714041 if (linkedNode != null ) {
4072- LazyAst .applyResolution (linkedNode);
40734042 var context = enclosingUnit.linkedContext;
40744043 var containerRef = reference.getChild ('@method' );
40754044 return _methods = context
@@ -4535,17 +4504,15 @@ class FunctionTypeAliasElementImpl extends ElementImpl
45354504 GenericFunctionTypeElementImpl get function {
45364505 if (_function != null ) return _function;
45374506
4538- var node = linkedNode;
4539- if (node != null ) {
4540- LazyAst .applyResolution (node);
4541- if (node is GenericTypeAlias ) {
4542- var function = node.functionType;
4507+ if (linkedNode != null ) {
4508+ if (linkedNode is GenericTypeAlias ) {
4509+ var context = enclosingUnit.linkedContext;
4510+ var function = context.getGeneticTypeAliasFunction (linkedNode);
45434511 if (function != null ) {
4544- return _function = GenericFunctionTypeElementImpl .forLinkedNode (
4545- this ,
4546- reference.getChild ('@function' ),
4547- function,
4548- );
4512+ var reference = context.getGenericFunctionTypeReference (function);
4513+ _function = reference.element;
4514+ encloseElement (_function);
4515+ return _function;
45494516 } else {
45504517 return _function = GenericFunctionTypeElementImpl .forOffset (- 1 )
45514518 ..typeParameters = const < TypeParameterElement > []
@@ -4740,20 +4707,17 @@ class GenericFunctionTypeElementImpl extends ElementImpl
47404707
47414708 @override
47424709 List <ParameterElement > get parameters {
4743- if (_parameters != null ) return _parameters;
4744-
4745- if (linkedNode != null ) {
4746- var context = enclosingUnit.linkedContext;
4747- var containerRef = reference.getChild ('@parameter' );
4748- var formalParameters = context.getFormalParameters (linkedNode);
4749- return _parameters = ParameterElementImpl .forLinkedNodeList (
4750- this ,
4751- context,
4752- containerRef,
4753- formalParameters,
4754- );
4710+ if (_parameters == null ) {
4711+ if (linkedNode != null ) {
4712+ var context = enclosingUnit.linkedContext;
4713+ return _parameters = ParameterElementImpl .forLinkedNodeList (
4714+ this ,
4715+ context,
4716+ reference.getChild ('@parameter' ),
4717+ context.getFormalParameters (linkedNode),
4718+ );
4719+ }
47554720 }
4756-
47574721 return _parameters ?? const < ParameterElement > [];
47584722 }
47594723
@@ -5873,10 +5837,8 @@ class MixinElementImpl extends ClassElementImpl {
58735837 if (_superclassConstraints != null ) return _superclassConstraints;
58745838
58755839 if (linkedNode != null ) {
5876- var node = linkedNode as MixinDeclaration ;
5877- LazyAst .applyResolution (node);
58785840 List <InterfaceType > constraints;
5879- var onClause = node.onClause ;
5841+ var onClause = enclosingUnit.linkedContext. getOnClause (linkedNode) ;
58805842 if (onClause != null ) {
58815843 constraints = onClause.superclassConstraints
58825844 .map ((node) => node.type)
@@ -6570,14 +6532,18 @@ class ParameterElementImpl extends VariableElementImpl
65706532
65716533 if (linkedNode != null ) {
65726534 var context = enclosingUnit.linkedContext;
6573- var containerRef = reference.getChild ('@parameter' );
65746535 var formalParameters = context.getFormalParameters (linkedNode);
6575- return _parameters = ParameterElementImpl .forLinkedNodeList (
6576- this ,
6577- context,
6578- containerRef,
6579- formalParameters,
6580- );
6536+ if (formalParameters != null ) {
6537+ var containerRef = reference.getChild ('@parameter' );
6538+ return _parameters = ParameterElementImpl .forLinkedNodeList (
6539+ this ,
6540+ context,
6541+ containerRef,
6542+ formalParameters,
6543+ );
6544+ } else {
6545+ return _parameters ?? = const < ParameterElement > [];
6546+ }
65816547 }
65826548
65836549 return _parameters ?? = const < ParameterElement > [];
@@ -6597,9 +6563,8 @@ class ParameterElementImpl extends VariableElementImpl
65976563
65986564 @override
65996565 DartType get typeInternal {
6600- if (_type != null ) return _type;
6601-
66026566 if (linkedNode != null ) {
6567+ if (_type != null ) return _type;
66036568 var context = enclosingUnit.linkedContext;
66046569 return _type = context.getType (linkedNode);
66056570 }
@@ -6611,7 +6576,7 @@ class ParameterElementImpl extends VariableElementImpl
66116576 if (_typeParameters != null ) return _typeParameters;
66126577
66136578 if (linkedNode != null ) {
6614- var typeParameters = linkedContext.getTypeParameters (linkedNode);
6579+ var typeParameters = linkedContext.getTypeParameters2 (linkedNode);
66156580 if (typeParameters == null ) {
66166581 return _typeParameters = const [];
66176582 }
@@ -7192,7 +7157,6 @@ abstract class PropertyInducingElementImpl
71927157 DartType get typeInternal {
71937158 if (linkedNode != null ) {
71947159 if (_type != null ) return _type;
7195- LazyAst .applyResolution (linkedNode);
71967160 _type = linkedContext.getType (linkedNode);
71977161
71987162 // While performing inference during linking, the first step is to collect
@@ -7426,8 +7390,8 @@ class TypeParameterElementImpl extends ElementImpl
74267390 if (_bound != null ) return _bound;
74277391
74287392 if (linkedNode != null ) {
7429- var node = linkedNode as TypeParameter ;
7430- return _bound = node.bound ? .type;
7393+ var context = enclosingUnit.linkedContext ;
7394+ return _bound = context. getTypeParameterBound (linkedNode) ? .type;
74317395 }
74327396
74337397 return _bound;
@@ -7561,19 +7525,13 @@ mixin TypeParameterizedElementMixin
75617525 if (_typeParameterElements != null ) return _typeParameterElements;
75627526
75637527 if (linkedNode != null ) {
7564- LazyAst .applyResolution (linkedNode);
7565- var typeParameters = linkedContext.getTypeParameters (linkedNode);
7528+ var typeParameters = linkedContext.getTypeParameters2 (linkedNode);
75667529 if (typeParameters == null ) {
75677530 return _typeParameterElements = const [];
75687531 }
75697532 var containerRef = reference.getChild ('@typeParameter' );
75707533 return _typeParameterElements =
75717534 typeParameters.typeParameters.map <TypeParameterElement >((node) {
7572- var element = node.declaredElement;
7573- if (element != null ) {
7574- return element;
7575- }
7576-
75777535 var reference = containerRef.getChild (node.name.name);
75787536 if (reference.hasElementFor (node)) {
75797537 return reference.element as TypeParameterElement ;
0 commit comments