| 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 | 11 import 'dart:io' show |
| 12 File, | 12 File, |
| 13 HttpClient, | 13 HttpClient, |
| 14 HttpClientRequest, | 14 HttpClientRequest, |
| 15 HttpClientResponse, | 15 HttpClientResponse, |
| 16 Platform, | 16 Platform, |
| 17 stdout; | 17 stdout; |
| 18 | 18 |
| 19 import 'dart:io' as io; | 19 import 'dart:io' as io; |
| 20 | 20 |
| 21 import 'dart:convert' show | 21 import 'dart:convert' show |
| 22 UTF8; | 22 UTF8; |
| 23 | 23 |
| 24 import 'package:dart2js_incremental/dart2js_incremental.dart' show | 24 import 'package:dart2js_incremental/dart2js_incremental.dart' show |
| 25 reuseCompiler; | 25 reuseCompiler; |
| 26 | 26 |
| 27 import 'package:dart2js_incremental/library_updater.dart' show |
| 28 LibraryUpdater; |
| 29 |
| 27 import 'package:compiler/implementation/source_file_provider.dart' show | 30 import 'package:compiler/implementation/source_file_provider.dart' show |
| 28 FormattingDiagnosticHandler; | 31 FormattingDiagnosticHandler; |
| 29 | 32 |
| 30 import 'package:compiler/compiler.dart' as api; | 33 import 'package:compiler/compiler.dart' as api; |
| 31 | 34 |
| 32 import 'package:compiler/implementation/dart2jslib.dart' show | 35 import 'package:compiler/implementation/dart2jslib.dart' show |
| 33 Compiler, | 36 Compiler, |
| 34 Enqueuer, | 37 Enqueuer, |
| 35 QueueFilter, | 38 QueueFilter, |
| 36 WorkItem; | 39 WorkItem; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 var options = [ | 368 var options = [ |
| 366 '--analyze-main', | 369 '--analyze-main', |
| 367 '--analyze-only', | 370 '--analyze-only', |
| 368 '--no-source-maps', | 371 '--no-source-maps', |
| 369 '--verbose', | 372 '--verbose', |
| 370 '--categories=Client,Server', | 373 '--categories=Client,Server', |
| 371 '--incremental-support', | 374 '--incremental-support', |
| 372 '--disable-type-inference', | 375 '--disable-type-inference', |
| 373 ]; | 376 ]; |
| 374 | 377 |
| 378 LibraryUpdater updater = |
| 379 new LibraryUpdater( |
| 380 cachedCompiler, inputProvider, script, printWallClock, printVerbose); |
| 381 |
| 375 return reuseCompiler( | 382 return reuseCompiler( |
| 376 diagnosticHandler: handler, | 383 diagnosticHandler: handler, |
| 377 inputProvider: inputProvider, | 384 inputProvider: inputProvider, |
| 378 options: options, | 385 options: options, |
| 379 cachedCompiler: cachedCompiler, | 386 cachedCompiler: cachedCompiler, |
| 380 libraryRoot: libraryRoot, | 387 libraryRoot: libraryRoot, |
| 381 packageRoot: packageRoot, | 388 packageRoot: packageRoot, |
| 382 packagesAreImmutable: true).then((Compiler newCompiler) { | 389 packagesAreImmutable: true, |
| 390 reuseLibrary: updater.reuseLibrary).then((Compiler newCompiler) { |
| 383 var filter = new ScriptOnlyFilter(script); | 391 var filter = new ScriptOnlyFilter(script); |
| 384 newCompiler.enqueuerFilter = filter; | 392 newCompiler.enqueuerFilter = filter; |
| 385 return runPoiInternal(newCompiler, script, position); | 393 return runPoiInternal(newCompiler, updater, position); |
| 386 }); | 394 }); |
| 387 } | 395 } |
| 388 | 396 |
| 389 Future<Element> runPoiInternal( | 397 Future<Element> runPoiInternal( |
| 390 Compiler newCompiler, | 398 Compiler newCompiler, |
| 391 Uri uri, | 399 LibraryUpdater updater, |
| 392 int position) { | 400 int position) { |
| 393 cachedCompiler = newCompiler; | 401 cachedCompiler = newCompiler; |
| 394 | 402 |
| 395 return cachedCompiler.run(uri).then((success) { | 403 Future<bool> compilation = cachedCompiler.run(updater.uri); |
| 404 |
| 405 return compilation.then((success) { |
| 406 if (isVerbose) { |
| 407 for (final task in cachedCompiler.tasks) { |
| 408 int time = task.timingMicroseconds; |
| 409 if (time != 0) { |
| 410 printFormattedTime('${task.name} took', time); |
| 411 } |
| 412 } |
| 413 } |
| 414 |
| 415 if (poiCount != null) poiCount++; |
| 396 if (success != true) { | 416 if (success != true) { |
| 397 throw 'Compilation failed'; | 417 throw 'Compilation failed'; |
| 398 } | 418 } |
| 399 return findPosition(position, cachedCompiler.mainApp); | 419 return findPosition(position, cachedCompiler.mainApp); |
| 400 }); | 420 }); |
| 401 } | 421 } |
| 402 | 422 |
| 403 Element findPosition(int position, Element element) { | 423 Element findPosition(int position, Element element) { |
| 404 FindPositionVisitor visitor = new FindPositionVisitor(position, element); | 424 FindPositionVisitor visitor = new FindPositionVisitor(position, element); |
| 405 element.accept(visitor); | 425 element.accept(visitor); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 buffer.write('\n'); | 726 buffer.write('\n'); |
| 707 indented.write('}'); | 727 indented.write('}'); |
| 708 } | 728 } |
| 709 } | 729 } |
| 710 | 730 |
| 711 modelx.ScopeX localScope(modelx.LibraryElementX element) => element.localScope; | 731 modelx.ScopeX localScope(modelx.LibraryElementX element) => element.localScope; |
| 712 | 732 |
| 713 modelx.ImportScope importScope(modelx.LibraryElementX element) { | 733 modelx.ImportScope importScope(modelx.LibraryElementX element) { |
| 714 return element.importScope; | 734 return element.importScope; |
| 715 } | 735 } |
| OLD | NEW |