| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library analyze_api; |
| 6 |
| 7 import 'dart:uri'; |
| 8 import 'dart:io'; |
| 9 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api; |
| 10 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart'; |
| 11 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' |
| 12 hide Compiler; |
| 13 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; |
| 14 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart'; |
| 15 import '../../../sdk/lib/_internal/libraries.dart'; |
| 16 |
| 17 class CollectingDiagnosticHandler extends FormattingDiagnosticHandler { |
| 18 bool hasWarnings = false; |
| 19 bool hasErrors = false; |
| 20 |
| 21 CollectingDiagnosticHandler(SourceFileProvider provider) : super(provider); |
| 22 |
| 23 void diagnosticHandler(Uri uri, int begin, int end, String message, |
| 24 api.Diagnostic kind) { |
| 25 if (kind == api.Diagnostic.WARNING) { |
| 26 hasWarnings = true; |
| 27 } |
| 28 if (kind == api.Diagnostic.ERROR) { |
| 29 hasErrors = true; |
| 30 } |
| 31 super.diagnosticHandler(uri, begin, end, message, kind); |
| 32 } |
| 33 } |
| 34 |
| 35 void main() { |
| 36 Uri currentWorkingDirectory = getCurrentDirectory(); |
| 37 var libraryRoot = currentWorkingDirectory.resolve('sdk/'); |
| 38 var uriList = new List<Uri>(); |
| 39 LIBRARIES.forEach((String name, LibraryInfo info) { |
| 40 if (info.documented) { |
| 41 uriList.add(new Uri.fromComponents(scheme: 'dart', path: name)); |
| 42 } |
| 43 }); |
| 44 var provider = new SourceFileProvider(); |
| 45 var handler = new CollectingDiagnosticHandler(provider); |
| 46 var compiler = new Compiler( |
| 47 provider.readStringFromUri, |
| 48 handler.diagnosticHandler, |
| 49 libraryRoot, libraryRoot, |
| 50 <String>['--analyze-only']); |
| 51 compiler.librariesToAnalyzeWhenRun = uriList; |
| 52 compiler.run(null); |
| 53 Expect.isFalse(handler.hasWarnings); |
| 54 Expect.isFalse(handler.hasErrors); |
| 55 } |
| OLD | NEW |