1
- // ignore_for_file: implementation_imports, deprecated_member_use
1
+ // ignore_for_file: implementation_imports
2
2
3
3
import 'dart:async' ;
4
4
5
- import 'package:analyzer/dart/element/element .dart' ;
5
+ import 'package:analyzer/dart/element/element2 .dart' ;
6
6
import 'package:analyzer/dart/element/type.dart' ;
7
7
import 'package:build/build.dart' ;
8
8
import 'package:dart_style/dart_style.dart' as dart_style;
@@ -20,7 +20,7 @@ Future<String> generateForElement<T>(
20
20
String name,
21
21
) async {
22
22
final elements =
23
- libraryReader.allElements.where ((e) => e.name == name).toList ();
23
+ libraryReader.allElements.where ((e) => e.name3 == name).toList ();
24
24
25
25
if (elements.isEmpty) {
26
26
throw ArgumentError .value (
@@ -30,13 +30,13 @@ Future<String> generateForElement<T>(
30
30
);
31
31
}
32
32
33
- Element element;
33
+ Element2 element;
34
34
35
35
if (elements.length == 1 ) {
36
36
element = elements[0 ];
37
37
} else {
38
38
final rootProperties =
39
- elements.whereType <PropertyInducingElement >().toList ();
39
+ elements.whereType <PropertyInducingElement2 >().toList ();
40
40
if (rootProperties.length == 1 ) {
41
41
element = rootProperties[0 ];
42
42
} else {
@@ -48,18 +48,18 @@ Future<String> generateForElement<T>(
48
48
49
49
if (annotation == null ) {
50
50
final annotationFromTestLib =
51
- element.metadata
51
+ ( element as Annotatable ).metadata2.annotations
52
52
.map ((ea) => ea.computeConstantValue ()! )
53
53
.where ((obj) {
54
54
if (obj.type is InterfaceType ) {
55
- final uri = (obj.type as InterfaceType ).element.source .uri;
55
+ final uri = (obj.type as InterfaceType ).element3.library2 .uri;
56
56
return uri.isScheme ('package' ) &&
57
57
uri.pathSegments.first == testPackageName;
58
58
}
59
59
60
60
return false ;
61
61
})
62
- .where ((obj) => obj.type! .element ! .name == T .toString ())
62
+ .where ((obj) => obj.type! .element3 ! .name3 == T .toString ())
63
63
.toList ();
64
64
65
65
String msg;
@@ -70,7 +70,7 @@ Future<String> generateForElement<T>(
70
70
NOTE: Could not find an annotation that matched
71
71
${generator .typeChecker }.
72
72
Using a annotation with the same name from the synthetic library instead
73
- ${(annotation .type as InterfaceType ).element . source .uri }#${annotation .type !.element !. name }''' ;
73
+ ${(annotation .type as InterfaceType ).element3 . library2 . firstFragment . source .uri }#${annotation .type !.element3 !. name3 }''' ;
74
74
} else {
75
75
msg = '''
76
76
NOTE: Could not find an annotation that matched
0 commit comments