OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 analyze_helper; | 5 library analyze_helper; |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:async'; |
8 import 'dart:io'; | 9 import 'dart:io'; |
9 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api; | 10 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/apiimpl.dart'; |
11 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' | 12 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' |
12 hide Compiler; | 13 hide Compiler; |
13 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; | 14 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; |
14 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart'; | 15 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart'; |
15 | 16 |
16 /** | 17 /** |
17 * Map of white-listed warnings and errors. | 18 * Map of white-listed warnings and errors. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 if (checkWhiteList(uri, message)) { | 107 if (checkWhiteList(uri, message)) { |
107 // Suppress white listed warnings. | 108 // Suppress white listed warnings. |
108 return; | 109 return; |
109 } | 110 } |
110 hasErrors = true; | 111 hasErrors = true; |
111 } | 112 } |
112 super.diagnosticHandler(uri, begin, end, message, kind); | 113 super.diagnosticHandler(uri, begin, end, message, kind); |
113 } | 114 } |
114 } | 115 } |
115 | 116 |
116 void analyze(List<Uri> uriList, Map<String, List<String>> whiteList) { | 117 Future analyze(List<Uri> uriList, Map<String, List<String>> whiteList) { |
117 var libraryRoot = currentDirectory.resolve('sdk/'); | 118 var libraryRoot = currentDirectory.resolve('sdk/'); |
118 var provider = new SourceFileProvider(); | 119 var provider = new SourceFileProvider(); |
119 var handler = new CollectingDiagnosticHandler(whiteList, provider); | 120 var handler = new CollectingDiagnosticHandler(whiteList, provider); |
120 var compiler = new Compiler( | 121 var compiler = new Compiler( |
121 provider.readStringFromUri, | 122 provider.readStringFromUri, |
122 null, | 123 null, |
123 handler.diagnosticHandler, | 124 handler.diagnosticHandler, |
124 libraryRoot, libraryRoot, | 125 libraryRoot, libraryRoot, |
125 <String>['--analyze-only', '--analyze-all', | 126 <String>['--analyze-only', '--analyze-all', |
126 '--categories=Client,Server']); | 127 '--categories=Client,Server']); |
127 compiler.librariesToAnalyzeWhenRun = uriList; | 128 compiler.librariesToAnalyzeWhenRun = uriList; |
128 compiler.run(null); | 129 return compiler.run(null).then((_) { |
129 handler.checkResults(); | 130 handler.checkResults(); |
| 131 }); |
130 } | 132 } |
OLD | NEW |