| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart2js.source_mirrors.analyze; | 5 library dart2js.source_mirrors.analyze; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'source_mirrors.dart'; | 9 import 'source_mirrors.dart'; |
| 10 import 'dart2js_mirrors.dart' show Dart2JsMirrorSystem; | 10 import 'dart2js_mirrors.dart' show Dart2JsMirrorSystem; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 throw new ArgumentError("libraryRoot must end with a /"); | 31 throw new ArgumentError("libraryRoot must end with a /"); |
| 32 } | 32 } |
| 33 if (packageRoot != null && !packageRoot.path.endsWith("/")) { | 33 if (packageRoot != null && !packageRoot.path.endsWith("/")) { |
| 34 throw new ArgumentError("packageRoot must end with a /"); | 34 throw new ArgumentError("packageRoot must end with a /"); |
| 35 } | 35 } |
| 36 options = new List<String>.from(options); | 36 options = new List<String>.from(options); |
| 37 options.add('--analyze-only'); | 37 options.add('--analyze-only'); |
| 38 options.add('--analyze-signatures-only'); | 38 options.add('--analyze-signatures-only'); |
| 39 options.add('--analyze-all'); | 39 options.add('--analyze-all'); |
| 40 options.add('--categories=Client,Server'); | 40 options.add('--categories=Client,Server'); |
| 41 options.add('--enable-async'); |
| 41 | 42 |
| 42 bool compilationFailed = false; | 43 bool compilationFailed = false; |
| 43 void internalDiagnosticHandler(Uri uri, int begin, int end, | 44 void internalDiagnosticHandler(Uri uri, int begin, int end, |
| 44 String message, api.Diagnostic kind) { | 45 String message, api.Diagnostic kind) { |
| 45 if (kind == api.Diagnostic.ERROR || | 46 if (kind == api.Diagnostic.ERROR || |
| 46 kind == api.Diagnostic.CRASH) { | 47 kind == api.Diagnostic.CRASH) { |
| 47 compilationFailed = true; | 48 compilationFailed = true; |
| 48 } | 49 } |
| 49 diagnosticHandler(uri, begin, end, message, kind); | 50 diagnosticHandler(uri, begin, end, message, kind); |
| 50 } | 51 } |
| 51 | 52 |
| 52 Compiler compiler = new apiimpl.Compiler(inputProvider, | 53 Compiler compiler = new apiimpl.Compiler(inputProvider, |
| 53 null, | 54 null, |
| 54 internalDiagnosticHandler, | 55 internalDiagnosticHandler, |
| 55 libraryRoot, packageRoot, | 56 libraryRoot, packageRoot, |
| 56 options, | 57 options, |
| 57 const {}); | 58 const {}); |
| 58 compiler.librariesToAnalyzeWhenRun = libraries; | 59 compiler.librariesToAnalyzeWhenRun = libraries; |
| 59 return compiler.run(null).then((bool success) { | 60 return compiler.run(null).then((bool success) { |
| 60 if (success && !compilationFailed) { | 61 if (success && !compilationFailed) { |
| 61 return new Dart2JsMirrorSystem(compiler); | 62 return new Dart2JsMirrorSystem(compiler); |
| 62 } else { | 63 } else { |
| 63 throw new StateError('Failed to create mirror system.'); | 64 throw new StateError('Failed to create mirror system.'); |
| 64 } | 65 } |
| 65 }); | 66 }); |
| 66 } | 67 } |
| OLD | NEW |