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

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

Issue 197923002: Mock up code completion. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Too many changes to summarize in one line. Created 6 years, 9 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.compilation; 5 library trydart.compilation;
6 6
7 import 'dart:html' show 7 import 'dart:html' show
8 Blob, 8 Blob,
9 Element, 9 Element,
10 ErrorEvent, 10 ErrorEvent,
(...skipping 11 matching lines...) Expand all
22 22
23 import 'editor.dart' show 23 import 'editor.dart' show
24 addDiagnostic, 24 addDiagnostic,
25 currentSource, 25 currentSource,
26 isMalformedInput; 26 isMalformedInput;
27 27
28 import 'run.dart' show 28 import 'run.dart' show
29 makeOutputFrame; 29 makeOutputFrame;
30 30
31 import 'ui.dart' show 31 import 'ui.dart' show
32 buildButton,
33 outputDiv,
34 outputFrame;
35
36 import 'settings.dart' show
32 alwaysRunInWorker, 37 alwaysRunInWorker,
33 applyingSettings, 38 compilationPaused,
34 buildButton,
35 minified, 39 minified,
36 onlyAnalyze, 40 onlyAnalyze,
37 outputDiv,
38 outputFrame,
39 verboseCompiler; 41 verboseCompiler;
40 42
43 @lazy import 'caching_compiler.dart' as cacheCompiler;
44
41 @lazy import 'compiler_isolate.dart'; 45 @lazy import 'compiler_isolate.dart';
42 46
43 // const lazy = const DeferredLibrary('compiler_isolate'); 47 // const lazy = const DeferredLibrary('compiler_isolate');
44 const lazy = null; 48 const lazy = null;
45 49
50 /**
51 * Scheme for recognizing files stored in memory.
52 *
53 * From http://tools.ietf.org/html/bcp35#section-2.8:
54 *
55 * Organizations that desire a private name space for URI scheme names
56 * are encouraged to use a prefix based on their domain name, expressed
57 * in reverse order. For example, a URI scheme name of com-example-info
58 * might be registered by the vendor that owns the example.com domain
59 * name.
60 */
61 const String PRIVATE_SCHEME = 'org-trydart';
62
46 SendPort compilerPort; 63 SendPort compilerPort;
47 Timer compilerTimer; 64 Timer compilerTimer;
48 65
49 void scheduleCompilation() { 66 void scheduleCompilation() {
50 if (applyingSettings) return; 67 if (compilationPaused) return;
51 if (compilerTimer != null) { 68 if (compilerTimer != null) {
52 compilerTimer.cancel(); 69 compilerTimer.cancel();
53 compilerTimer = null; 70 compilerTimer = null;
54 } 71 }
55 compilerTimer = 72 compilerTimer =
56 new Timer(const Duration(milliseconds: 500), startCompilation); 73 new Timer(const Duration(milliseconds: 500), startCompilation);
57 } 74 }
58 75
59 void startCompilation() { 76 void startCompilation() {
60 if (compilerTimer != null) { 77 if (compilerTimer != null) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 }; 178 };
162 self.importScripts("$url"); 179 self.importScripts("$url");
163 '''; 180 ''';
164 var wrapperUrl = 181 var wrapperUrl =
165 Url.createObjectUrl(new Blob([wrapper], 'application/javascript')); 182 Url.createObjectUrl(new Blob([wrapper], 'application/javascript'));
166 objectUrls.add(wrapperUrl); 183 objectUrls.add(wrapperUrl);
167 void retryInIframe(_) { 184 void retryInIframe(_) {
168 var frame = makeOutputFrame(url); 185 var frame = makeOutputFrame(url);
169 outputFrame.replaceWith(frame); 186 outputFrame.replaceWith(frame);
170 outputFrame = frame; 187 outputFrame = frame;
188 console.append(buildButton('Try in iframe', retryInIframe));
171 } 189 }
172 void onError(String errorMessage) { 190 void onError(String errorMessage) {
173 console.appendText(errorMessage); 191 console.appendText(errorMessage);
174 console.appendText(' '); 192 console.appendText(' ');
175 console.append(buildButton('Try in iframe', retryInIframe)); 193 console.append(buildButton('Try in iframe', retryInIframe));
176 console.appendText('\n'); 194 console.appendText('\n');
177 } 195 }
178 if (usesDartHtml && !alwaysRunInWorker) { 196 if (usesDartHtml && !alwaysRunInWorker) {
179 retryInIframe(null); 197 retryInIframe(null);
180 } else { 198 } else {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 console.appendText('.'); 265 console.appendText('.');
248 } 266 }
249 return; 267 return;
250 } 268 }
251 String uri = diagnostic['uri']; 269 String uri = diagnostic['uri'];
252 if (uri == null) { 270 if (uri == null) {
253 clear(); 271 clear();
254 consolePrint(message); 272 consolePrint(message);
255 return; 273 return;
256 } 274 }
257 if (uri != 'memory:/main.dart') return; 275 if (uri != '${PRIVATE_SCHEME}:/main.dart') return;
258 if (currentSource != source) return; 276 if (currentSource != source) return;
259 int begin = diagnostic['begin']; 277 int begin = diagnostic['begin'];
260 int end = diagnostic['end']; 278 int end = diagnostic['end'];
261 if (begin == null) return; 279 if (begin == null) return;
262 addDiagnostic(kind, message, begin, end); 280 addDiagnostic(kind, message, begin, end);
263 } 281 }
264 282
265 onCrash(data) { 283 onCrash(data) {
266 consolePrint(data); 284 consolePrint(data);
267 } 285 }
268 286
269 void consolePrint(message) { 287 void consolePrint(message) {
270 console.appendText('$message\n'); 288 console.appendText('$message\n');
271 } 289 }
272 } 290 }
273 291
274 void compilerIsolate(SendPort port) { 292 void compilerIsolate(SendPort port) {
275 // TODO(ahe): Restore when restoring deferred loading. 293 // TODO(ahe): Restore when restoring deferred loading.
276 // lazy.load().then((_) => port.listen(compile)); 294 // lazy.load().then((_) => port.listen(compile));
277 ReceivePort replyTo = new ReceivePort(); 295 ReceivePort replyTo = new ReceivePort();
278 port.send(replyTo.sendPort); 296 port.send(replyTo.sendPort);
279 replyTo.listen((message) { 297 replyTo.listen((message) {
280 List list = message as List; 298 List list = message as List;
281 try { 299 try {
282 compile(list[0], list[1]); 300 compile(list[0], list[1]);
283 } catch (exception, stack) { 301 } catch (exception, stack) {
284 port.send('$exception\n$stack'); 302 port.send('$exception\n$stack');
285 } 303 }
286 }); 304 });
305 // cacheCompiler.compilerFor(null);
kasperl 2014/03/24 10:32:51 ?
ahe 2014/03/24 15:20:23 This code will be cleaned up in a follow-up CL.
287 } 306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698