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

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

Issue 197923002: Mock up code completion. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r34309. 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
« no previous file with comments | « dart/site/try/src/isolate_legacy.dart ('k') | dart/site/try/src/messages.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) 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.main; 5 library trydart.main;
6 6
7 import 'dart:html' show 7 import 'dart:html' show
8 HttpRequest, 8 HttpRequest,
9 LinkElement, 9 LinkElement,
10 query, 10 querySelector,
11 window; 11 window;
12 12
13 import 'dart:isolate' show 13 import 'dart:isolate' show
14 ReceivePort, 14 ReceivePort,
15 SendPort; 15 SendPort;
16 16
17 import 'compilation.dart' show 17 import 'compilation.dart' show
18 compilerIsolate, 18 compilerIsolate,
19 compilerPort; 19 compilerPort;
20 20
21 import 'editor.dart' show
22 onMutation;
23
24 import 'isolate_legacy.dart' show 21 import 'isolate_legacy.dart' show
25 spawnDomFunction, 22 spawnDomFunction,
26 spawnFunction; 23 spawnFunction;
27 24
28 import 'samples.dart' show 25 import 'samples.dart' show
29 EXAMPLE_HELLO; 26 EXAMPLE_HELLO;
30 27
31 import 'ui.dart' show 28 import 'ui.dart' show
32 buildUI, 29 buildUI,
30 interaction,
33 observer; 31 observer;
34 32
33 import 'user_option.dart' show
34 UserOption;
35
35 int count = 0; 36 int count = 0;
36 37
37 const String HAS_NON_DOM_HTTP_REQUEST = 'spawnFunction supports HttpRequest'; 38 const String HAS_NON_DOM_HTTP_REQUEST = 'spawnFunction supports HttpRequest';
38 const String NO_NON_DOM_HTTP_REQUEST = 39 const String NO_NON_DOM_HTTP_REQUEST =
39 'spawnFunction does not support HttpRequest'; 40 'spawnFunction does not support HttpRequest';
40 41
41 checkHttpRequest(SendPort replyTo) { 42 checkHttpRequest(SendPort replyTo) {
42 try { 43 try {
43 new HttpRequest(); 44 new HttpRequest();
44 replyTo.send(HAS_NON_DOM_HTTP_REQUEST); 45 replyTo.send(HAS_NON_DOM_HTTP_REQUEST);
45 } catch (e, trace) { 46 } catch (e, trace) {
46 replyTo.send(NO_NON_DOM_HTTP_REQUEST); 47 replyTo.send(NO_NON_DOM_HTTP_REQUEST);
47 } 48 }
48 } 49 }
49 50
50 main() { 51 main() {
52 UserOption.storage = window.localStorage;
51 if (window.localStorage['currentSource'] == null) { 53 if (window.localStorage['currentSource'] == null) {
52 window.localStorage['currentSource'] = EXAMPLE_HELLO; 54 window.localStorage['currentSource'] = EXAMPLE_HELLO;
53 } 55 }
54 56
55 buildUI(); 57 buildUI();
56 spawnFunction(checkHttpRequest).first.then((reply) { 58 spawnFunction(checkHttpRequest).first.then((reply) {
57 ReceivePort port; 59 ReceivePort port;
58 if (reply == HAS_NON_DOM_HTTP_REQUEST) { 60 if (reply == HAS_NON_DOM_HTTP_REQUEST) {
59 port = spawnFunction(compilerIsolate); 61 port = spawnFunction(compilerIsolate);
60 } else { 62 } else {
61 port = spawnDomFunction(compilerIsolate); 63 port = spawnDomFunction(compilerIsolate);
62 } 64 }
63 LinkElement link = query('link[rel="dart-sdk"]'); 65 LinkElement link = querySelector('link[rel="dart-sdk"]');
64 String sdk = link.href; 66 String sdk = link.href;
65 print('Using Dart SDK: $sdk'); 67 print('Using Dart SDK: $sdk');
66 int messageCount = 0; 68 int messageCount = 0;
67 SendPort sendPort; 69 SendPort sendPort;
68 port.listen((message) { 70 port.listen((message) {
69 messageCount++; 71 messageCount++;
70 switch (messageCount) { 72 switch (messageCount) {
71 case 1: 73 case 1:
72 sendPort = message as SendPort; 74 sendPort = message as SendPort;
73 sendPort.send([sdk, port.sendPort]); 75 sendPort.send([sdk, port.sendPort]);
74 break; 76 break;
75 case 2: 77 case 2:
76 // Acknowledged Receiving the SDK URI. 78 // Acknowledged Receiving the SDK URI.
77 compilerPort = sendPort; 79 compilerPort = sendPort;
78 onMutation([], observer); 80 interaction.onMutation([], observer);
79 break; 81 break;
80 default: 82 default:
81 // TODO(ahe): Close [port]? 83 // TODO(ahe): Close [port]?
82 print('Unexpected message received: $message'); 84 print('Unexpected message received: $message');
83 break; 85 break;
84 } 86 }
85 }); 87 });
86 }); 88 });
87 } 89 }
OLDNEW
« no previous file with comments | « dart/site/try/src/isolate_legacy.dart ('k') | dart/site/try/src/messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698