Chromium Code Reviews| Index: pkg/docgen/lib/src/models/class.dart |
| diff --git a/pkg/docgen/lib/src/models/class.dart b/pkg/docgen/lib/src/models/class.dart |
| index 555b1ddb9cd6f22284e6edd4712ded743dbb72fe..4bcbb65433c9a0f7a1881a2d0e99ad055e93024b 100644 |
| --- a/pkg/docgen/lib/src/models/class.dart |
| +++ b/pkg/docgen/lib/src/models/class.dart |
| @@ -4,6 +4,8 @@ |
| library docgen.models.clazz; |
| +import 'dart:collection'; |
| + |
| import '../exports/dart2js_mirrors.dart' as dart2js_mirrors; |
| import '../exports/mirrors_util.dart' as dart2js_util; |
| import '../exports/source_mirrors.dart'; |
| @@ -86,8 +88,8 @@ class Class extends OwnedIndexable<dart2js_mirrors.Dart2JsInterfaceTypeMirror> |
| interfaces = superinterfaces.toList(); |
| variables = createVariables( |
| dart2js_util.variablesOf(classMirror.declarations), this); |
| - methods = createMethods(classMirror.declarations.values.where( |
| - (mirror) => mirror is MethodMirror), this); |
| + methods = createMethods(new TypeOfIterable<MethodMirror>( |
|
herhut
2014/04/28 08:24:41
Maybe rather expose [anyMethodOf] and use that. Wo
kevmoo
2014/04/28 09:23:01
Done.
|
| + classMirror.declarations.values), this); |
| // Tell superclass that you are a subclass, unless you are not |
| // visible or an intermediary mixin class. |
| @@ -243,3 +245,29 @@ class Class extends OwnedIndexable<dart2js_mirrors.Dart2JsInterfaceTypeMirror> |
| bool isValidMirror(DeclarationMirror mirror) => mirror is ClassMirror; |
| } |
| + |
| +class TypeOfIterable<TTarget> extends IterableBase<TTarget> { |
|
herhut
2014/04/28 08:24:41
Nit: I prefer using just T for the type variable b
|
| + final Iterable _source; |
| + |
| + TypeOfIterable(this._source); |
| + |
| + Iterator<TTarget> get iterator => |
| + new _TypeOfIterator<TTarget>(_source.iterator); |
| +} |
| + |
| +class _TypeOfIterator<TTarget> implements Iterator<TTarget> { |
| + final Iterator _source; |
| + |
| + TTarget get current => _source.current as TTarget; |
|
herhut
2014/04/28 08:24:41
Do you really need the runtime check via as here?
|
| + |
| + _TypeOfIterator(this._source); |
| + |
| + bool moveNext() { |
| + while(_source.moveNext()) { |
| + if (_source.current is TTarget) { |
| + return true; |
| + } |
| + } |
| + return false; |
| + } |
| +} |