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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/source_file_provider.dart

Issue 13797002: Change MirrorSystem.libraries to Map<Uri, String> (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library source_file_provider; 5 library source_file_provider;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:uri'; 8 import 'dart:uri';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:utf'; 10 import 'dart:utf';
11 11
12 import '../compiler.dart' as api show Diagnostic; 12 import '../compiler.dart' as api show Diagnostic;
13 import 'dart2js.dart' show AbortLeg; 13 import 'dart2js.dart' show AbortLeg;
14 import 'colors.dart' as colors; 14 import 'colors.dart' as colors;
15 import 'source_file.dart'; 15 import 'source_file.dart';
16 import 'filenames.dart'; 16 import 'filenames.dart';
17 import 'util/uri_extras.dart'; 17 import 'util/uri_extras.dart';
18 18
19 String readAll(String filename) { 19 String readAll(String filename) {
20 var file = (new File(filename)).openSync(); 20 var file = (new File(filename)).openSync();
21 var length = file.lengthSync(); 21 var length = file.lengthSync();
22 var buffer = new List<int>(length); 22 var buffer = new List<int>(length);
23 var bytes = file.readListSync(buffer, 0, length); 23 var bytes = file.readListSync(buffer, 0, length);
24 file.closeSync(); 24 file.closeSync();
25 return new String.fromCharCodes(new Utf8Decoder(buffer).decodeRest()); 25 return new String.fromCharCodes(new Utf8Decoder(buffer).decodeRest());
26 } 26 }
27 27
28 class SourceFileProvider { 28 class SourceFileProvider {
29 bool isWindows = (Platform.operatingSystem == 'windows'); 29 bool isWindows = (Platform.operatingSystem == 'windows');
30 Uri cwd = getCurrentDirectory();
ahe 2013/04/09 08:28:44 I think it makes sense to keep the local variable.
Johnni Winther 2013/04/22 13:00:02 Done.
31 Map<String, SourceFile> sourceFiles = <String, SourceFile>{}; 30 Map<String, SourceFile> sourceFiles = <String, SourceFile>{};
32 int dartCharactersRead = 0; 31 int dartCharactersRead = 0;
33 32
34 Future<String> readStringFromUri(Uri resourceUri) { 33 Future<String> readStringFromUri(Uri resourceUri) {
35 if (resourceUri.scheme != 'file') { 34 if (resourceUri.scheme != 'file') {
36 throw new ArgumentError("Unknown scheme in uri '$resourceUri'"); 35 throw new ArgumentError("Unknown scheme in uri '$resourceUri'");
37 } 36 }
38 String source; 37 String source;
39 try { 38 try {
40 source = readAll(uriPathToNative(resourceUri.path)); 39 source = readAll(uriPathToNative(resourceUri.path));
41 } on FileIOException catch (ex) { 40 } on FileIOException catch (ex) {
42 throw 'Error: Cannot read "${relativize(cwd, resourceUri, isWindows)}" ' 41 throw 'Error: Cannot read '
42 '"${relativize(currentDirectory, resourceUri, isWindows)}" '
43 '(${ex.osError}).'; 43 '(${ex.osError}).';
44 } 44 }
45 dartCharactersRead += source.length; 45 dartCharactersRead += source.length;
46 sourceFiles[resourceUri.toString()] = 46 sourceFiles[resourceUri.toString()] = new SourceFile(
47 new SourceFile(relativize(cwd, resourceUri, isWindows), source); 47 relativize(currentDirectory, resourceUri, isWindows), source);
48 return new Future.immediate(source); 48 return new Future.immediate(source);
49 } 49 }
50 } 50 }
51 51
52 class FormattingDiagnosticHandler { 52 class FormattingDiagnosticHandler {
53 final SourceFileProvider provider; 53 final SourceFileProvider provider;
54 bool showWarnings = true; 54 bool showWarnings = true;
55 bool verbose = false; 55 bool verbose = false;
56 bool isAborting = false; 56 bool isAborting = false;
57 bool enableColors = false; 57 bool enableColors = false;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 print(file.getLocationMessage(color(message), begin, end, true, color)); 112 print(file.getLocationMessage(color(message), begin, end, true, color));
113 } 113 }
114 if (fatal && throwOnError) { 114 if (fatal && throwOnError) {
115 isAborting = true; 115 isAborting = true;
116 throw new AbortLeg(message); 116 throw new AbortLeg(message);
117 } 117 }
118 } 118 }
119 } 119 }
120 120
121 121
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698