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:
ahe@google.com
2013-06-28 17:13:39 +00:00
parent f1f9392151
commit d477c3f663
3 changed files with 24 additions and 1 deletions
+10 -1
View File
@@ -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();
+10
View File
@@ -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));
}
+4
View File
@@ -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));
}