65718c56df
For example firstMatching -> firstWhere. BUG= http://dartbug.com/8664 BUG= http://dartbug.com/8337 Review URL: https://codereview.chromium.org//12537009 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19880 260f80e4-7a28-3924-810f-c04153c831b5
15 lines
500 B
Dart
15 lines
500 B
Dart
library metadata;
|
|
|
|
import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart';
|
|
|
|
/// Returns the metadata for the given string or null if not found.
|
|
InstanceMirror findMetadata(List<InstanceMirror> metadataList, String find) {
|
|
return metadataList.firstWhere(
|
|
(metadata) {
|
|
if (metadata is TypeInstanceMirror) {
|
|
return metadata.representedType.simpleName == find;
|
|
}
|
|
return metadata.type.simpleName == find;
|
|
}, orElse: () => null);
|
|
}
|