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

Unified Diff: sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart

Issue 57983002: Add mixin support to source mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 1 month 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
Index: sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart
diff --git a/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart b/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart
index 987b99661a26587a61737ece5134246b0cf010b7..86ef6581130bd97ffa44f03136fb6dbe14ac3a94 100644
--- a/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart
+++ b/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart
@@ -293,6 +293,8 @@ abstract class Dart2JsElementMirror extends Dart2JsDeclarationMirror {
String get simpleName => _element.name;
+ bool get isNameSynthetic => false;
+
/**
* Computes the first token for this declaration using the begin token of the
* element node or element position as indicator.
@@ -537,13 +539,7 @@ class Dart2JsLibraryMirror extends Dart2JsContainerMirror
*/
String get simpleName {
if (_library.libraryTag != null) {
- // TODO(ahe): Remove StringNode check when old syntax is removed.
- StringNode name = _library.libraryTag.name.asStringNode();
- if (name != null) {
- return name.dartString.slowToString();
- } else {
- return _library.libraryTag.name.toString();
- }
+ return _library.libraryTag.name.toString();
} else {
// Use the file name as script name.
String path = _library.canonicalUri.path;
@@ -847,6 +843,23 @@ class Dart2JsClassMirror extends Dart2JsContainerMirror
return null;
}
+ ClassMirror get mixin {
+ if (_class.isMixinApplication) {
+ MixinApplicationElement mixinApplication = _class;
+ return new Dart2JsInterfaceTypeMirror(mirrors,
+ mixinApplication.mixinType);
+ }
+ return this;
+ }
+
+ bool get isNameSynthetic {
+ if (_class.isMixinApplication) {
+ MixinApplicationElement mixinApplication = _class;
+ return mixinApplication.isUnnamedMixinApplication;
+ }
+ return false;
+ }
+
List<ClassMirror> get superinterfaces {
var list = <ClassMirror>[];
Link<DartType> link = _class.interfaces;
@@ -958,6 +971,10 @@ class Dart2JsTypedefMirror extends Dart2JsTypeElementMirror
List<ClassMirror> get superinterfaces => const <ClassMirror>[];
+ // TODO(johnniwinther): Refactor [TypedefMirror] to not extend [ClassMirror]
+ // and remove this.
+ ClassMirror get mixin => this;
+
bool get isClass => false;
bool get isOriginalDeclaration => true;
@@ -1077,6 +1094,8 @@ class Dart2JsInterfaceTypeMirror extends Dart2JsTypeElementMirror
InterfaceType get _interfaceType => _type;
+ bool get isNameSynthetic => originalDeclaration.isNameSynthetic;
+
String get qualifiedName => originalDeclaration.qualifiedName;
// TODO(johnniwinther): Substitute type arguments for type variables.
@@ -1096,6 +1115,14 @@ class Dart2JsInterfaceTypeMirror extends Dart2JsTypeElementMirror
// TODO(johnniwinther): Substitute type arguments for type variables.
List<ClassMirror> get superinterfaces => originalDeclaration.superinterfaces;
+ // TODO(johnniwinther): Substitute type arguments for type variables.
+ ClassMirror get mixin {
+ if (originalDeclaration.mixin == originalDeclaration) {
+ return this;
+ }
+ return originalDeclaration.mixin;
+ }
+
bool get isClass => originalDeclaration.isClass;
bool get isAbstract => originalDeclaration.isAbstract;
@@ -1170,7 +1197,7 @@ class Dart2JsFunctionTypeMirror extends Dart2JsTypeElementMirror
List<ParameterMirror> _parameters;
Dart2JsFunctionTypeMirror(Dart2JsMirrorSystem system,
- FunctionType functionType, this._functionSignature)
+ FunctionType functionType, this._functionSignature)
: super(system, functionType) {
assert (_functionSignature != null);
}
@@ -1209,6 +1236,8 @@ class Dart2JsFunctionTypeMirror extends Dart2JsTypeElementMirror
// TODO(johnniwinther): Substitute type arguments for type variables.
List<ClassMirror> get superinterfaces => originalDeclaration.superinterfaces;
+ ClassMirror get mixin => this;
+
bool get isClass => originalDeclaration.isClass;
bool get isPrivate => originalDeclaration.isPrivate;

Powered by Google App Engine
This is Rietveld 408576698