File tree Expand file tree Collapse file tree 3 files changed +49
-1
lines changed Expand file tree Collapse file tree 3 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 5
5
` build_extensions: { '.dart': ['.stub.dart', '.web.dart', '.vm.dart'] } `
6
6
* Avoid throwing when a type without a backing class is checked with
7
7
` TypeChecker ` .
8
+ * Include imports, exports, and part directives in ` LibraryReader.allElements ` .
9
+ This allows ` GeneratorForAnnotation ` to target annotated directives.
8
10
9
11
## 1.2.7
10
12
Original file line number Diff line number Diff line change @@ -34,7 +34,13 @@ class LibraryReader {
34
34
}
35
35
36
36
/// All of the declarations in this library.
37
- Iterable <Element > get allElements => [element, ...element.topLevelElements];
37
+ Iterable <Element > get allElements => [
38
+ element,
39
+ ...element.topLevelElements,
40
+ ...element.libraryImports,
41
+ ...element.libraryExports,
42
+ ...element.parts,
43
+ ];
38
44
39
45
/// All of the declarations in this library annotated with [checker] .
40
46
Iterable <AnnotatedElement > annotatedWith (
Original file line number Diff line number Diff line change @@ -134,6 +134,46 @@ void main() {
134
134
// **************************************************************************
135
135
136
136
// foo
137
+ '''
138
+ },
139
+ );
140
+ });
141
+
142
+ test ('applies to annotated directives' , () async {
143
+ final builder = LibraryBuilder (
144
+ _StubGenerator <Deprecated >(
145
+ 'Deprecated' ,
146
+ (element) => '// ${element .runtimeType }' ,
147
+ ),
148
+ );
149
+ await testBuilder (
150
+ builder,
151
+ {
152
+ 'a|lib/imported.dart' : '' ,
153
+ 'a|lib/part.dart' : 'part of \' file.dart\' ;' ,
154
+ 'a|lib/file.dart' : '''
155
+ library;
156
+ @deprecated
157
+ import 'imported.dart';
158
+ @deprecated
159
+ export 'imported.dart';
160
+ @deprecated
161
+ part 'part.dart';
162
+ '''
163
+ },
164
+ outputs: {
165
+ 'a|lib/file.g.dart' : '''
166
+ // GENERATED CODE - DO NOT MODIFY BY HAND
167
+
168
+ // **************************************************************************
169
+ // Generator: Deprecated
170
+ // **************************************************************************
171
+
172
+ // LibraryImportElementImpl
173
+
174
+ // LibraryExportElementImpl
175
+
176
+ // PartElementImpl
137
177
'''
138
178
},
139
179
);
You can’t perform that action at this time.
0 commit comments