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

Side by Side Diff: runtime/lib/mirrors_patch.dart

Issue 287523003: Improve error messages in MirrorSystem.findLibrary. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 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 import "dart:_internal" as _symbol_dev; 5 import "dart:_internal" as _symbol_dev;
6 6
7 /** 7 /**
8 * Returns a [MirrorSystem] for the current isolate. 8 * Returns a [MirrorSystem] for the current isolate.
9 */ 9 */
10 patch MirrorSystem currentMirrorSystem() { 10 patch MirrorSystem currentMirrorSystem() {
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 patch ClassMirror reflectClass(Type key) { 30 patch ClassMirror reflectClass(Type key) {
31 return _Mirrors.reflectClass(key); 31 return _Mirrors.reflectClass(key);
32 } 32 }
33 33
34 patch TypeMirror reflectType(Type key) { 34 patch TypeMirror reflectType(Type key) {
35 return _Mirrors.reflectType(key); 35 return _Mirrors.reflectType(key);
36 } 36 }
37 37
38 patch class MirrorSystem { 38 patch class MirrorSystem {
39 /* patch */ LibraryMirror findLibrary(Symbol libraryName) {
40 var candidates =
41 libraries.values.where((lib) => lib.simpleName == libraryName);
42 if (candidates.length == 1) {
43 return candidates.single;
44 }
45 if (candidates.length > 1) {
46 var uris = candidates.map((lib) => lib.uri.toString()).toList();
47 throw new Exception("There are multiple libraries named "
48 "'${getName(libraryName)}': $uris");
49 }
50 throw new Exception("There is no library named '${getName(libraryName)}'");
51 }
52
39 /* patch */ static String getName(Symbol symbol) { 53 /* patch */ static String getName(Symbol symbol) {
40 String string = _symbol_dev.Symbol.getName(symbol); 54 String string = _symbol_dev.Symbol.getName(symbol);
41 55
42 // get:foo -> foo 56 // get:foo -> foo
43 // set:foo -> foo= 57 // set:foo -> foo=
44 // get:_foo@xxx -> _foo 58 // get:_foo@xxx -> _foo
45 // set:_foo@xxx -> _foo= 59 // set:_foo@xxx -> _foo=
46 // Class._constructor@xxx -> Class._constructor 60 // Class._constructor@xxx -> Class._constructor
47 // _Class@xxx._constructor@xxx -> _Class._constructor 61 // _Class@xxx._constructor@xxx -> _Class._constructor
48 // lib._S@xxx with lib._M1@xxx, lib._M2@xxx -> lib._S with lib._M1, lib._M2 62 // lib._S@xxx with lib._M1@xxx, lib._M2@xxx -> lib._S with lib._M1, lib._M2
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // TODO(rmacnak): Eliminate this class. 105 // TODO(rmacnak): Eliminate this class.
92 class MirroredCompilationError { 106 class MirroredCompilationError {
93 final String message; 107 final String message;
94 108
95 MirroredCompilationError(this.message); 109 MirroredCompilationError(this.message);
96 110
97 String toString() { 111 String toString() {
98 return "Compile-time error during mirrored execution: <$message>"; 112 return "Compile-time error during mirrored execution: <$message>";
99 } 113 }
100 } 114 }
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