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 /// Command line tool to run the checker on a Dart program. | 5 /// Command line tool to run the checker on a Dart program. |
6 library dev_compiler.devc; | 6 library dev_compiler.devc; |
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return new Compiler._(options, resolver, reporter, rules, checker, graph, | 90 return new Compiler._(options, resolver, reporter, rules, checker, graph, |
91 entryNode, generators); | 91 entryNode, generators); |
92 } | 92 } |
93 | 93 |
94 Compiler._(this._options, this._resolver, this._reporter, this._rules, | 94 Compiler._(this._options, this._resolver, this._reporter, this._rules, |
95 this._checker, this._graph, this._entryNode, this._generators); | 95 this._checker, this._graph, this._entryNode, this._generators); |
96 | 96 |
97 bool _buildSource(SourceNode node) { | 97 bool _buildSource(SourceNode node) { |
98 if (node is HtmlSourceNode) { | 98 if (node is HtmlSourceNode) { |
99 _buildHtmlFile(node); | 99 _buildHtmlFile(node); |
100 } else if (node is LibrarySourceNode) { | 100 } else if (node is DartSourceNode) { |
101 _buildDartLibrary(node); | 101 _buildDartLibrary(node); |
102 } else { | 102 } else { |
103 assert(false); // should not get a build request on PartSourceNode | 103 assert(false); // should not get a build request on PartSourceNode |
104 } | 104 } |
105 | 105 |
106 // TODO(sigmund): don't always return true. Use summarization to better | 106 // TODO(sigmund): don't always return true. Use summarization to better |
107 // determine when rebuilding is needed. | 107 // determine when rebuilding is needed. |
108 return true; | 108 return true; |
109 } | 109 } |
110 | 110 |
(...skipping 16 matching lines...) Expand all Loading... |
127 path.dirname(path.dirname(Platform.script.path)), 'lib/runtime/'); | 127 path.dirname(path.dirname(Platform.script.path)), 'lib/runtime/'); |
128 var runtimeOutput = path.join(_options.outputDir, 'dev_compiler/runtime/'); | 128 var runtimeOutput = path.join(_options.outputDir, 'dev_compiler/runtime/'); |
129 new Directory(runtimeOutput).createSync(recursive: true); | 129 new Directory(runtimeOutput).createSync(recursive: true); |
130 new File(path.join(runtimeDir, 'harmony_feature_check.js')) | 130 new File(path.join(runtimeDir, 'harmony_feature_check.js')) |
131 .copy(path.join(runtimeOutput, 'harmony_feature_check.js')); | 131 .copy(path.join(runtimeOutput, 'harmony_feature_check.js')); |
132 new File(path.join(runtimeDir, 'dart_runtime.js')) | 132 new File(path.join(runtimeDir, 'dart_runtime.js')) |
133 .copy(path.join(runtimeOutput, 'dart_runtime.js')); | 133 .copy(path.join(runtimeOutput, 'dart_runtime.js')); |
134 _devCompilerRuntimeCopied = true; | 134 _devCompilerRuntimeCopied = true; |
135 } | 135 } |
136 | 136 |
137 bool _isEntry(LibrarySourceNode node) { | 137 bool _isEntry(DartSourceNode node) { |
138 if (_entryNode is LibrarySourceNode) return _entryNode == node; | 138 if (_entryNode is DartSourceNode) return _entryNode == node; |
139 return (_entryNode as HtmlSourceNode).scripts.contains(node); | 139 return (_entryNode as HtmlSourceNode).scripts.contains(node); |
140 } | 140 } |
141 | 141 |
142 void _buildDartLibrary(LibrarySourceNode node) { | 142 void _buildDartLibrary(DartSourceNode node) { |
143 var source = node.source; | 143 var source = node.source; |
144 // TODO(sigmund): find out from analyzer team if there is a better way | 144 // TODO(sigmund): find out from analyzer team if there is a better way |
145 _resolver.context.applyChanges(new ChangeSet()..changedSource(source)); | 145 _resolver.context.applyChanges(new ChangeSet()..changedSource(source)); |
146 var entryUnit = _resolver.context.resolveCompilationUnit2(source, source); | 146 var entryUnit = _resolver.context.resolveCompilationUnit2(source, source); |
147 var lib = entryUnit.element.enclosingElement; | 147 var lib = entryUnit.element.enclosingElement; |
148 if (!_options.checkSdk && lib.isInSdk) return; | 148 if (!_options.checkSdk && lib.isInSdk) return; |
149 var current = node.info; | 149 var current = node.info; |
150 if (current != null) { | 150 if (current != null) { |
151 assert(current.library == lib); | 151 assert(current.library == lib); |
152 } else { | 152 } else { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 263 } |
264 | 264 |
265 rebuildIfNeeded(shelf.Request request) { | 265 rebuildIfNeeded(shelf.Request request) { |
266 var filepath = request.url.path; | 266 var filepath = request.url.path; |
267 if (filepath == '/$_entryPath' || filepath == '/') compiler._runAgain(); | 267 if (filepath == '/$_entryPath' || filepath == '/') compiler._runAgain(); |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
271 final _log = new Logger('dev_compiler'); | 271 final _log = new Logger('dev_compiler'); |
272 final _earlyErrorResult = new CheckerResults(const [], null, true); | 272 final _earlyErrorResult = new CheckerResults(const [], null, true); |
OLD | NEW |