OLD | NEW |
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 /// Development server that compiles Dart to JS on the fly. | 5 /// Development server that compiles Dart to JS on the fly. |
6 library dev_compiler.src.server; | 6 library dev_compiler.src.server; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 29 matching lines...) Expand all Loading... |
40 final SourceNode _entryNode; | 40 final SourceNode _entryNode; |
41 List<LibraryInfo> _libraries = <LibraryInfo>[]; | 41 List<LibraryInfo> _libraries = <LibraryInfo>[]; |
42 final _generators = <CodeGenerator>[]; | 42 final _generators = <CodeGenerator>[]; |
43 bool _hashing; | 43 bool _hashing; |
44 bool _failure = false; | 44 bool _failure = false; |
45 | 45 |
46 factory ServerCompiler(AnalysisContext context, CompilerOptions options, | 46 factory ServerCompiler(AnalysisContext context, CompilerOptions options, |
47 {AnalysisErrorListener reporter}) { | 47 {AnalysisErrorListener reporter}) { |
48 var srcOpts = options.sourceOptions; | 48 var srcOpts = options.sourceOptions; |
49 var inputFile = options.inputs[0]; | 49 var inputFile = options.inputs[0]; |
50 var inputUri = inputFile.startsWith('dart:') || | 50 var inputUri = |
51 inputFile.startsWith('package:') | 51 inputFile.startsWith('dart:') || inputFile.startsWith('package:') |
52 ? Uri.parse(inputFile) | 52 ? Uri.parse(inputFile) |
53 : new Uri.file(path.absolute(srcOpts.useImplicitHtml | 53 : new Uri.file(path.absolute(srcOpts.useImplicitHtml |
54 ? SourceResolverOptions.implicitHtmlFile | 54 ? SourceResolverOptions.implicitHtmlFile |
55 : inputFile)); | 55 : inputFile)); |
56 var graph = new SourceGraph(context, reporter, options); | 56 var graph = new SourceGraph(context, reporter, options); |
57 var entryNode = graph.nodeFromUri(inputUri); | 57 var entryNode = graph.nodeFromUri(inputUri); |
58 | 58 |
59 return new ServerCompiler._(context, options, reporter, entryNode); | 59 return new ServerCompiler._(context, options, reporter, entryNode); |
60 } | 60 } |
61 | 61 |
62 ServerCompiler._(AnalysisContext context, CompilerOptions options, | 62 ServerCompiler._(AnalysisContext context, CompilerOptions options, |
63 AnalysisErrorListener reporter, this._entryNode) | 63 AnalysisErrorListener reporter, this._entryNode) |
64 : super(context, options, reporter) { | 64 : super(context, options, reporter) { |
65 if (outputDir != null) { | 65 if (outputDir != null) { |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 308 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
309 var src = resolver.resolveAbsolute(uri, actualUri); | 309 var src = resolver.resolveAbsolute(uri, actualUri); |
310 return src.exists() ? src : null; | 310 return src.exists() ? src : null; |
311 } | 311 } |
312 | 312 |
313 Uri restoreAbsolute(Source source) => resolver.restoreAbsolute(source); | 313 Uri restoreAbsolute(Source source) => resolver.restoreAbsolute(source); |
314 } | 314 } |
315 | 315 |
316 final _log = new Logger('dev_compiler.src.server'); | 316 final _log = new Logger('dev_compiler.src.server'); |
317 final _earlyErrorResult = new CheckerResults(const [], true); | 317 final _earlyErrorResult = new CheckerResults(const [], true); |
OLD | NEW |