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

Side by Side Diff: pkg/front_end/lib/src/base/processed_options.dart

Issue 2614063007: Use URIs rather than paths in front end API. (Closed)
Patch Set: Minor fixes Created 3 years, 11 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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:async'; 5 import 'dart:async';
6 6
7 import 'package:front_end/compiler_options.dart'; 7 import 'package:front_end/compiler_options.dart';
8 import 'package:front_end/file_system.dart'; 8 import 'package:front_end/file_system.dart';
9 import 'package:front_end/src/base/uri_resolver.dart'; 9 import 'package:front_end/src/base/uri_resolver.dart';
10 import 'package:package_config/packages_file.dart' as package_config; 10 import 'package:package_config/packages_file.dart' as package_config;
(...skipping 21 matching lines...) Expand all
32 /// Initializes a [ProcessedOptions] object wrapping the given [rawOptions]. 32 /// Initializes a [ProcessedOptions] object wrapping the given [rawOptions].
33 ProcessedOptions(CompilerOptions rawOptions) : this._raw = rawOptions; 33 ProcessedOptions(CompilerOptions rawOptions) : this._raw = rawOptions;
34 34
35 /// Determine whether to generate code for the SDK when compiling a 35 /// Determine whether to generate code for the SDK when compiling a
36 /// whole-program. 36 /// whole-program.
37 bool get compileSdk => _raw.compileSdk; 37 bool get compileSdk => _raw.compileSdk;
38 38
39 /// Get the [FileSystem] which should be used by the front end to access 39 /// Get the [FileSystem] which should be used by the front end to access
40 /// files. 40 /// files.
41 /// 41 ///
42 /// If the client supplied bazel roots using [CompilerOptions.bazelRoots], the 42 /// If the client supplied roots using [CompilerOptions.multiRoots], the
43 /// returned [FileSystem] will automatically perform the appropriate mapping. 43 /// returned [FileSystem] will automatically perform the appropriate mapping.
44 FileSystem get fileSystem { 44 FileSystem get fileSystem {
45 // TODO(paulberry): support bazelRoots. 45 // TODO(paulberry): support multiRoots.
46 assert(_raw.bazelRoots.isEmpty); 46 assert(_raw.multiRoots.isEmpty);
47 return _raw.fileSystem; 47 return _raw.fileSystem;
48 } 48 }
49 49
50 /// Get the [UriResolver] which resolves "package:" and "dart:" URIs. 50 /// Get the [UriResolver] which resolves "package:" and "dart:" URIs.
51 /// 51 ///
52 /// This is an asynchronous getter since file system operations may be 52 /// This is an asynchronous getter since file system operations may be
53 /// required to locate/read the packages file as well as SDK metadata. 53 /// required to locate/read the packages file as well as SDK metadata.
54 Future<UriResolver> getUriResolver() async { 54 Future<UriResolver> getUriResolver() async {
55 if (_uriResolver == null) { 55 if (_uriResolver == null) {
56 await _getPackages(); 56 await _getPackages();
57 var sdkLibraries = 57 var sdkLibraries =
58 <String, Uri>{}; // TODO(paulberry): support SDK libraries 58 <String, Uri>{}; // TODO(paulberry): support SDK libraries
59 _uriResolver = 59 _uriResolver =
60 new UriResolver(_packages, sdkLibraries, fileSystem.context); 60 new UriResolver(_packages, sdkLibraries, fileSystem.context);
61 } 61 }
62 return _uriResolver; 62 return _uriResolver;
63 } 63 }
64 64
65 /// Get the package map which maps package names to URIs. 65 /// Get the package map which maps package names to URIs.
66 /// 66 ///
67 /// This is an asynchronous getter since file system operations may be 67 /// This is an asynchronous getter since file system operations may be
68 /// required to locate/read the packages file. 68 /// required to locate/read the packages file.
69 Future<Map<String, Uri>> _getPackages() async { 69 Future<Map<String, Uri>> _getPackages() async {
70 if (_packages == null) { 70 if (_packages == null) {
71 if (_raw.packagesFilePath == null) { 71 if (_raw.packagesFilePath == null) {
72 throw new UnimplementedError(); // TODO(paulberry): search for .packages 72 throw new UnimplementedError(); // TODO(paulberry): search for .packages
73 } else if (_raw.packagesFilePath.isEmpty) { 73 } else if (_raw.packagesFilePath.path.isEmpty) {
74 _packages = {}; 74 _packages = {};
75 } else { 75 } else {
76 var contents = 76 var contents =
77 await fileSystem.entityForPath(_raw.packagesFilePath).readAsBytes(); 77 await fileSystem.entityForUri(_raw.packagesFilePath).readAsBytes();
78 var baseLocation = fileSystem.context.toUri(_raw.packagesFilePath); 78 _packages = package_config.parse(contents, _raw.packagesFilePath);
79 _packages = package_config.parse(contents, baseLocation);
80 } 79 }
81 } 80 }
82 return _packages; 81 return _packages;
83 } 82 }
84 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698