Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(817)

Unified Diff: pkg/dartdoc/lib/mirrors_util.dart

Issue 10985085: Members and comments inherited in dartdoc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/dartdoc/lib/dartdoc.dart ('k') | pkg/dartdoc/lib/src/client/client-shared.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dartdoc/lib/mirrors_util.dart
diff --git a/pkg/dartdoc/lib/mirrors_util.dart b/pkg/dartdoc/lib/mirrors_util.dart
index fc2cf8c329881f96f5998f4738a8212009bd75f8..bbd6b49a4a4c4d348cdb6c5577ca43cf12073320 100644
--- a/pkg/dartdoc/lib/mirrors_util.dart
+++ b/pkg/dartdoc/lib/mirrors_util.dart
@@ -72,3 +72,64 @@ int getLocationColumn(Location location) {
}
return column;
}
+
+class HierarchyIterable implements Iterable<InterfaceMirror> {
+ final bool includeType;
+ final InterfaceMirror type;
+
+ HierarchyIterable(this.type, {bool includeType})
+ : this.includeType = includeType;
+
+ Iterator<InterfaceMirror> iterator() =>
+ new HierarchyIterator(type, includeType: includeType);
+}
+
+/**
+ * [HierarchyIterator] iterates through the class hierarchy of the provided
+ * type.
+ *
+ * First is the superclass relation is traversed, skipping [Object], next the
+ * superinterface relation and finally is [Object] visited. The supertypes are
+ * visited in breadth first order and a superinterface is visited more than once
+ * if implemented through multiple supertypes.
+ */
+class HierarchyIterator implements Iterator<InterfaceMirror> {
+ final Queue<InterfaceMirror> queue = new Queue<InterfaceMirror>();
+ InterfaceMirror object;
+
+ HierarchyIterator(InterfaceMirror type, {bool includeType}) {
+ if (includeType) {
+ queue.add(type);
+ } else {
+ push(type);
+ }
+ }
+
+ InterfaceMirror push(InterfaceMirror type) {
+ if (type.superclass !== null) {
+ if (type.superclass.isObject) {
+ object = type.superclass;
+ } else {
+ queue.addFirst(type.superclass);
+ }
+ }
+ queue.addAll(type.interfaces);
+ return type;
+ }
+
+ InterfaceMirror next() {
+ InterfaceMirror type;
+ if (queue.isEmpty()) {
+ if (object === null) {
+ throw new NoMoreElementsException();
+ }
+ type = object;
+ object = null;
+ return type;
+ } else {
+ return push(queue.removeFirst());
+ }
+ }
+
+ bool hasNext() => !queue.isEmpty() || object !== null;
+}
« no previous file with comments | « pkg/dartdoc/lib/dartdoc.dart ('k') | pkg/dartdoc/lib/src/client/client-shared.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698