55import 'package:_fe_analyzer_shared/src/testing/id.dart' ;
66import 'package:analyzer/dart/ast/ast.dart' ;
77import 'package:analyzer/dart/ast/visitor.dart' ;
8- import 'package:analyzer/dart/element/element .dart' ;
8+ import 'package:analyzer/dart/element/element2 .dart' ;
99
10- MemberId computeMemberId (Element element) {
11- var enclosingElement = element.enclosingElement3 ;
12- if (enclosingElement is CompilationUnitElement ) {
13- var memberName = element.name ! ;
14- if (element is PropertyAccessorElement && element.isSetter ) {
10+ MemberId computeMemberId (Element2 element) {
11+ var enclosingElement = element.enclosingElement2 ;
12+ if (enclosingElement is LibraryElement2 ) {
13+ var memberName = element.name3 ! ;
14+ if (element is SetterElement ) {
1515 memberName += '=' ;
1616 }
1717 return MemberId .internal (memberName);
18- } else if (enclosingElement is InterfaceElement ) {
19- var memberName = element.name ! ;
20- var className = enclosingElement.name ;
18+ } else if (enclosingElement is InterfaceElement2 ) {
19+ var memberName = element.lookupName ! ;
20+ var className = enclosingElement.name3 ;
2121 return MemberId .internal (memberName, className: className);
22- } else if (enclosingElement is ExtensionElement ) {
23- var memberName = element.name! ;
24- var extensionName = enclosingElement.name;
25- if (element is PropertyAccessorElement ) {
26- memberName = '${element .isGetter ? 'get' : 'set' }#$memberName ' ;
22+ } else if (enclosingElement is ExtensionElement2 ) {
23+ var memberName = element.name3! ;
24+ var extensionName = enclosingElement.name3;
25+ if (element is PropertyAccessorElement2 ) {
26+ if (element is GetterElement ) {
27+ memberName = 'get#$memberName ' ;
28+ } else {
29+ memberName = 'set#$memberName ' ;
30+ }
2731 }
2832 return MemberId .internal ('$extensionName |$memberName ' );
2933 }
@@ -45,7 +49,7 @@ abstract class AstDataExtractor<T> extends GeneralizingAstVisitor<void>
4549 NodeId computeDefaultNodeId (AstNode node) =>
4650 NodeId (_nodeOffset (node), IdKind .node);
4751
48- T ? computeElementValue (Id id, Element element) => null ;
52+ T ? computeElementValue (Id id, Element2 element) => null ;
4953
5054 void computeForClass (Declaration node, Id ? id) {
5155 if (id == null ) return ;
@@ -65,7 +69,7 @@ abstract class AstDataExtractor<T> extends GeneralizingAstVisitor<void>
6569 registerValue (uri, _nodeOffset (node), id, value, node);
6670 }
6771
68- void computeForLibrary (LibraryElement library, Id ? id) {
72+ void computeForLibrary (LibraryElement2 library, Id ? id) {
6973 if (id == null ) return ;
7074 T ? value = computeElementValue (id, library);
7175 registerValue (uri, 0 , id, value, library);
@@ -101,12 +105,12 @@ abstract class AstDataExtractor<T> extends GeneralizingAstVisitor<void>
101105 T ? computeNodeValue (Id id, AstNode node);
102106
103107 Id createClassId (Declaration node) {
104- var element = node.declaredElement ! ;
105- return ClassId (element.name ! );
108+ var element = node.declaredFragment ! .element ;
109+ return ClassId (element.name3 ! );
106110 }
107111
108- Id createLibraryId (LibraryElement node) {
109- Uri uri = node.source. uri;
112+ Id createLibraryId (LibraryElement2 node) {
113+ Uri uri = node.uri;
110114 if (uri.path.startsWith (r'/C:' )) {
111115 // The `MemoryResourceProvider.convertPath` inserts '/C:' on Windows.
112116 uri = Uri (scheme: uri.scheme, path: uri.path.substring (3 ));
@@ -115,7 +119,7 @@ abstract class AstDataExtractor<T> extends GeneralizingAstVisitor<void>
115119 }
116120
117121 Id createMemberId (Declaration node) {
118- var element = node.declaredElement ! ;
122+ var element = node.declaredFragment ! .element ;
119123 return computeMemberId (element);
120124 }
121125
@@ -151,7 +155,7 @@ abstract class AstDataExtractor<T> extends GeneralizingAstVisitor<void>
151155
152156 @override
153157 void visitCompilationUnit (CompilationUnit node) {
154- var library = node.declaredElement ! .library ;
158+ var library = node.declaredFragment ! .element ;
155159 computeForLibrary (library, createLibraryId (library));
156160 super .visitCompilationUnit (node);
157161 }
0 commit comments