Implement JsMethodMirror.constructorName.
BUG=http://dartbug.com/11608 R=kustermann@google.com Review URL: https://codereview.chromium.org//18216002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24597 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -834,11 +834,20 @@ class JsMethodMirror extends JsDeclarationMirror implements MethodMirror {
|
||||
return _metadata.map(reflect).toList();
|
||||
}
|
||||
|
||||
Symbol get constructorName {
|
||||
// TODO(ahe): I believe it is more appropriate to throw an exception or
|
||||
// return null.
|
||||
if (!isConstructor) return const Symbol('');
|
||||
String name = n(simpleName);
|
||||
int index = name.indexOf('.');
|
||||
if (index == -1) return const Symbol('');
|
||||
return s(name.substring(index + 1));
|
||||
}
|
||||
|
||||
// TODO(ahe): Implement these.
|
||||
bool get isAbstract => throw new UnimplementedError();
|
||||
bool get isRegularMethod => throw new UnimplementedError();
|
||||
bool get isOperator => throw new UnimplementedError();
|
||||
Symbol get constructorName => throw new UnimplementedError();
|
||||
bool get isConstConstructor => throw new UnimplementedError();
|
||||
bool get isGenerativeConstructor => throw new UnimplementedError();
|
||||
bool get isRedirectingConstructor => throw new UnimplementedError();
|
||||
|
||||
@@ -52,4 +52,14 @@ main() {
|
||||
for (var constructor in bizConstructors.values) {
|
||||
expect('[]', constructor.parameters);
|
||||
}
|
||||
|
||||
expect('[s()]',
|
||||
fooConstructors.values.map((m) => m.constructorName).toList());
|
||||
expect('[s()]',
|
||||
barConstructors.values.map((m) => m.constructorName).toList());
|
||||
expect('[s(named)]',
|
||||
bazConstructors.values.map((m) => m.constructorName).toList());
|
||||
expect('[s(), s(named)]',
|
||||
bizConstructors.values.map((m) => m.constructorName).toList()
|
||||
..sort(compareSymbols));
|
||||
}
|
||||
|
||||
@@ -103,3 +103,7 @@ stringify(value) {
|
||||
}
|
||||
|
||||
expect(expected, actual) => Expect.stringEquals(expected, stringify(actual));
|
||||
|
||||
compareSymbols(Symbol a, Symbol b) {
|
||||
return MirrorSystem.getName(a).compareTo(MirrorSystem.getName(b));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user