@@ -30,6 +30,7 @@ class AnnotatedElement {
3030
3131 const AnnotatedElement (this .annotation, this .element2);
3232
33+ @deprecated
3334 Element get element => element2.asElement! ;
3435
3536 Metadata ? get metadata2 {
@@ -40,17 +41,20 @@ class AnnotatedElement {
4041 }
4142}
4243
43- /// A high-level wrapper API with common functionality for [LibraryElement ] .
44+ /// A high-level wrapper API with common functionality for [LibraryElement2 ] .
4445class LibraryReader {
4546 final LibraryElement2 element2;
4647
48+ @deprecated
4749 LibraryReader (LibraryElement element) : this .v2 (element.asElement2);
4850
4951 LibraryReader .v2 (this .element2);
5052
53+ @deprecated
5154 LibraryElement get element => element2.asElement;
5255
5356 /// All of the declarations in this library.
57+ @deprecated
5458 Iterable <Element > get allElements => [
5559 element,
5660 ...element.topLevelElements,
@@ -63,13 +67,15 @@ class LibraryReader {
6367 Iterable <Element2 > get allElements2 => [element2, ...element2.children2];
6468
6569 /// All of the elements representing classes in this library.
70+ @deprecated
6671 Iterable <ClassElement > get classes =>
6772 element.units.expand ((cu) => cu.classes);
6873
6974 /// All of the elements representing classes in this library.
7075 Iterable <ClassElement2 > get classes2 => element2.classes;
7176
7277 /// All of the elements representing enums in this library.
78+ @deprecated
7379 Iterable <EnumElement > get enums => element.units.expand ((cu) => cu.enums);
7480
7581 /// All of the elements representing enums in this library.
@@ -80,19 +86,14 @@ class LibraryReader {
8086 TypeChecker checker, {
8187 bool throwOnUnresolved = true ,
8288 }) sync * {
83- for (final element in allElements ) {
84- final annotation = checker.firstAnnotationOf (
89+ for (final element in allElements2 ) {
90+ final annotation = checker.firstAnnotationOf2 (
8591 element,
8692 throwOnUnresolved: throwOnUnresolved,
8793 );
8894
89- final element2 = element.asElement2;
90- if (element2 == null ) {
91- return ;
92- }
93-
9495 if (annotation != null ) {
95- yield AnnotatedElement (ConstantReader (annotation), element2 );
96+ yield AnnotatedElement (ConstantReader (annotation), element );
9697 }
9798 }
9899 }
@@ -126,13 +127,13 @@ class LibraryReader {
126127 TypeChecker checker, {
127128 bool throwOnUnresolved = true ,
128129 }) sync * {
129- for (final element in allElements ) {
130- final annotation = checker.firstAnnotationOfExact (
130+ for (final element in allElements2 ) {
131+ final annotation = checker.firstAnnotationOfExact2 (
131132 element,
132133 throwOnUnresolved: throwOnUnresolved,
133134 );
134135 if (annotation != null ) {
135- yield AnnotatedElement (ConstantReader (annotation), element.asElement2 ! );
136+ yield AnnotatedElement (ConstantReader (annotation), element);
136137 }
137138 }
138139 }
@@ -147,12 +148,12 @@ class LibraryReader {
147148 return type is ClassElement ? type : null ;
148149 }
149150
150- /// Returns a top-level [ClassElement ] publicly visible in by [name] .
151+ /// Returns a top-level [ClassElement2 ] publicly visible in by [name] .
151152 ///
152- /// Unlike [LibraryElement .getClass] , this also correctly traverses
153+ /// Unlike [LibraryElement2 .getClass] , this also correctly traverses
153154 /// identifiers that are accessible via one or more `export` directives.
154155 ClassElement2 ? findType2 (String name) {
155- final type = element .exportNamespace.get2 (name);
156+ final type = element2 .exportNamespace.get2 (name);
156157 return type is ClassElement2 ? type : null ;
157158 }
158159
@@ -166,6 +167,7 @@ class LibraryReader {
166167 ///
167168 /// This is a typed convenience function for using [pathToUrl] , and the same
168169 /// API restrictions hold around supported schemes and relative paths.
170+ @deprecated
169171 Uri pathToElement (Element element) => pathToUrl (element.source! .uri);
170172
171173 /// Returns a [Uri] from the current library to the target [element] .
@@ -210,7 +212,7 @@ class LibraryReader {
210212 if (to.pathSegments.length > 1 && to.pathSegments[1 ] == 'lib' ) {
211213 return assetToPackageUrl (to);
212214 }
213- var from = element.source .uri;
215+ var from = element2 .uri;
214216 // Normalize (convert to an asset: URL).
215217 from = normalizeUrl (from);
216218 if (_isRelative (from, to)) {
0 commit comments