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

Unified Diff: pkg/front_end/lib/kernel_generator.dart

Issue 2614063007: Use URIs rather than paths in front end API. (Closed)
Patch Set: Run dartfmt 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/kernel_generator.dart
diff --git a/pkg/front_end/lib/kernel_generator.dart b/pkg/front_end/lib/kernel_generator.dart
index a87bb683b44dc71eb28c9cf328fba10469ada4f6..348d1f9021571c70c7bdbc8b1044a7b91e038f31 100644
--- a/pkg/front_end/lib/kernel_generator.dart
+++ b/pkg/front_end/lib/kernel_generator.dart
@@ -59,7 +59,7 @@ Future<Program> kernelForProgram(Uri source, CompilerOptions options) async {
/// which will be read are those listed in [sources],
/// [CompilerOptions.inputSummaries], and [CompilerOptions.sdkSummary]. If a
/// source file attempts to refer to a file which is not obtainable from these
-/// paths, that will result in an error, even if the file exists on the
+/// URIs, that will result in an error, even if the file exists on the
/// filesystem.
///
/// When [CompilerOptions.chaseDependencies] is true, this default behavior
@@ -128,7 +128,8 @@ Future<Program> kernelForBuildUnit(
Future<DartLoader> _createLoader(CompilerOptions options,
{Repository repository, Uri entry}) async {
var kernelOptions = _convertOptions(options);
- var packages = await createPackages(options.packagesFilePath,
+ var packages = await createPackages(
+ _uriToPath(options.packagesFileUri, options),
discoveryPath: entry?.path);
return new DartLoader(
repository ?? new Repository(), kernelOptions, packages);
@@ -137,11 +138,12 @@ Future<DartLoader> _createLoader(CompilerOptions options,
DartOptions _convertOptions(CompilerOptions options) {
return new DartOptions(
strongMode: options.strongMode,
- sdk: options.sdkPath,
+ sdk: _uriToPath(options.sdkRoot, options),
// TODO(sigmund): make it possible to use summaries and still compile the
// sdk sources.
- sdkSummary: options.compileSdk ? null : options.sdkSummary,
- packagePath: options.packagesFilePath,
+ sdkSummary:
+ options.compileSdk ? null : _uriToPath(options.sdkSummary, options),
+ packagePath: _uriToPath(options.packagesFileUri, options),
declaredVariables: options.declaredVariables);
}
@@ -152,6 +154,14 @@ void _reportErrors(List errors, ErrorHandler onError) {
}
}
+String _uriToPath(Uri uri, CompilerOptions options) {
+ if (uri == null) return null;
+ if (uri.scheme != 'file') {
+ throw new StateError('Only file URIs are supported');
+ }
+ return options.fileSystem.context.fromUri(uri);
+}
+
// TODO(sigmund): delete this class. Dartk should not format errors itself, we
// should just pass them along.
class _DartkError implements CompilationError {

Powered by Google App Engine
This is Rietveld 408576698