Skip to content

Commit 46d8d1d

Browse files
author
Harry Terkelsen
authored
Verify that all elements have a parent (#31)
Fixes flutter#15
1 parent 3fec061 commit 46d8d1d

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

bin/debug_info.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ main(args) async {
2727
}
2828

2929
validateSize(info, debugLibName);
30+
validateParents(info);
3031
compareGraphs(info);
3132
verifyDeps(info);
3233
}
@@ -74,6 +75,30 @@ validateSize(AllInfo info, String debugLibName) {
7475
}
7576
}
7677

78+
/// Validates that every element in the model has a parent (except libraries).
79+
validateParents(AllInfo info) {
80+
final parentlessInfos = new Set<Info>();
81+
82+
failIfNoParents(List<Info> infos) {
83+
for (var info in infos) {
84+
if (info.parent == null) {
85+
parentlessInfos.add(info);
86+
}
87+
}
88+
}
89+
90+
failIfNoParents(info.functions);
91+
failIfNoParents(info.typedefs);
92+
failIfNoParents(info.classes);
93+
failIfNoParents(info.fields);
94+
failIfNoParents(info.closures);
95+
if (parentlessInfos.isEmpty) {
96+
_pass('all elements have a parent');
97+
} else {
98+
_fail('${parentlessInfos.length} elements have no parent');
99+
}
100+
}
101+
77102
class _SizeTracker extends RecursiveInfoVisitor {
78103
/// A library name for which to print debugging information (if not null).
79104
final String _debugLibName;

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: dart2js_info
2-
version: 0.5.6+2
2+
version: 0.5.6+3
33
description: >
44
Libraries and tools to process data produced when running dart2js with
55
--dump-info.

0 commit comments

Comments
 (0)