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

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: Rebased. 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
Index: pkg/dartdoc/lib/mirrors_util.dart
diff --git a/pkg/dartdoc/lib/mirrors_util.dart b/pkg/dartdoc/lib/mirrors_util.dart
index 150df5f63628d36f6119dbc3e000bd7c170e53dd..c5618988fb0565984e09db64cbe399564f97e581 100644
--- a/pkg/dartdoc/lib/mirrors_util.dart
+++ b/pkg/dartdoc/lib/mirrors_util.dart
@@ -30,7 +30,7 @@ Iterable<InterfaceMirror> computeSubdeclarations(InterfaceMirror type) {
}
}
}
- final superInterfaces = otherType.interfaces.getValues();
+ final superInterfaces = otherType.interfaces;
for (InterfaceMirror superInterface in superInterfaces) {
superInterface = superInterface.declaration;
if (type.library === superInterface.library) {
@@ -44,34 +44,6 @@ Iterable<InterfaceMirror> computeSubdeclarations(InterfaceMirror type) {
return subtypes;
}
-/**
- * Finds the mirror in [map] by the simple name [name]. If [constructorName] or
- * [operatorName] is provided, a constructor/operator method by that name is
- * returned.
- */
-Mirror findMirror(Map<Object,Mirror> map, String name,
- [String constructorName, String operatorName]) {
- var foundMirror = null;
- map.forEach((_, Mirror mirror) {
- if (mirror.simpleName == name) {
- if (constructorName !== null) {
- if (mirror is MethodMirror &&
- constructorName == mirror.constructorName) {
- foundMirror = mirror;
- }
- } else if (operatorName !== null) {
- if (mirror is MethodMirror &&
- operatorName == mirror.operatorName) {
- foundMirror = mirror;
- }
- } else {
- foundMirror = mirror;
- }
- }
- });
- return foundMirror;
-}
-
LibraryMirror findLibrary(MemberMirror member) {
ObjectMirror owner = member.surroundingDeclaration;
if (owner is LibraryMirror) {
@@ -100,3 +72,62 @@ int getLocationColumn(Location location) {
}
return column;
}
+
+class HierarchyIterable implements Iterable<InterfaceMirror> {
Lasse Reichstein Nielsen 2012/10/04 07:41:19 Consider whether Iterable is necessary in the name
Johnni Winther 2012/10/04 12:46:21 I can't think of a sensible name without Iterable.
+ 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, next the superinterface
+ * relation and finally is [Object] visited.
Lasse Reichstein Nielsen 2012/10/04 07:41:19 Why do you mention Object explicitly? It is in the
Johnni Winther 2012/10/04 12:46:21 Done.
+ */
+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;
+}

Powered by Google App Engine
This is Rietveld 408576698