OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /// A wrapper on top of the [IncrementalKernelGenerator] that tracks | 5 /// A wrapper on top of the [IncrementalKernelGenerator] that tracks |
6 /// file modifications between subsequent compilation requests and only | 6 /// file modifications between subsequent compilation requests and only |
7 /// invalidates those files that appear to be modified. | 7 /// invalidates those files that appear to be modified. |
8 library front_end.example.incremental_reload.compiler_with_invalidation; | 8 library front_end.example.incremental_reload.compiler_with_invalidation; |
9 | 9 |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 Future<CompilationResult> rebuild( | 156 Future<CompilationResult> rebuild( |
157 IncrementalCompiler compiler, Uri outputUri) async { | 157 IncrementalCompiler compiler, Uri outputUri) async { |
158 var result = new CompilationResult(); | 158 var result = new CompilationResult(); |
159 try { | 159 try { |
160 var program = result.program = await compiler.recompile(); | 160 var program = result.program = await compiler.recompile(); |
161 if (program != null && !program.libraries.isEmpty) { | 161 if (program != null && !program.libraries.isEmpty) { |
162 var sink = new File.fromUri(outputUri).openWrite(); | 162 var sink = new File.fromUri(outputUri).openWrite(); |
163 // TODO(sigmund): should the incremental generator always filter these | 163 // TODO(sigmund): should the incremental generator always filter these |
164 // libraries instead? | 164 // libraries instead? |
165 new LimitedBinaryPrinter( | 165 new LimitedBinaryPrinter( |
166 sink, (library) => library.importUri.scheme != 'dart') | 166 sink, (library) => library.importUri.scheme != 'dart', false) |
167 .writeProgramFile(program); | 167 .writeProgramFile(program); |
168 await sink.close(); | 168 await sink.close(); |
169 } | 169 } |
170 } catch (e, t) { | 170 } catch (e, t) { |
171 result.errorDetails = 'compilation error: $e, $t'; | 171 result.errorDetails = 'compilation error: $e, $t'; |
172 result.errorSeen = true; | 172 result.errorSeen = true; |
173 } | 173 } |
174 | 174 |
175 result.changed = compiler.changed; | 175 result.changed = compiler.changed; |
176 result.totalFiles = compiler.lastModified.length; | 176 result.totalFiles = compiler.lastModified.length; |
177 result.invalidateTime = compiler.invalidateTime; | 177 result.invalidateTime = compiler.invalidateTime; |
178 result.compileTime = compiler.compileTime; | 178 result.compileTime = compiler.compileTime; |
179 result.reloadTime = 0; | 179 result.reloadTime = 0; |
180 return result; | 180 return result; |
181 } | 181 } |
OLD | NEW |