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

Unified Diff: pkg/compiler/lib/src/resolved_uri_translator.dart

Issue 2675023002: Temporarily allow to import dart:io in client apps. (Closed)
Patch Set: cl comments Created 3 years, 10 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
« no previous file with comments | « pkg/compiler/lib/src/apiimpl.dart ('k') | sdk/lib/dart_client.platform » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolved_uri_translator.dart
diff --git a/pkg/compiler/lib/src/resolved_uri_translator.dart b/pkg/compiler/lib/src/resolved_uri_translator.dart
index e2bf95407d119f58e38cbdfaf6b6efe019629379..ecd7d0a633b361a424fe5425e911a310c9b0e4aa 100644
--- a/pkg/compiler/lib/src/resolved_uri_translator.dart
+++ b/pkg/compiler/lib/src/resolved_uri_translator.dart
@@ -10,8 +10,9 @@ import 'util/emptyset.dart';
/// system readable URIs.
abstract class ResolvedUriTranslator {
factory ResolvedUriTranslator(
- Map<String, Uri> sdkLibraries, DiagnosticReporter reporter) =
- _ResolvedUriTranslator;
+ Map<String, Uri> sdkLibraries,
+ DiagnosticReporter reporter,
+ Uri platformConfigUri) = _ResolvedUriTranslator;
/// The set of platform libraries reported as unsupported.
///
@@ -76,11 +77,13 @@ class ForwardingResolvedUriTranslator implements ResolvedUriTranslator {
class _ResolvedUriTranslator implements ResolvedUriTranslator {
final Map<String, Uri> _sdkLibraries;
final DiagnosticReporter _reporter;
+ final Uri _platformConfigUri;
Set<Uri> disallowedLibraryUris = new Set<Uri>();
bool mockableLibraryUsed = false;
- _ResolvedUriTranslator(this._sdkLibraries, this._reporter);
+ _ResolvedUriTranslator(
+ this._sdkLibraries, this._reporter, this._platformConfigUri);
Map<String, Uri> get sdkLibraries => _sdkLibraries;
@@ -136,9 +139,27 @@ class _ResolvedUriTranslator implements ResolvedUriTranslator {
}
if (location.scheme == "unsupported") {
- _reporter.reportErrorMessage(spannable, MessageKind.LIBRARY_NOT_SUPPORTED,
- {'resolvedUri': resolvedUri});
- registerDisallowedLibraryUse(resolvedUri);
+ if (location.path == "") {
+ _reporter.reportErrorMessage(spannable,
+ MessageKind.LIBRARY_NOT_SUPPORTED, {'resolvedUri': resolvedUri});
+ registerDisallowedLibraryUse(resolvedUri);
+ } else {
+ // If the specification includes a path, we treat it as "partially"
+ // unsupported: it is allowed to be imported unconditionally, but we
+ // will not expose it as being supported in the const variable
+ // `dart.library.name`.
+ //
+ // This is a stopgap measure to support packages like `http` that need
+ // to import `dart:io` conditionally. Once config-imports are supported
+ // in the language, we can make it an error again to import it
+ // unconditionally.
+ //
+ // The plaform configuration files contain a URI of the form
+ // `unsupported:path/to/library.dart` to indicate this partially
+ // supported mode. We resolve the path with respect to the configuration
+ // file.
+ return _platformConfigUri.resolve(location.path);
+ }
return null;
}
« no previous file with comments | « pkg/compiler/lib/src/apiimpl.dart ('k') | sdk/lib/dart_client.platform » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698