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

Unified Diff: lib/src/analysis_context.dart

Issue 1136293005: fixes #187, implicit html, as well as server messages not printing (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 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 | « lib/devc.dart ('k') | lib/src/options.dart » ('j') | lib/src/options.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/analysis_context.dart
diff --git a/lib/src/analysis_context.dart b/lib/src/analysis_context.dart
index b6e74a4eca1824e553cb43ab2c6e891bf550cd2d..26677b19fd293702adafa9e8c641091f3c71caaa 100644
--- a/lib/src/analysis_context.dart
+++ b/lib/src/analysis_context.dart
@@ -63,7 +63,21 @@ UriResolver _createImplicitEntryResolver(ResolverOptions options) {
var provider = new MemoryResourceProvider();
provider.newFile(
entry, '<body><script type="application/dart" src="$src"></script>');
- return new ResourceUriResolver(provider);
+ return new ExistingSourceUriResolver(new ResourceUriResolver(provider));
+}
+
+/// A UriResolver that continues to the next one if it fails to find an existing
+/// source file. This is unlike normal URI resolvers, that always return
+/// something, even if it is a non-existing file.
+class ExistingSourceUriResolver implements UriResolver {
+ final UriResolver resolver;
+ ExistingSourceUriResolver(this.resolver);
+
+ Source resolveAbsolute(Uri uri) {
+ var src = resolver.resolveAbsolute(uri);
+ return src.exists() ? src : null;
+ }
+ Uri restoreAbsolute(Source source) => resolver.restoreAbsolute(source);
}
/// Creates an analysis context that contains our restricted typing rules.
« no previous file with comments | « lib/devc.dart ('k') | lib/src/options.dart » ('j') | lib/src/options.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698