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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // dependency_graph now detects broken imports or unsupported features | 77 // dependency_graph now detects broken imports or unsupported features |
78 // like more than one script tag (see .severe messages in | 78 // like more than one script tag (see .severe messages in |
79 // dependency_graph.dart). Such failures should be reported back | 79 // dependency_graph.dart). Such failures should be reported back |
80 // here so we can mark failure=true in the CheckerResults. | 80 // here so we can mark failure=true in the CheckerResults. |
81 rebuild(_entryNode, _buildSource); | 81 rebuild(_entryNode, _buildSource); |
82 _dumpInfoIfRequested(); | 82 _dumpInfoIfRequested(); |
83 clock.stop(); | 83 clock.stop(); |
84 var time = (clock.elapsedMilliseconds / 1000).toStringAsFixed(2); | 84 var time = (clock.elapsedMilliseconds / 1000).toStringAsFixed(2); |
85 _log.fine('Compiled ${_libraries.length} libraries in ${time} s\n'); | 85 _log.fine('Compiled ${_libraries.length} libraries in ${time} s\n'); |
86 return new CheckerResults( | 86 return new CheckerResults( |
87 _libraries, rules, _failure || options.codegenOptions.forceCompile); | 87 _libraries, _failure || options.codegenOptions.forceCompile); |
88 } | 88 } |
89 | 89 |
90 bool _buildSource(SourceNode node) { | 90 bool _buildSource(SourceNode node) { |
91 if (node is HtmlSourceNode) { | 91 if (node is HtmlSourceNode) { |
92 _buildHtmlFile(node); | 92 _buildHtmlFile(node); |
93 } else if (node is DartSourceNode) { | 93 } else if (node is DartSourceNode) { |
94 _buildDartLibrary(node); | 94 _buildDartLibrary(node); |
95 } else if (node is ResourceSourceNode) { | 95 } else if (node is ResourceSourceNode) { |
96 _buildResourceFile(node); | 96 _buildResourceFile(node); |
97 } else { | 97 } else { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 _libraries.add(current); | 147 _libraries.add(current); |
148 | 148 |
149 var resolvedParts = node.parts | 149 var resolvedParts = node.parts |
150 .map((p) => context.resolveCompilationUnit2(p.source, source)) | 150 .map((p) => context.resolveCompilationUnit2(p.source, source)) |
151 .toList(growable: false); | 151 .toList(growable: false); |
152 var libraryUnit = new LibraryUnit(entryUnit, resolvedParts); | 152 var libraryUnit = new LibraryUnit(entryUnit, resolvedParts); |
153 bool failureInLib = false; | 153 bool failureInLib = false; |
154 for (var unit in libraryUnit.libraryThenParts) { | 154 for (var unit in libraryUnit.libraryThenParts) { |
155 var unitSource = unit.element.source; | 155 var unitSource = unit.element.source; |
156 // TODO(sigmund): integrate analyzer errors with static-info (issue #6). | 156 // TODO(sigmund): integrate analyzer errors with static-info (issue #6). |
157 failureInLib = logErrors(unitSource) || failureInLib; | 157 failureInLib = computeErrors(unitSource) || failureInLib; |
158 checker.visitCompilationUnit(unit); | |
159 if (checker.failure) failureInLib = true; | |
160 } | 158 } |
161 if (failureInLib) { | 159 if (failureInLib) { |
162 _failure = true; | 160 _failure = true; |
163 if (!options.codegenOptions.forceCompile) return; | 161 if (!options.codegenOptions.forceCompile) return; |
164 } | 162 } |
165 | 163 |
166 for (var cg in _generators) { | 164 for (var cg in _generators) { |
167 var hash = cg.generateLibrary(libraryUnit); | 165 var hash = cg.generateLibrary(libraryUnit); |
168 if (_hashing) node.cachingHash = hash; | 166 if (_hashing) node.cachingHash = hash; |
169 } | 167 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 301 |
304 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 302 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
305 var src = resolver.resolveAbsolute(uri, actualUri); | 303 var src = resolver.resolveAbsolute(uri, actualUri); |
306 return src.exists() ? src : null; | 304 return src.exists() ? src : null; |
307 } | 305 } |
308 | 306 |
309 Uri restoreAbsolute(Source source) => resolver.restoreAbsolute(source); | 307 Uri restoreAbsolute(Source source) => resolver.restoreAbsolute(source); |
310 } | 308 } |
311 | 309 |
312 final _log = new Logger('dev_compiler.src.server'); | 310 final _log = new Logger('dev_compiler.src.server'); |
313 final _earlyErrorResult = new CheckerResults(const [], null, true); | 311 final _earlyErrorResult = new CheckerResults(const [], true); |
OLD | NEW |