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

Side by Side Diff: pkg/serialization/lib/src/serialization_rule.dart

Issue 86193003: Remove use of deprecated mirror API from pkg/serialization. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of serialization; 5 part of serialization;
6 6
7 // TODO(alanknight): We should have an example and tests for subclassing 7 // TODO(alanknight): We should have an example and tests for subclassing
8 // serialization rule rather than using the hard-coded ClosureToMap rule. And 8 // serialization rule rather than using the hard-coded ClosureToMap rule. And
9 // possibly an abstract superclass that's designed to be subclassed that way. 9 // possibly an abstract superclass that's designed to be subclassed that way.
10 /** 10 /**
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 var lookup = r.objectNamed(type, (x) => null); 403 var lookup = r.objectNamed(type, (x) => null);
404 if (lookup != null) return lookup; 404 if (lookup != null) return lookup;
405 var name = qualifiedName.substring(0, separatorIndex); 405 var name = qualifiedName.substring(0, separatorIndex);
406 // This is very ugly. The library name for an unnamed library is its URI. 406 // This is very ugly. The library name for an unnamed library is its URI.
407 // That can't be constructed as a Symbol, so we can't use findLibrary. 407 // That can't be constructed as a Symbol, so we can't use findLibrary.
408 // So follow one or the other path depending if it has a colon, which we 408 // So follow one or the other path depending if it has a colon, which we
409 // assume is in any URI and can't be in a Symbol. 409 // assume is in any URI and can't be in a Symbol.
410 if (name.contains(":")) { 410 if (name.contains(":")) {
411 var uri = Uri.parse(name); 411 var uri = Uri.parse(name);
412 var libMirror = currentMirrorSystem().libraries[uri]; 412 var libMirror = currentMirrorSystem().libraries[uri];
413 return libMirror.classes[new Symbol(type)]; 413 var candidate = libMirror.declarations[new Symbol(type)];
414 return candidate is ClassMirror ? candidate : null;
414 } else { 415 } else {
415 var symbol = new Symbol(name); 416 var symbol = new Symbol(name);
416 var typeSymbol = new Symbol(type); 417 var typeSymbol = new Symbol(type);
417 var libMirror = currentMirrorSystem().libraries.values.firstWhere( 418 for (var libMirror in currentMirrorSystem().libraries.values) {
418 (lib) => lib.simpleName == symbol && lib.classes[typeSymbol] != null); 419 if (libMirror.simpleName != symbol) continue;
419 return libMirror.classes[typeSymbol]; 420 var candidate = libMirror.declarations[typeSymbol];
421 if (candidate != null && candidate is ClassMirror) return candidate;
422 }
423 return null;
420 } 424 }
421 } 425 }
422 } 426 }
423 427
424 /** 428 /**
425 * This provides an abstract superclass for writing your own rules specific to 429 * This provides an abstract superclass for writing your own rules specific to
426 * a class. It makes some assumptions about behaviour, and so can have a 430 * a class. It makes some assumptions about behaviour, and so can have a
427 * simpler set of methods that need to be implemented in order to subclass it. 431 * simpler set of methods that need to be implemented in order to subclass it.
428 * 432 *
429 */ 433 */
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 int get length => _raw.length; 572 int get length => _raw.length;
569 573
570 void set length(int value) => _throw(); 574 void set length(int value) => _throw();
571 575
572 void operator []=(int index, value) => _throw(); 576 void operator []=(int index, value) => _throw();
573 577
574 void _throw() { 578 void _throw() {
575 throw new UnsupportedError("Not modifiable"); 579 throw new UnsupportedError("Not modifiable");
576 } 580 }
577 } 581 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698