OLD | NEW |
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 /// Generic utility functions. Stuff that should possibly be in core. | 5 /// Generic utility functions. Stuff that should possibly be in core. |
6 library pub.utils; | 6 library pub.utils; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import "dart:collection"; | 9 import "dart:collection"; |
10 import "dart:convert"; | 10 import "dart:convert"; |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 for (var pair in resolvedPairs) { | 565 for (var pair in resolvedPairs) { |
566 map[pair.first] = pair.last; | 566 map[pair.first] = pair.last; |
567 } | 567 } |
568 return map; | 568 return map; |
569 }); | 569 }); |
570 } | 570 } |
571 | 571 |
572 /// Returns the path to the library named [libraryName]. The library name must | 572 /// Returns the path to the library named [libraryName]. The library name must |
573 /// be globally unique, or the wrong library path may be returned. | 573 /// be globally unique, or the wrong library path may be returned. |
574 String libraryPath(String libraryName) { | 574 String libraryPath(String libraryName) { |
575 var libraries = currentMirrorSystem().findLibrary(new Symbol(libraryName)); | 575 var lib = currentMirrorSystem().findLibrary(new Symbol(libraryName)); |
576 return path.fromUri(libraries.single.uri); | 576 return path.fromUri(lib.uri); |
577 } | 577 } |
578 | 578 |
579 /// Gets a "special" string (ANSI escape or Unicode). On Windows, returns | 579 /// Gets a "special" string (ANSI escape or Unicode). On Windows, returns |
580 /// something else since those aren't supported. | 580 /// something else since those aren't supported. |
581 String getSpecial(String color, [String onWindows = '']) { | 581 String getSpecial(String color, [String onWindows = '']) { |
582 // No ANSI escapes on windows or when running tests. | 582 // No ANSI escapes on windows or when running tests. |
583 if (runningAsTest || Platform.operatingSystem == 'windows') return onWindows; | 583 if (runningAsTest || Platform.operatingSystem == 'windows') return onWindows; |
584 return color; | 584 return color; |
585 } | 585 } |
586 | 586 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 error is AnalyzerErrorGroup || | 750 error is AnalyzerErrorGroup || |
751 error is IsolateSpawnException || | 751 error is IsolateSpawnException || |
752 error is FileSystemException || | 752 error is FileSystemException || |
753 error is HttpException || | 753 error is HttpException || |
754 error is HttpException || | 754 error is HttpException || |
755 error is OSError || | 755 error is OSError || |
756 error is ProcessException || | 756 error is ProcessException || |
757 error is SocketException || | 757 error is SocketException || |
758 error is WebSocketException; | 758 error is WebSocketException; |
759 } | 759 } |
OLD | NEW |