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

Side by Side Diff: dart/site/try/src/compiler_isolate.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/compilation.dart ('k') | dart/site/try/src/decoration.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 compiler_isolate; 5 library compiler_isolate;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import 'dart:convert' show JSON; 10 import 'dart:convert' show JSON;
11 11
12 import '../../../sdk/lib/_internal/compiler/compiler.dart' as compiler; 12 import 'compilation.dart' show PRIVATE_SCHEME;
13
14 import 'package:compiler/compiler.dart' as compiler;
13 15
14 const bool THROW_ON_ERROR = false; 16 const bool THROW_ON_ERROR = false;
15 17
16 final cachedSources = new Map<Uri, String>(); 18 final cachedSources = new Map<Uri, String>();
17 19
18 Uri sdkLocation; 20 Uri sdkLocation;
19 List options = []; 21 List options = [];
20 22
21 compile(source, SendPort replyTo) { 23 compile(source, SendPort replyTo) {
22 if (sdkLocation == null) { 24 if (sdkLocation == null) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return new Future.value(value); 59 return new Future.value(value);
58 } else if (uri.scheme == 'http' || uri.scheme == 'https') { 60 } else if (uri.scheme == 'http' || uri.scheme == 'https') {
59 var value = cachedSources.putIfAbsent(uri, () { 61 var value = cachedSources.putIfAbsent(uri, () {
60 var request = new HttpRequest(); 62 var request = new HttpRequest();
61 request.open('GET', '$uri', async: false); 63 request.open('GET', '$uri', async: false);
62 request.send(null); 64 request.send(null);
63 return request.responseText; 65 return request.responseText;
64 }); 66 });
65 charactersRead += value.length; 67 charactersRead += value.length;
66 return new Future.value(value); 68 return new Future.value(value);
67 } else if ('$uri' == 'memory:/main.dart') { 69 } else if ('$uri' == '$PRIVATE_SCHEME:/main.dart') {
68 charactersRead += source.length; 70 charactersRead += source.length;
69 return new Future.value(source); 71 return new Future.value(source);
72 } else if (uri.scheme == PRIVATE_SCHEME) {
73 return HttpRequest.getString('project${uri.path}');
70 } 74 }
71 throw new Exception('Error: Cannot read: $uri'); 75 throw new Exception('Error: Cannot read: $uri');
72 } 76 }
73 void handler(Uri uri, int begin, int end, 77 void handler(Uri uri, int begin, int end,
74 String message, compiler.Diagnostic kind) { 78 String message, compiler.Diagnostic kind) {
75 replyTo.send(['diagnostic', { 'uri': '$uri', 79 replyTo.send(['diagnostic', { 'uri': '$uri',
76 'begin': begin, 80 'begin': begin,
77 'end': end, 81 'end': end,
78 'message': message, 82 'message': message,
79 'kind': kind.name }]); 83 'kind': kind.name }]);
80 if (THROW_ON_ERROR && kind == compiler.Diagnostic.ERROR) { 84 if (THROW_ON_ERROR && kind == compiler.Diagnostic.ERROR) {
81 throw new Exception('Throw on error'); 85 throw new Exception('Throw on error');
82 } 86 }
83 } 87 }
84 compiler.compile(Uri.parse('memory:/main.dart'), 88 compiler.compile(Uri.parse('$PRIVATE_SCHEME:/main.dart'),
85 sdkLocation, 89 sdkLocation,
86 null, 90 Uri.parse('packages/'),
87 inputProvider, 91 inputProvider,
88 handler, 92 handler,
89 options).then((js) { 93 options).then((js) {
90 try { 94 try {
91 if (js == null) { 95 if (js == null) {
92 if (!options.contains('--analyze-only')) replyTo.send('failed'); 96 if (!options.contains('--analyze-only')) replyTo.send('failed');
93 } else { 97 } else {
94 var url; 98 var url;
95 if (options.contains('--verbose')) { 99 if (options.contains('--verbose')) {
96 handler(null, 0, 0, 100 handler(null, 0, 0,
(...skipping 14 matching lines...) Expand all
111 } else { 115 } else {
112 replyTo.send(['code', js]); 116 replyTo.send(['code', js]);
113 } 117 }
114 } 118 }
115 } catch (e, trace) { 119 } catch (e, trace) {
116 replyTo.send(['crash', '$e, $trace']); 120 replyTo.send(['crash', '$e, $trace']);
117 } 121 }
118 replyTo.send('done'); 122 replyTo.send('done');
119 }); 123 });
120 } 124 }
OLDNEW
« no previous file with comments | « dart/site/try/src/compilation.dart ('k') | dart/site/try/src/decoration.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698