| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library trydart.poi; |
| 6 |
| 7 import 'dart:io' show |
| 8 Platform; |
| 9 |
| 10 import 'package:dart2js_incremental/dart2js_incremental.dart' show |
| 11 reuseCompiler; |
| 12 |
| 13 import 'package:compiler/implementation/source_file_provider.dart' show |
| 14 FormattingDiagnosticHandler, |
| 15 SourceFileProvider; |
| 16 |
| 17 import 'package:compiler/compiler.dart' as api show |
| 18 Diagnostic; |
| 19 |
| 20 void main(List<String> arguments) { |
| 21 Uri script = Uri.base.resolve(arguments.first); |
| 22 int position = int.parse(arguments[1]); |
| 23 FormattingDiagnosticHandler handler = new FormattingDiagnosticHandler(); |
| 24 handler |
| 25 ..verbose = true |
| 26 ..enableColors = true; |
| 27 |
| 28 Uri libraryRoot = Uri.base.resolve('sdk/'); |
| 29 Uri packageRoot = Uri.base.resolveUri( |
| 30 new Uri.file('${Platform.packageRoot}/')); |
| 31 |
| 32 var options = [ |
| 33 '--analyze-main', |
| 34 '--analyze-only', |
| 35 '--no-source-maps', |
| 36 '--verbose', |
| 37 '--categories=Client,Server', |
| 38 ]; |
| 39 |
| 40 var cachedCompiler = null; |
| 41 cachedCompiler = reuseCompiler( |
| 42 diagnosticHandler: handler, |
| 43 inputProvider: handler.provider, |
| 44 options: options, |
| 45 cachedCompiler: cachedCompiler, |
| 46 libraryRoot: libraryRoot, |
| 47 packageRoot: packageRoot, |
| 48 packagesAreImmutable: true); |
| 49 |
| 50 cachedCompiler.run(script).then((success) { |
| 51 if (success != true) { |
| 52 throw 'Compilation failed'; |
| 53 } |
| 54 handler( |
| 55 script, position, position + 1, |
| 56 'Point of interest.', api.Diagnostic.HINT); |
| 57 }); |
| 58 } |
| OLD | NEW |