@@ -8,7 +8,9 @@ import 'compilation_unit_matcher/chainable_matcher.dart';
8
8
part 'compilation_unit_matcher/argument_matcher/argument_matcher.dart' ;
9
9
part 'compilation_unit_matcher/class_matcher/class_matcher.dart' ;
10
10
part 'compilation_unit_matcher/constructor_matcher/constructor_matcher.dart' ;
11
+ part 'compilation_unit_matcher/extends_matcher/extends_matcher.dart' ;
11
12
part 'compilation_unit_matcher/field_matcher/field_matcher.dart' ;
13
+ part 'compilation_unit_matcher/generic_matcher/generic_matcher.dart' ;
12
14
part 'compilation_unit_matcher/method_matcher/method_matcher.dart' ;
13
15
part 'compilation_unit_matcher/parameter_matcher/parameter_matcher.dart' ;
14
16
part 'compilation_unit_matcher/super_initializer_matcher/super_initializer_matcher.dart' ;
@@ -28,8 +30,10 @@ part 'compilation_unit_matcher/super_initializer_matcher/super_initializer_match
28
30
/// │ ├── SuperInitializerMatcher
29
31
/// │ │ └── ArgumentMatcher
30
32
/// │ └── ParameterMatcher
31
- /// └── MethodMatcher
32
- /// └── ParameterMatcher
33
+ /// ├── MethodMatcher
34
+ /// │ └── ParameterMatcher
35
+ /// └── ExtendsMatcher
36
+ ///
33
37
ClassMatcher containsClass (String className) => _ClassMatcherImpl ._(className);
34
38
35
39
/// Parses a string of Dart code into a FormattedCompilationUnit.
@@ -42,6 +46,9 @@ abstract interface class ArgumentMatcher {}
42
46
/// A matcher that checks if a CompilationUnit contains a class that matches
43
47
/// certain criteria.
44
48
abstract interface class ClassMatcher {
49
+ /// Chains a [ExtendsMatcher] that checks if the class extends a specific class.
50
+ ExtendsMatcher thatExtends (String className);
51
+
45
52
/// Chains a [FieldMatcher] that checks if the class contains a field with a
46
53
/// specific name.
47
54
///
@@ -56,7 +63,18 @@ abstract interface class ClassMatcher {
56
63
///
57
64
/// Use [isNullable] to match field nullability. If the value is not set, the
58
65
/// matcher will ignore the nullability of the field.
59
- FieldMatcher withField (String fieldName, {bool ? isNullable});
66
+ ///
67
+ /// Use [isFinal] to match final fields. If the value is not set, the matcher
68
+ /// will ignore the final status of the field
69
+ ///
70
+ /// Use [isLate] to match late fields. If the value is not set, the matcher
71
+ /// will ignore the late status of the field
72
+ FieldMatcher withField (
73
+ String fieldName, {
74
+ bool ? isNullable,
75
+ bool ? isFinal,
76
+ bool ? isLate,
77
+ });
60
78
61
79
/// Chains a [MethodMatcher] that checks if the class contains a method with a
62
80
/// specific name.
@@ -139,6 +157,11 @@ abstract interface class ConstructorMatcher {
139
157
});
140
158
}
141
159
160
+ /// A chainable matcher that matches the extension in a compilation unit.
161
+ abstract interface class ExtendsMatcher {
162
+ GenericMatcher withGeneric (String genericType);
163
+ }
164
+
142
165
/// A chainable matcher that matches a field in a compilation unit.
143
166
abstract interface class FieldMatcher {}
144
167
@@ -153,6 +176,9 @@ class FormattedCompilationUnit {
153
176
}
154
177
}
155
178
179
+ /// A chainable matcher that matches a generic type in a compilation unit.
180
+ abstract interface class GenericMatcher {}
181
+
156
182
/// Initializer types for parameters.
157
183
enum Initializer {
158
184
/// The parameter is initialized with `this` .
@@ -196,7 +222,7 @@ abstract interface class ParameterMatcher {}
196
222
/// A chainable matcher that matches a super initializer in a compilation unit.
197
223
abstract interface class SuperInitializerMatcher {
198
224
/// Chains an [ArgumentMatcher] that checks if the super initializer is called
199
- /// with a specific argument.
225
+ /// with a specific literal argument.
200
226
ArgumentMatcher withArgument (String value);
201
227
202
228
/// Chains an [ArgumentMatcher] that checks if the super initializer is called
0 commit comments