OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Implementation of the smoke services using mirrors. | 5 /// Implementation of the smoke services using mirrors. |
6 library smoke.mirrors; | 6 library smoke.mirrors; |
7 | 7 |
8 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
9 import 'package:smoke/smoke.dart'; | 9 import 'package:smoke/smoke.dart'; |
10 import 'package:logging/logging.dart'; | 10 import 'package:logging/logging.dart'; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // Interceptor is leaked by dart2js. It has the same methods as Object | 215 // Interceptor is leaked by dart2js. It has the same methods as Object |
216 // (including noSuchMethod), and our code above assumes that it doesn't | 216 // (including noSuchMethod), and our code above assumes that it doesn't |
217 // exist. Most queries exclude Object, so they should exclude Interceptor | 217 // exist. Most queries exclude Object, so they should exclude Interceptor |
218 // too. We don't check for t.simpleName == #Interceptor because depending on | 218 // too. We don't check for t.simpleName == #Interceptor because depending on |
219 // dart2js optimizations it may be #Interceptor or #num/Interceptor. | 219 // dart2js optimizations it may be #Interceptor or #num/Interceptor. |
220 // Checking for a private library seems to reliably filter this out. | 220 // Checking for a private library seems to reliably filter this out. |
221 if (t != null && t.owner != null && t.owner.isPrivate) { | 221 if (t != null && t.owner != null && t.owner.isPrivate) { |
222 t = _objectType; | 222 t = _objectType; |
223 } | 223 } |
224 return t; | 224 return t; |
225 } on UnsupportedError catch (e) { | 225 } on UnsupportedError catch (_) { |
226 // Note: dart2js throws UnsupportedError when the type is not reflectable. | 226 // Note: dart2js throws UnsupportedError when the type is not reflectable. |
227 return _objectType; | 227 return _objectType; |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 MethodMirror _findMethod(ClassMirror type, Symbol name) { | 231 MethodMirror _findMethod(ClassMirror type, Symbol name) { |
232 do { | 232 do { |
233 var member = type.declarations[name]; | 233 var member = type.declarations[name]; |
234 if (member is MethodMirror) return member; | 234 if (member is MethodMirror) return member; |
235 type = type.superclass; | 235 type = type.superclass; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 String toString() => (new StringBuffer() | 315 String toString() => (new StringBuffer() |
316 ..write('(mirror-based-declaration ') | 316 ..write('(mirror-based-declaration ') |
317 ..write(name) | 317 ..write(name) |
318 ..write( | 318 ..write( |
319 isField ? ' (field) ' : (isProperty ? ' (property) ' : ' (method) ')) | 319 isField ? ' (field) ' : (isProperty ? ' (property) ' : ' (method) ')) |
320 ..write(isFinal ? 'final ' : '') | 320 ..write(isFinal ? 'final ' : '') |
321 ..write(isStatic ? 'static ' : '') | 321 ..write(isStatic ? 'static ' : '') |
322 ..write(annotations) | 322 ..write(annotations) |
323 ..write(')')).toString(); | 323 ..write(')')).toString(); |
324 } | 324 } |
OLD | NEW |