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

Side by Side Diff: pkg/front_end/example/incremental_reload/compiler_with_invalidation.dart

Issue 2926933002: Skip directly to the last library to set the entry point and check importUri (Closed)
Patch Set: fix Created 3 years, 6 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/incremental_kernel_generator_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 Program program; 150 Program program;
151 } 151 }
152 152
153 /// Request a recompile and possibly a reload, and gather timing metrics. 153 /// Request a recompile and possibly a reload, and gather timing metrics.
154 Future<CompilationResult> rebuild( 154 Future<CompilationResult> rebuild(
155 IncrementalCompiler compiler, Uri outputUri) async { 155 IncrementalCompiler compiler, Uri outputUri) async {
156 var result = new CompilationResult(); 156 var result = new CompilationResult();
157 try { 157 try {
158 var program = result.program = await compiler.recompile(); 158 var program = result.program = await compiler.recompile();
159 if (program != null && !program.libraries.isEmpty) { 159 if (program != null && !program.libraries.isEmpty) {
160 // TODO(sigmund): the incremental generator should set the main method
161 // directly.
162 var mainLib = program.libraries.last;
163 program.mainMethod =
164 mainLib.procedures.firstWhere((p) => p.name.name == 'main');
165 var sink = new File.fromUri(outputUri).openWrite(); 160 var sink = new File.fromUri(outputUri).openWrite();
166
167 // TODO(sigmund): should the incremental generator always filter these 161 // TODO(sigmund): should the incremental generator always filter these
168 // libraries instead? 162 // libraries instead?
169 new LimitedBinaryPrinter( 163 new LimitedBinaryPrinter(
170 sink, (library) => library.importUri.scheme != 'dart') 164 sink, (library) => library.importUri.scheme != 'dart')
171 .writeProgramFile(program); 165 .writeProgramFile(program);
172 await sink.close(); 166 await sink.close();
173 } 167 }
174 } catch (e, t) { 168 } catch (e, t) {
175 result.errorDetails = 'compilation error: $e, $t'; 169 result.errorDetails = 'compilation error: $e, $t';
176 result.errorSeen = true; 170 result.errorSeen = true;
177 } 171 }
178 172
179 result.changed = compiler.changed; 173 result.changed = compiler.changed;
180 result.totalFiles = compiler.lastModified.length; 174 result.totalFiles = compiler.lastModified.length;
181 result.invalidateTime = compiler.invalidateTime; 175 result.invalidateTime = compiler.invalidateTime;
182 result.compileTime = compiler.compileTime; 176 result.compileTime = compiler.compileTime;
183 result.reloadTime = 0; 177 result.reloadTime = 0;
184 return result; 178 return result;
185 } 179 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/incremental_kernel_generator_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698