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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dev_compiler.src.analysis_context; 5 library dev_compiler.src.analysis_context;
6 6
7 import 'package:analyzer/file_system/file_system.dart'; 7 import 'package:analyzer/file_system/file_system.dart';
8 import 'package:analyzer/file_system/memory_file_system.dart'; 8 import 'package:analyzer/file_system/memory_file_system.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/java_io.dart' show JavaFile; 10 import 'package:analyzer/src/generated/java_io.dart' show JavaFile;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath]. 56 /// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath].
57 DartUriResolver createSdkPathResolver(String sdkPath) => 57 DartUriResolver createSdkPathResolver(String sdkPath) =>
58 new DartUriResolver(new DirectoryBasedDartSdk(new JavaFile(sdkPath))); 58 new DartUriResolver(new DirectoryBasedDartSdk(new JavaFile(sdkPath)));
59 59
60 UriResolver _createImplicitEntryResolver(ResolverOptions options) { 60 UriResolver _createImplicitEntryResolver(ResolverOptions options) {
61 var entry = path.absolute(ResolverOptions.implicitHtmlFile); 61 var entry = path.absolute(ResolverOptions.implicitHtmlFile);
62 var src = path.absolute(options.entryPointFile); 62 var src = path.absolute(options.entryPointFile);
63 var provider = new MemoryResourceProvider(); 63 var provider = new MemoryResourceProvider();
64 provider.newFile( 64 provider.newFile(
65 entry, '<body><script type="application/dart" src="$src"></script>'); 65 entry, '<body><script type="application/dart" src="$src"></script>');
66 return new ResourceUriResolver(provider); 66 return new ExistingSourceUriResolver(new ResourceUriResolver(provider));
67 }
68
69 /// A UriResolver that continues to the next one if it fails to find an existing
70 /// source file. This is unlike normal URI resolvers, that always return
71 /// something, even if it is a non-existing file.
72 class ExistingSourceUriResolver implements UriResolver {
73 final UriResolver resolver;
74 ExistingSourceUriResolver(this.resolver);
75
76 Source resolveAbsolute(Uri uri) {
77 var src = resolver.resolveAbsolute(uri);
78 return src.exists() ? src : null;
79 }
80 Uri restoreAbsolute(Source source) => resolver.restoreAbsolute(source);
67 } 81 }
68 82
69 /// Creates an analysis context that contains our restricted typing rules. 83 /// Creates an analysis context that contains our restricted typing rules.
70 AnalysisContext _initContext(ResolverOptions options) { 84 AnalysisContext _initContext(ResolverOptions options) {
71 var analysisOptions = new AnalysisOptionsImpl()..cacheSize = 512; 85 var analysisOptions = new AnalysisOptionsImpl()..cacheSize = 512;
72 AnalysisContextImpl res = AnalysisEngine.instance.createAnalysisContext(); 86 AnalysisContextImpl res = AnalysisEngine.instance.createAnalysisContext();
73 res.analysisOptions = analysisOptions; 87 res.analysisOptions = analysisOptions;
74 res.libraryResolverFactory = 88 res.libraryResolverFactory =
75 (context) => new LibraryResolverWithInference(context, options); 89 (context) => new LibraryResolverWithInference(context, options);
76 return res; 90 return res;
77 } 91 }
OLDNEW
« 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