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

Side by Side Diff: pkg/compiler/lib/src/source_file_provider.dart

Issue 2226173002: dart2js: fix bot failures - I made this private without realizing it was accessed for testing (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
« 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) 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:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:math' as math; 10 import 'dart:math' as math;
(...skipping 25 matching lines...) Expand all
36 return _readFromHttp(resourceUri); 36 return _readFromHttp(resourceUri);
37 } else { 37 } else {
38 throw new ArgumentError("Unknown scheme in uri '$resourceUri'"); 38 throw new ArgumentError("Unknown scheme in uri '$resourceUri'");
39 } 39 }
40 } 40 }
41 41
42 Future<List<int>> _readFromFile(Uri resourceUri) { 42 Future<List<int>> _readFromFile(Uri resourceUri) {
43 assert(resourceUri.scheme == 'file'); 43 assert(resourceUri.scheme == 'file');
44 List<int> source; 44 List<int> source;
45 try { 45 try {
46 source = _readAll(resourceUri.toFilePath()); 46 source = readAll(resourceUri.toFilePath());
47 } on FileSystemException catch (ex) { 47 } on FileSystemException catch (ex) {
48 String message = ex.osError?.message; 48 String message = ex.osError?.message;
49 String detail = message != null ? ' ($message)' : ''; 49 String detail = message != null ? ' ($message)' : '';
50 return new Future.error( 50 return new Future.error(
51 "Error reading '${relativizeUri(resourceUri)}' $detail"); 51 "Error reading '${relativizeUri(resourceUri)}' $detail");
52 } 52 }
53 dartCharactersRead += source.length; 53 dartCharactersRead += source.length;
54 sourceFiles[resourceUri] = new CachingUtf8BytesSourceFile( 54 sourceFiles[resourceUri] = new CachingUtf8BytesSourceFile(
55 resourceUri, relativizeUri(resourceUri), source); 55 resourceUri, relativizeUri(resourceUri), source);
56 return new Future.value(source); 56 return new Future.value(source);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // API. 90 // API.
91 Future/*<List<int> | String>*/ call(Uri resourceUri) => throw "unimplemented"; 91 Future/*<List<int> | String>*/ call(Uri resourceUri) => throw "unimplemented";
92 92
93 relativizeUri(Uri uri) => relativize(cwd, uri, isWindows); 93 relativizeUri(Uri uri) => relativize(cwd, uri, isWindows);
94 94
95 SourceFile getSourceFile(Uri resourceUri) { 95 SourceFile getSourceFile(Uri resourceUri) {
96 return sourceFiles[resourceUri]; 96 return sourceFiles[resourceUri];
97 } 97 }
98 } 98 }
99 99
100 List<int> _readAll(String filename) { 100 List<int> readAll(String filename) {
101 var file = (new File(filename)).openSync(); 101 var file = (new File(filename)).openSync();
102 var length = file.lengthSync(); 102 var length = file.lengthSync();
103 // +1 to have a 0 terminated list, see [Scanner]. 103 // +1 to have a 0 terminated list, see [Scanner].
104 var buffer = new Uint8List(length + 1); 104 var buffer = new Uint8List(length + 1);
105 file.readIntoSync(buffer, 0, length); 105 file.readIntoSync(buffer, 0, length);
106 file.closeSync(); 106 file.closeSync();
107 return buffer; 107 return buffer;
108 } 108 }
109 109
110 class CompilerSourceFileProvider extends SourceFileProvider { 110 class CompilerSourceFileProvider extends SourceFileProvider {
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 var absolute = currentDirectory.resolve(path); 412 var absolute = currentDirectory.resolve(path);
413 var bazelRelativeUri = fakeBazelRoot.resolve( 413 var bazelRelativeUri = fakeBazelRoot.resolve(
414 path.startsWith(genPath) ? path.substring(genPath.length) : path); 414 path.startsWith(genPath) ? path.substring(genPath.length) : path);
415 mappings[bazelRelativeUri] = absolute; 415 mappings[bazelRelativeUri] = absolute;
416 } 416 }
417 } 417 }
418 418
419 @override 419 @override
420 Future readFromUri(Uri uri) => readUtf8BytesFromUri(mappings[uri] ?? uri); 420 Future readFromUri(Uri uri) => readUtf8BytesFromUri(mappings[uri] ?? uri);
421 } 421 }
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