Skip to content

Commit

Permalink
fixes #187, implicit html, as well as server messages not printing
Browse files Browse the repository at this point in the history
R=vsm@google.com

Review URL: https://codereview.chromium.org/1136293005
  • Loading branch information
John Messerly committed May 19, 2015
1 parent 08fb216 commit 918ee66
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/dev_compiler/lib/devc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,12 @@ class CompilerServer {
.addHandler(shelf_static.createStaticHandler(outDir,
defaultDocument: _entryPath));
await shelf.serve(handler, host, port);
_log.fine('Serving $_entryPath at http://$host:$port/');
print('Serving $_entryPath at http://$host:$port/');
compiler.run();
}

shelf.Handler rebuildAndCache(shelf.Handler handler) => (request) {
_log.fine('requested $GREEN_COLOR${request.url}$NO_COLOR');
print('requested $GREEN_COLOR${request.url}$NO_COLOR');
// Trigger recompile only when requesting the HTML page.
var segments = request.url.pathSegments;
bool isEntryPage = segments.length == 0 || segments[0] == _entryPath;
Expand Down
16 changes: 15 additions & 1 deletion pkg/dev_compiler/lib/src/analysis_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions pkg/dev_compiler/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ CompilerOptions parseOptions(List<String> argv) {
if (enableHashing == null) {
enableHashing = serverMode;
}
// TODO(jmesserly): shouldn't level always default to warning?
var logLevel = serverMode ? Level.WARNING : Level.SEVERE;
var levelName = args['log'];
if (levelName != null) {
Expand Down

0 comments on commit 918ee66

Please sign in to comment.