| 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 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'package:compiler/compiler.dart' as api; | 9 import 'package:compiler/compiler.dart' as api; |
| 10 import 'package:compiler/src/apiimpl.dart'; | 10 import 'package:compiler/src/apiimpl.dart'; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 hasErrors = true; | 124 hasErrors = true; |
| 125 } | 125 } |
| 126 if (kind == api.Diagnostic.INFO && lastWasWhitelisted) { | 126 if (kind == api.Diagnostic.INFO && lastWasWhitelisted) { |
| 127 return; | 127 return; |
| 128 } | 128 } |
| 129 lastWasWhitelisted = false; | 129 lastWasWhitelisted = false; |
| 130 super.report(message, uri, begin, end, text, kind); | 130 super.report(message, uri, begin, end, text, kind); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 typedef bool CheckResults(Compiler compiler, | 134 typedef bool CheckResults(CompilerImpl compiler, |
| 135 CollectingDiagnosticHandler handler); | 135 CollectingDiagnosticHandler handler); |
| 136 | 136 |
| 137 Future analyze(List<Uri> uriList, | 137 Future analyze(List<Uri> uriList, |
| 138 Map<String, List<String>> whiteList, | 138 Map<String, List<String>> whiteList, |
| 139 {bool analyzeAll: true, | 139 {bool analyzeAll: true, |
| 140 bool analyzeMain: false, | 140 bool analyzeMain: false, |
| 141 CheckResults checkResults}) { | 141 CheckResults checkResults}) { |
| 142 String testFileName = | 142 String testFileName = |
| 143 relativize(Uri.base, Platform.script, Platform.isWindows); | 143 relativize(Uri.base, Platform.script, Platform.isWindows); |
| 144 | 144 |
| 145 print(""" | 145 print(""" |
| 146 | 146 |
| 147 | 147 |
| 148 === | 148 === |
| 149 === NOTE: If this test fails, update [WHITE_LIST] in $testFileName | 149 === NOTE: If this test fails, update [WHITE_LIST] in $testFileName |
| 150 === | 150 === |
| 151 | 151 |
| 152 | 152 |
| 153 """); | 153 """); |
| 154 | 154 |
| 155 var libraryRoot = currentDirectory.resolve('sdk/'); | 155 var libraryRoot = currentDirectory.resolve('sdk/'); |
| 156 var packageRoot = | 156 var packageRoot = |
| 157 currentDirectory.resolveUri(new Uri.file('${Platform.packageRoot}/')); | 157 currentDirectory.resolveUri(new Uri.file('${Platform.packageRoot}/')); |
| 158 var provider = new CompilerSourceFileProvider(); | 158 var provider = new CompilerSourceFileProvider(); |
| 159 var handler = new CollectingDiagnosticHandler(whiteList, provider); | 159 var handler = new CollectingDiagnosticHandler(whiteList, provider); |
| 160 var options = <String>[Flags.analyzeOnly, '--categories=Client,Server', | 160 var options = <String>[Flags.analyzeOnly, '--categories=Client,Server', |
| 161 Flags.showPackageWarnings]; | 161 Flags.showPackageWarnings]; |
| 162 if (analyzeAll) options.add(Flags.analyzeAll); | 162 if (analyzeAll) options.add(Flags.analyzeAll); |
| 163 if (analyzeMain) options.add(Flags.analyzeMain); | 163 if (analyzeMain) options.add(Flags.analyzeMain); |
| 164 var compiler = new Compiler( | 164 var compiler = new CompilerImpl( |
| 165 provider, | 165 provider, |
| 166 null, | 166 null, |
| 167 handler, | 167 handler, |
| 168 libraryRoot, | 168 libraryRoot, |
| 169 packageRoot, | 169 packageRoot, |
| 170 options, | 170 options, |
| 171 {}); | 171 {}); |
| 172 String MESSAGE = """ | 172 String MESSAGE = """ |
| 173 | 173 |
| 174 | 174 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 191 exit(1); | 191 exit(1); |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 if (analyzeAll || analyzeMain) { | 194 if (analyzeAll || analyzeMain) { |
| 195 compiler.librariesToAnalyzeWhenRun = uriList; | 195 compiler.librariesToAnalyzeWhenRun = uriList; |
| 196 return compiler.run(null).then(onCompletion); | 196 return compiler.run(null).then(onCompletion); |
| 197 } else { | 197 } else { |
| 198 return compiler.run(uriList.single).then(onCompletion); | 198 return compiler.run(uriList.single).then(onCompletion); |
| 199 } | 199 } |
| 200 } | 200 } |
| OLD | NEW |