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

Unified Diff: reflectable/lib/src/transformer_implementation.dart

Issue 1181153003: Add `.type` to the transformed InstanceMirror. (Closed) Base URL: https://github.com/dart-lang/reflectable.git@master
Patch Set: Clarify comment Created 5 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test_reflectable/test/reflect_type_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: reflectable/lib/src/transformer_implementation.dart
diff --git a/reflectable/lib/src/transformer_implementation.dart b/reflectable/lib/src/transformer_implementation.dart
index eb2e12665b94a711ab5cceaf514ddfdf513bbe2a..d9bf08f01afce9aac6512fed1a83ab9f607c0b3d 100644
--- a/reflectable/lib/src/transformer_implementation.dart
+++ b/reflectable/lib/src/transformer_implementation.dart
@@ -119,8 +119,8 @@ class ClassDomain {
/// Returns a String with the textual representation of the declarations-map.
String get declarationsString {
- Iterable<String> declarationParts = declarations
- .map((ExecutableElement instanceMember) {
+ Iterable<String> declarationParts = declarations.map(
+ (ExecutableElement instanceMember) {
return '"${instanceMember.name}": '
'new MethodMirrorImpl("${instanceMember.name}", '
'${_declarationDescriptor(instanceMember)}, this)';
@@ -764,9 +764,15 @@ class TransformerImplementation {
/// is the class modeled by [classElement].
String _staticClassMirrorCode(ClassDomain classDomain) {
String declarationsString = classDomain.declarationsString;
+ String simpleName = classDomain.classElement.name;
+ // When/if we have library-mirrors there could be a generic implementation:
+ // String get qualifiedName => "${owner.qualifiedName}.${simpleName}";
+ String qualifiedName =
+ "${classDomain.classElement.library.name}.$simpleName";
return """
class ${classDomain.staticClassMirrorName} extends ClassMirrorUnimpl {
- final String simpleName = "${classDomain.classElement.name}";
+ final String simpleName = "$simpleName";
+ final String qualifiedName = "$qualifiedName";
Map<String, MethodMirror> _declarationsCache;
@@ -1121,6 +1127,8 @@ class ${classDomain.staticClassMirrorName} extends ClassMirrorUnimpl {
String rest = "";
rest += instanceMethodFilter(classDomain.reflectorDomain.capabilities);
rest += _staticInstanceMirrorInvokeCode(classDomain);
+ rest += " ClassMirror get type => "
+ "new ${classDomain.staticClassMirrorName}();\n";
// TODO(eernst): add code for other mirror methods than `invoke`.
return """
class ${classDomain.staticInstanceMirrorName} extends InstanceMirrorUnimpl {
« no previous file with comments | « no previous file | test_reflectable/test/reflect_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698