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

Side by Side Diff: dart/site/try/src/interaction_manager.dart

Issue 350443006: Add secret option "live" which compiles more frequently. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/site/try/src/settings.dart » ('j') | dart/site/try/src/settings.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library trydart.interaction_manager; 5 library trydart.interaction_manager;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 8
9 import 'dart:convert' show 9 import 'dart:convert' show
10 JSON; 10 JSON;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 const Duration HEARTBEAT_INTERVAL = const Duration(milliseconds: 50); 87 const Duration HEARTBEAT_INTERVAL = const Duration(milliseconds: 50);
88 88
89 /// Determines how frequently "project" files are saved. The time is measured 89 /// Determines how frequently "project" files are saved. The time is measured
90 /// from the time of last modification. 90 /// from the time of last modification.
91 const Duration SAVE_INTERVAL = const Duration(seconds: 5); 91 const Duration SAVE_INTERVAL = const Duration(seconds: 5);
92 92
93 /// Determines how frequently the compiler is invoked. The time is measured 93 /// Determines how frequently the compiler is invoked. The time is measured
94 /// from the time of last modification. 94 /// from the time of last modification.
95 const Duration COMPILE_INTERVAL = const Duration(seconds: 1); 95 const Duration COMPILE_INTERVAL = const Duration(seconds: 1);
96 96
97 /// Determines how frequently the compiler is invoked in "live" mode. The time
98 /// is measured from the time of last modification.
99 const Duration LIVE_COMPILE_INTERVAL = const Duration(seconds: 0);
100
97 /// Determines if a compilation is slow. The time is measured from the last 101 /// Determines if a compilation is slow. The time is measured from the last
98 /// compilation started. If a compilation is slow, progress information is 102 /// compilation started. If a compilation is slow, progress information is
99 /// displayed to the user, but the console is untouched if the compilation 103 /// displayed to the user, but the console is untouched if the compilation
100 /// finished quickly. The purpose is to reduce flicker in the UI. 104 /// finished quickly. The purpose is to reduce flicker in the UI.
101 const Duration SLOW_COMPILE = const Duration(seconds: 1); 105 const Duration SLOW_COMPILE = const Duration(seconds: 1);
102 106
103 /** 107 /**
104 * UI interaction manager for the entire application. 108 * UI interaction manager for the entire application.
105 */ 109 */
106 abstract class InteractionManager { 110 abstract class InteractionManager {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 Completer<String> completeSaveOperation; 206 Completer<String> completeSaveOperation;
203 207
204 bool shouldClearConsole = false; 208 bool shouldClearConsole = false;
205 209
206 Element compilerConsole; 210 Element compilerConsole;
207 211
208 bool isFirstCompile = true; 212 bool isFirstCompile = true;
209 213
210 final Set<AnchorElement> oldDiagnostics = new Set<AnchorElement>(); 214 final Set<AnchorElement> oldDiagnostics = new Set<AnchorElement>();
211 215
216 final Duration compileInterval = settings.live.value
217 ? LIVE_COMPILE_INTERVAL
218 : COMPILE_INTERVAL;
219
212 InteractionContext() 220 InteractionContext()
213 : super.internal() { 221 : super.internal() {
214 state = new InitialState(this); 222 state = new InitialState(this);
215 heartbeat = new Timer.periodic(HEARTBEAT_INTERVAL, onHeartbeat); 223 heartbeat = new Timer.periodic(HEARTBEAT_INTERVAL, onHeartbeat);
216 } 224 }
217 225
218 void onInput(Event event) => state.onInput(event); 226 void onInput(Event event) => state.onInput(event);
219 227
220 void onKeyUp(KeyboardEvent event) => state.onKeyUp(event); 228 void onKeyUp(KeyboardEvent event) => state.onKeyUp(event);
221 229
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 if (context.unitsToSave.isEmpty && 570 if (context.unitsToSave.isEmpty &&
563 context.saveTimer.elapsed > SAVE_INTERVAL) { 571 context.saveTimer.elapsed > SAVE_INTERVAL) {
564 context.saveTimer 572 context.saveTimer
565 ..stop() 573 ..stop()
566 ..reset(); 574 ..reset();
567 context.unitsToSave.addAll(context.modifiedUnits); 575 context.unitsToSave.addAll(context.modifiedUnits);
568 context.modifiedUnits.clear(); 576 context.modifiedUnits.clear();
569 saveUnits(); 577 saveUnits();
570 } 578 }
571 if (!settings.compilationPaused && 579 if (!settings.compilationPaused &&
572 context.compileTimer.elapsed > COMPILE_INTERVAL) { 580 context.compileTimer.elapsed > context.compileInterval) {
573 if (startCompilation()) { 581 if (startCompilation()) {
574 context.compileTimer 582 context.compileTimer
575 ..stop() 583 ..stop()
576 ..reset(); 584 ..reset();
577 } 585 }
578 } 586 }
579 587
580 if (context.elapsedCompilationTime.elapsed > SLOW_COMPILE) { 588 if (context.elapsedCompilationTime.elapsed > SLOW_COMPILE) {
581 if (context.compilerConsole.parent == null) { 589 if (context.compilerConsole.parent == null) {
582 outputDiv.append(context.compilerConsole); 590 outputDiv.append(context.compilerConsole);
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 bool isCompilerStageMarker(String message) { 1196 bool isCompilerStageMarker(String message) {
1189 return 1197 return
1190 message.startsWith('Package root is ') || 1198 message.startsWith('Package root is ') ||
1191 message.startsWith('Compiling ') || 1199 message.startsWith('Compiling ') ||
1192 message == "Resolving..." || 1200 message == "Resolving..." ||
1193 message.startsWith('Resolved ') || 1201 message.startsWith('Resolved ') ||
1194 message == "Inferring types..." || 1202 message == "Inferring types..." ||
1195 message == "Compiling..." || 1203 message == "Compiling..." ||
1196 message.startsWith('Compiled '); 1204 message.startsWith('Compiled ');
1197 } 1205 }
OLDNEW
« no previous file with comments | « no previous file | dart/site/try/src/settings.dart » ('j') | dart/site/try/src/settings.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698