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

Unified Diff: pkg/front_end/example/incremental_reload/compiler_with_invalidation.dart

Issue 2993113003: Revert "Switch FE to use the libraries.json format." (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/example/incremental_reload/compiler_with_invalidation.dart
diff --git a/pkg/front_end/example/incremental_reload/compiler_with_invalidation.dart b/pkg/front_end/example/incremental_reload/compiler_with_invalidation.dart
index 061771c9e54ce775f8b32280931105da699801f4..c5d976027032fa73ea36adf4878edf736f423ab4 100644
--- a/pkg/front_end/example/incremental_reload/compiler_with_invalidation.dart
+++ b/pkg/front_end/example/incremental_reload/compiler_with_invalidation.dart
@@ -9,6 +9,7 @@ library front_end.example.incremental_reload.compiler_with_invalidation;
import 'dart:io';
import 'dart:async';
+import 'dart:convert' show JSON;
import 'package:front_end/compiler_options.dart';
import 'package:front_end/incremental_kernel_generator.dart';
@@ -32,6 +33,7 @@ Future<IncrementalCompiler> createIncrementalCompiler(String entry,
..sdkRoot = sdkRoot
..packagesFileUri = Uri.base.resolve('.packages')
..strongMode = false
+ ..dartLibraries = loadDartLibraries(sdkRoot)
// Note: we do not report error on the console because the incremental
// compiler is an ongoing background service that shouldn't polute stdout.
// TODO(sigmund): do something with the errors.
@@ -41,6 +43,18 @@ Future<IncrementalCompiler> createIncrementalCompiler(String entry,
return IncrementalCompiler.create(options, entryUri);
}
+/// Reads the `libraries.json` file for an SDK to provide the location of the
+/// SDK files.
+// TODO(sigmund): this should be handled by package:front_end internally.
+Map<String, Uri> loadDartLibraries(Uri sdkRoot) {
+ var libraries = sdkRoot.resolve('lib/libraries.json');
+ var map =
+ JSON.decode(new File.fromUri(libraries).readAsStringSync())['libraries'];
+ var dartLibraries = <String, Uri>{};
+ map.forEach((k, v) => dartLibraries[k] = libraries.resolve(v));
+ return dartLibraries;
+}
+
/// An incremental compiler that monitors file modifications on disk and
/// invalidates only files that have been modified since the previous time the
/// compiler was invoked.
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart ('k') | pkg/front_end/lib/compiler_options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698