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

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

Issue 2239193002: Rerun formatter (Closed) Base URL: https://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
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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 /// replaced by the first directory in the search path containing the file, if 376 /// replaced by the first directory in the search path containing the file, if
377 /// any. For example, given the search path ".,bazel-bin/", and a URL 377 /// any. For example, given the search path ".,bazel-bin/", and a URL
378 /// of the form `file:///bazel-root/a/b.dart`, this provider will check if the 378 /// of the form `file:///bazel-root/a/b.dart`, this provider will check if the
379 /// file exists under "./a/b.dart", then check under "bazel-bin/a/b.dart". If 379 /// file exists under "./a/b.dart", then check under "bazel-bin/a/b.dart". If
380 /// none of the paths matches, it will attempt to load the file from 380 /// none of the paths matches, it will attempt to load the file from
381 /// `/bazel-root/a/b.dart` which will likely fail. 381 /// `/bazel-root/a/b.dart` which will likely fail.
382 class BazelInputProvider extends SourceFileProvider { 382 class BazelInputProvider extends SourceFileProvider {
383 final List<Uri> dirs; 383 final List<Uri> dirs;
384 384
385 BazelInputProvider(List<String> searchPaths) 385 BazelInputProvider(List<String> searchPaths)
386 : dirs = searchPaths.map(_resolve).toList(); 386 : dirs = searchPaths.map(_resolve).toList();
387 387
388 static _resolve(String path) => currentDirectory.resolve(path); 388 static _resolve(String path) => currentDirectory.resolve(path);
389 389
390 @override 390 @override
391 Future readFromUri(Uri uri) async { 391 Future readFromUri(Uri uri) async {
392 var resolvedUri = uri; 392 var resolvedUri = uri;
393 var path = uri.path; 393 var path = uri.path;
394 if (path.startsWith('/bazel-root')) { 394 if (path.startsWith('/bazel-root')) {
395 path = path.substring('/bazel-root/'.length); 395 path = path.substring('/bazel-root/'.length);
396 for (var dir in dirs) { 396 for (var dir in dirs) {
397 var file = dir.resolve(path); 397 var file = dir.resolve(path);
398 if (await new File.fromUri(file).exists()) { 398 if (await new File.fromUri(file).exists()) {
399 resolvedUri = file; 399 resolvedUri = file;
400 break; 400 break;
401 } 401 }
402 } 402 }
403 } 403 }
404 var result = await readUtf8BytesFromUri(resolvedUri); 404 var result = await readUtf8BytesFromUri(resolvedUri);
405 sourceFiles[uri] = sourceFiles[resolvedUri]; 405 sourceFiles[uri] = sourceFiles[resolvedUri];
406 return result; 406 return result;
407 } 407 }
408 } 408 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/equivalence.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698