File tree Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 1+ ## 0.9.0+1
2+
3+ * Fix ` LibraryReader.classElements ` to return classes from parts, if they exist,
4+ as well as from the defining library file.
5+
16## 0.9.0
27
38* Introduce ` SharedPartBuilder ` for creating part files that can be merged
Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ class LibraryReader {
166166
167167 /// All of the `class` elements in this library.
168168 Iterable <ClassElement > get classElements =>
169- element.definingCompilationUnit. types;
169+ element.units. expand ((cu) => cu. types) ;
170170
171171 static Iterable <Element > _getElements (CompilationUnitMember member) {
172172 if (member is TopLevelVariableDeclaration ) {
Original file line number Diff line number Diff line change 11name : source_gen
2- version : 0.9.0
2+ version : 0.9.0+1
33author : Dart Team <misc@dartlang.org>
44description : Automated source code generation for Dart.
55homepage : https://github.com/dart-lang/source_gen
Original file line number Diff line number Diff line change @@ -14,23 +14,39 @@ final _source = r'''
1414 export 'package:source_gen/source_gen.dart' show Generator;
1515 import 'dart:async' show Stream;
1616
17+ part 'part.dart';
18+
1719 class Example {}
1820''' ;
1921
22+ final _partSource = r'''
23+ part of 'source.dart';
24+
25+ class PartClass {}
26+ ''' ;
27+
2028void main () {
2129 LibraryReader library;
2230
2331 setUpAll (() async {
24- library = await resolveSource (
25- _source,
32+ library = await resolveSources (
33+ { 'a|source.dart' : _source, 'a|part.dart' : _partSource} ,
2634 (r) async => new LibraryReader (await r.findLibraryByName ('test_lib' )),
2735 );
2836 });
2937
38+ test ('class count' , () {
39+ expect (library.classElements, hasLength (2 ));
40+ });
41+
3042 test ('should return a type not exported' , () {
3143 expect (library.findType ('Example' ), _isClassElement);
3244 });
3345
46+ test ('should return a type from a part' , () {
47+ expect (library.findType ('PartClass' ), _isClassElement);
48+ });
49+
3450 test ('should return a type exported from dart:' , () {
3551 expect (library.findType ('LinkedHashMap' ), _isClassElement);
3652 });
You can’t perform that action at this time.
0 commit comments