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

Side by Side Diff: pkg/dartdoc/lib/mirrors_util.dart

Issue 11348036: Alignments for the ClassMirror interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library('mirrors.util'); 5 #library('mirrors.util');
6 6
7 // TODO(rnystrom): Use "package:" URL (#4968). 7 // TODO(rnystrom): Use "package:" URL (#4968).
8 #import('mirrors.dart'); 8 #import('mirrors.dart');
9 #import('../../../lib/compiler/implementation/util/characters.dart'); 9 #import('../../../lib/compiler/implementation/util/characters.dart');
10 10
11 //------------------------------------------------------------------------------ 11 //------------------------------------------------------------------------------
12 // Utility functions for using the Mirror API 12 // Utility functions for using the Mirror API
13 //------------------------------------------------------------------------------ 13 //------------------------------------------------------------------------------
14 14
15 /** 15 /**
16 * Returns an iterable over the type declarations directly inheriting from 16 * Returns an iterable over the type declarations directly inheriting from
17 * the declaration of this type. 17 * the declaration of this type.
18 */ 18 */
19 Iterable<ClassMirror> computeSubdeclarations(ClassMirror type) { 19 Iterable<ClassMirror> computeSubdeclarations(ClassMirror type) {
20 type = type.declaration; 20 type = type.originalDeclaration;
21 var subtypes = <ClassMirror>[]; 21 var subtypes = <ClassMirror>[];
22 type.system.libraries.forEach((_, library) { 22 type.system.libraries.forEach((_, library) {
23 for (ClassMirror otherType in library.classes.values) { 23 for (ClassMirror otherType in library.classes.values) {
24 var superClass = otherType.superclass; 24 var superClass = otherType.superclass;
25 if (superClass !== null) { 25 if (superClass !== null) {
26 superClass = superClass.declaration; 26 superClass = superClass.originalDeclaration;
27 if (type.library === superClass.library) { 27 if (type.library === superClass.library) {
28 if (superClass == type) { 28 if (superClass == type) {
29 subtypes.add(otherType); 29 subtypes.add(otherType);
30 } 30 }
31 } 31 }
32 } 32 }
33 final superInterfaces = otherType.interfaces; 33 final superInterfaces = otherType.superinterfaces;
34 for (ClassMirror superInterface in superInterfaces) { 34 for (ClassMirror superInterface in superInterfaces) {
35 superInterface = superInterface.declaration; 35 superInterface = superInterface.originalDeclaration;
36 if (type.library === superInterface.library) { 36 if (type.library === superInterface.library) {
37 if (superInterface == type) { 37 if (superInterface == type) {
38 subtypes.add(otherType); 38 subtypes.add(otherType);
39 } 39 }
40 } 40 }
41 } 41 }
42 } 42 }
43 }); 43 });
44 return subtypes; 44 return subtypes;
45 } 45 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 ClassMirror push(ClassMirror type) { 108 ClassMirror push(ClassMirror type) {
109 if (type.superclass !== null) { 109 if (type.superclass !== null) {
110 if (type.superclass.isObject) { 110 if (type.superclass.isObject) {
111 object = type.superclass; 111 object = type.superclass;
112 } else { 112 } else {
113 queue.addFirst(type.superclass); 113 queue.addFirst(type.superclass);
114 } 114 }
115 } 115 }
116 queue.addAll(type.interfaces); 116 queue.addAll(type.superinterfaces);
117 return type; 117 return type;
118 } 118 }
119 119
120 ClassMirror next() { 120 ClassMirror next() {
121 ClassMirror type; 121 ClassMirror type;
122 if (queue.isEmpty) { 122 if (queue.isEmpty) {
123 if (object === null) { 123 if (object === null) {
124 throw new StateError("No more elements"); 124 throw new StateError("No more elements");
125 } 125 }
126 type = object; 126 type = object;
127 object = null; 127 object = null;
128 return type; 128 return type;
129 } else { 129 } else {
130 return push(queue.removeFirst()); 130 return push(queue.removeFirst());
131 } 131 }
132 } 132 }
133 133
134 bool get hasNext => !queue.isEmpty || object !== null; 134 bool get hasNext => !queue.isEmpty || object !== null;
135 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698