OLD | NEW |
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.poi; | 5 library trydart.poi; |
6 | 6 |
7 import 'dart:async' show | 7 import 'dart:async' show |
8 Completer, | 8 Completer, |
9 Future; | 9 Future; |
10 | 10 |
11 import 'dart:io' show | |
12 File, | |
13 HttpClient, | |
14 HttpClientRequest, | |
15 HttpClientResponse, | |
16 Platform, | |
17 stdout; | |
18 | |
19 import 'dart:io' as io; | 11 import 'dart:io' as io; |
20 | 12 |
21 import 'dart:convert' show | 13 import 'dart:convert' show |
22 UTF8; | 14 UTF8; |
23 | 15 |
24 import 'package:dart2js_incremental/dart2js_incremental.dart' show | 16 import 'package:dart2js_incremental/dart2js_incremental.dart' show |
25 reuseCompiler; | 17 reuseCompiler; |
26 | 18 |
27 import 'package:dart2js_incremental/library_updater.dart' show | 19 import 'package:dart2js_incremental/library_updater.dart' show |
28 LibraryUpdater; | 20 LibraryUpdater; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 return (Uri uri) { | 189 return (Uri uri) { |
198 if (counter != globalCounter) throw 'Using old provider'; | 190 if (counter != globalCounter) throw 'Using old provider'; |
199 printVerbose('fake inputProvider#$counter($uri): $poiCount $count'); | 191 printVerbose('fake inputProvider#$counter($uri): $poiCount $count'); |
200 if (uri == script) { | 192 if (uri == script) { |
201 if (poiCount == count) { | 193 if (poiCount == count) { |
202 cachedFileName = uri.toFilePath(); | 194 cachedFileName = uri.toFilePath(); |
203 if (count != 0) { | 195 if (count != 0) { |
204 cachedFileName = '$cachedFileName.$count.dart'; | 196 cachedFileName = '$cachedFileName.$count.dart'; |
205 } | 197 } |
206 printVerbose('Not using cached version of $cachedFileName'); | 198 printVerbose('Not using cached version of $cachedFileName'); |
207 cache = new File(cachedFileName).readAsBytes().then((data) { | 199 cache = new io.File(cachedFileName).readAsBytes().then((data) { |
208 printVerbose('Read file $cachedFileName: ${UTF8.decode(data)}'); | 200 printVerbose('Read file $cachedFileName: ${UTF8.decode(data)}'); |
209 return data; | 201 return data; |
210 }); | 202 }); |
211 count++; | 203 count++; |
212 } else { | 204 } else { |
213 printVerbose('Using cached version of $cachedFileName'); | 205 printVerbose('Using cached version of $cachedFileName'); |
214 } | 206 } |
215 return cache; | 207 return cache; |
216 } else { | 208 } else { |
217 printVerbose('Using original provider for $uri'); | 209 printVerbose('Using original provider for $uri'); |
218 return inputProvider(uri); | 210 return inputProvider(uri); |
219 } | 211 } |
220 }; | 212 }; |
221 } | 213 } |
222 | 214 |
223 Future<String> prompt(message) { | 215 Future<String> prompt(message) { |
224 if (stdin is StdinIterator) { | 216 if (stdin is StdinIterator) { |
225 stdout.write(message); | 217 io.stdout.write(message); |
226 } | 218 } |
227 return stdout.flush().then((_) { | 219 return io.stdout.flush().then((_) { |
228 stdin.moveNext(); | 220 stdin.moveNext(); |
229 return stdin.current; | 221 return stdin.current; |
230 }); | 222 }); |
231 } | 223 } |
232 | 224 |
233 Future queryDartMind(String prefix, String info) { | 225 Future queryDartMind(String prefix, String info) { |
234 // TODO(lukechurch): Use [info] for something. | 226 // TODO(lukechurch): Use [info] for something. |
235 String encodedArg0 = Uri.encodeComponent('"$prefix"'); | 227 String encodedArg0 = Uri.encodeComponent('"$prefix"'); |
236 String mindQuery = | 228 String mindQuery = |
237 'http://dart-mind.appspot.com/rpc' | 229 'http://dart-mind.appspot.com/rpc' |
238 '?action=GetExportingPubCompletions' | 230 '?action=GetExportingPubCompletions' |
239 '&arg0=$encodedArg0'; | 231 '&arg0=$encodedArg0'; |
240 Uri uri = Uri.parse(mindQuery); | 232 Uri uri = Uri.parse(mindQuery); |
241 | 233 |
242 HttpClient client = new HttpClient(); | 234 io.HttpClient client = new io.HttpClient(); |
243 return client.getUrl(uri).then((HttpClientRequest request) { | 235 return client.getUrl(uri).then((io.HttpClientRequest request) { |
244 return request.close(); | 236 return request.close(); |
245 }).then((HttpClientResponse response) { | 237 }).then((io.HttpClientResponse response) { |
246 Completer<String> completer = new Completer<String>(); | 238 Completer<String> completer = new Completer<String>(); |
247 response.transform(UTF8.decoder).listen((contents) { | 239 response.transform(UTF8.decoder).listen((contents) { |
248 completer.complete(contents); | 240 completer.complete(contents); |
249 }); | 241 }); |
250 return completer.future; | 242 return completer.future; |
251 }); | 243 }); |
252 } | 244 } |
253 | 245 |
254 Future parseUserInput( | 246 Future parseUserInput( |
255 String fileName, | 247 String fileName, |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 return null; | 348 return null; |
357 } | 349 } |
358 | 350 |
359 Future<Element> runPoi( | 351 Future<Element> runPoi( |
360 Uri script, | 352 Uri script, |
361 int position, | 353 int position, |
362 api.CompilerInputProvider inputProvider, | 354 api.CompilerInputProvider inputProvider, |
363 api.DiagnosticHandler handler) { | 355 api.DiagnosticHandler handler) { |
364 Uri libraryRoot = Uri.base.resolve('sdk/'); | 356 Uri libraryRoot = Uri.base.resolve('sdk/'); |
365 Uri packageRoot = Uri.base.resolveUri( | 357 Uri packageRoot = Uri.base.resolveUri( |
366 new Uri.file('${Platform.packageRoot}/')); | 358 new Uri.file('${io.Platform.packageRoot}/')); |
367 | 359 |
368 var options = [ | 360 var options = [ |
369 '--analyze-main', | 361 '--analyze-main', |
370 '--analyze-only', | 362 '--analyze-only', |
371 '--no-source-maps', | 363 '--no-source-maps', |
372 '--verbose', | 364 '--verbose', |
373 '--categories=Client,Server', | 365 '--categories=Client,Server', |
374 '--incremental-support', | 366 '--incremental-support', |
375 '--disable-type-inference', | 367 '--disable-type-inference', |
376 ]; | 368 ]; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 buffer.write('\n'); | 718 buffer.write('\n'); |
727 indented.write('}'); | 719 indented.write('}'); |
728 } | 720 } |
729 } | 721 } |
730 | 722 |
731 modelx.ScopeX localScope(modelx.LibraryElementX element) => element.localScope; | 723 modelx.ScopeX localScope(modelx.LibraryElementX element) => element.localScope; |
732 | 724 |
733 modelx.ImportScope importScope(modelx.LibraryElementX element) { | 725 modelx.ImportScope importScope(modelx.LibraryElementX element) { |
734 return element.importScope; | 726 return element.importScope; |
735 } | 727 } |
OLD | NEW |