22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- // ignore_for_file: analyzer_use_new_elements
6-
7- import 'package:analyzer/dart/element/element.dart' ;
5+ import 'package:analyzer/dart/element/element2.dart' ;
86import 'package:analyzer/dart/element/type.dart' ;
97import 'package:analyzer/src/dart/ast/ast.dart' ;
108import 'package:analyzer/src/dart/element/element.dart' ;
@@ -14,7 +12,6 @@ import 'package:analyzer/src/dart/element/type_provider.dart';
1412import 'package:analyzer/src/dart/element/type_system.dart' ;
1513import 'package:analyzer/src/dart/resolver/type_property_resolver.dart' ;
1614import 'package:analyzer/src/generated/resolver.dart' ;
17- import 'package:analyzer/src/utilities/extensions/element.dart' ;
1815
1916class CommentReferenceResolver {
2017 final TypeProviderImpl _typeProvider;
@@ -55,45 +52,45 @@ class CommentReferenceResolver {
5552 }) {
5653 var prefix = expression.prefix;
5754 var prefixElement = _resolveSimpleIdentifier (prefix);
58- prefix.staticElement = prefixElement;
55+ prefix.element = prefixElement;
5956
6057 if (prefixElement == null ) {
6158 return ;
6259 }
6360
6461 var name = expression.identifier;
6562
66- if (prefixElement is PrefixElement ) {
63+ if (prefixElement is PrefixElement2 ) {
6764 var prefixScope = prefixElement.scope;
6865 var lookupResult = prefixScope.lookup (name.name);
69- var element = lookupResult.getter ?? lookupResult.setter ;
70- name.staticElement = element;
66+ var element = lookupResult.getter2 ?? lookupResult.setter2 ;
67+ name.element = element;
7168 return ;
7269 }
7370
7471 if (! hasNewKeyword) {
75- if (prefixElement is InterfaceElement ) {
76- name.staticElement = _resolver.inheritance.getMember2 (
72+ if (prefixElement is InterfaceElement2 ) {
73+ name.element = _resolver.inheritance.getMember4 (
7774 prefixElement,
78- Name (prefixElement.library.source .uri, name.name),
75+ Name (prefixElement.library2 .uri, name.name),
7976 ) ??
80- prefixElement.getMethod (name.name) ??
81- prefixElement.getGetter (name.name) ??
82- prefixElement.getSetter (name.name) ??
83- prefixElement.getNamedConstructor (name.name);
84- } else if (prefixElement is ExtensionElement ) {
85- name.staticElement = prefixElement.getMethod (name.name) ??
86- prefixElement.getGetter (name.name) ??
87- prefixElement.getSetter (name.name);
77+ prefixElement.getMethod2 (name.name) ??
78+ prefixElement.getGetter2 (name.name) ??
79+ prefixElement.getSetter2 (name.name) ??
80+ prefixElement.getNamedConstructor2 (name.name);
81+ } else if (prefixElement is ExtensionElement2 ) {
82+ name.element = prefixElement.getMethod2 (name.name) ??
83+ prefixElement.getGetter2 (name.name) ??
84+ prefixElement.getSetter2 (name.name);
8885 } else {
8986 // TODO(brianwilkerson): Report this error.
9087 }
91- } else if (prefixElement is InterfaceElement ) {
92- var constructor = prefixElement.getNamedConstructor (name.name);
88+ } else if (prefixElement is InterfaceElement2 ) {
89+ var constructor = prefixElement.getNamedConstructor2 (name.name);
9390 if (constructor == null ) {
9491 // TODO(brianwilkerson): Report this error.
9592 } else {
96- name.staticElement = constructor;
93+ name.element = constructor;
9794 }
9895 } else {
9996 // TODO(brianwilkerson): Report this error.
@@ -113,9 +110,9 @@ class CommentReferenceResolver {
113110
114111 var prefix = target.prefix;
115112 var prefixElement = _resolveSimpleIdentifier (prefix);
116- prefix.staticElement = prefixElement;
113+ prefix.element = prefixElement;
117114
118- if (prefixElement is ! PrefixElement ) {
115+ if (prefixElement is ! PrefixElement2 ) {
119116 // The only valid prefixElement is a PrefixElement; otherwise, this is
120117 // not a comment reference.
121118 return ;
@@ -124,33 +121,33 @@ class CommentReferenceResolver {
124121 var name = target.identifier;
125122 var prefixScope = prefixElement.scope;
126123 var lookupResult = prefixScope.lookup (name.name);
127- var element = lookupResult.getter ?? lookupResult.setter ;
128- name.staticElement = element;
124+ var element = lookupResult.getter2 ?? lookupResult.setter2 ;
125+ name.element = element;
129126
130127 var propertyName = expression.propertyName;
131- if (element is InterfaceElement ) {
132- propertyName.staticElement = element.getMethod (propertyName.name) ??
133- element.getGetter (propertyName.name) ??
134- element.getSetter (propertyName.name) ??
135- element.getNamedConstructor (propertyName.name);
136- } else if (element is ExtensionElement ) {
137- propertyName.staticElement = element.getMethod (propertyName.name) ??
138- element.getGetter (propertyName.name) ??
139- element.getSetter (propertyName.name);
128+ if (element is InterfaceElement2 ) {
129+ propertyName.element = element.getMethod2 (propertyName.name) ??
130+ element.getGetter2 (propertyName.name) ??
131+ element.getSetter2 (propertyName.name) ??
132+ element.getNamedConstructor2 (propertyName.name);
133+ } else if (element is ExtensionElement2 ) {
134+ propertyName.element = element.getMethod2 (propertyName.name) ??
135+ element.getGetter2 (propertyName.name) ??
136+ element.getSetter2 (propertyName.name);
140137 }
141138 }
142139
143140 /// Resolves the given simple [identifier] if possible.
144141 ///
145142 /// Returns the resolved element, or `null` if the identifier could not be
146143 /// resolved. This does not record the results of the resolution.
147- Element ? _resolveSimpleIdentifier (SimpleIdentifierImpl identifier) {
144+ Element2 ? _resolveSimpleIdentifier (SimpleIdentifierImpl identifier) {
148145 var lookupResult = identifier.scopeLookupResult! ;
149- var element = lookupResult.getter ?? lookupResult.setter ;
146+ var element = lookupResult.getter2 ?? lookupResult.setter2 ;
150147
151148 // Usually referencing just an import prefix is an error.
152149 // But we allow this in documentation comments.
153- if (element is PrefixElementImpl ) {
150+ if (element is PrefixElementImpl2 ) {
154151 element.scope.notifyPrefixUsedInCommentReference ();
155152 }
156153
@@ -182,7 +179,7 @@ class CommentReferenceResolver {
182179 propertyErrorEntity: identifier,
183180 nameErrorEntity: identifier,
184181 );
185- element = result.getter2? .asElement ?? result.setter2? .asElement ;
182+ element = result.getter2 ?? result.setter2;
186183 }
187184 return element;
188185 }
@@ -195,14 +192,14 @@ class CommentReferenceResolver {
195192 if (element == null ) {
196193 return ;
197194 }
198- expression.staticElement = element;
195+ expression.element = element;
199196 if (hasNewKeyword) {
200- if (element is InterfaceElement ) {
201- var constructor = element.unnamedConstructor ;
197+ if (element is InterfaceElement2 ) {
198+ var constructor = element.unnamedConstructor2 ;
202199 if (constructor == null ) {
203200 // TODO(brianwilkerson): Report this error.
204201 } else {
205- expression.staticElement = constructor;
202+ expression.element = constructor;
206203 }
207204 } else {
208205 // TODO(brianwilkerson): Report this error.
0 commit comments