OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analyzer_cli.src.build_mode; | 5 library analyzer_cli.src.build_mode; |
6 | 6 |
7 import 'dart:core'; | 7 import 'dart:core'; |
8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart' show CompilationUnit; | 10 import 'package:analyzer/dart/ast/ast.dart' show CompilationUnit; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 return _computeMaxSeverity(); | 236 return _computeMaxSeverity(); |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 ErrorSeverity _computeMaxSeverity() { | 240 ErrorSeverity _computeMaxSeverity() { |
241 ErrorSeverity maxSeverity = ErrorSeverity.NONE; | 241 ErrorSeverity maxSeverity = ErrorSeverity.NONE; |
242 if (!options.buildSuppressExitCode) { | 242 if (!options.buildSuppressExitCode) { |
243 for (Source source in explicitSources) { | 243 for (Source source in explicitSources) { |
244 AnalysisErrorInfo errorInfo = context.getErrors(source); | 244 AnalysisErrorInfo errorInfo = context.getErrors(source); |
245 for (AnalysisError error in errorInfo.errors) { | 245 for (AnalysisError error in errorInfo.errors) { |
246 ProcessedSeverity processedSeverity = | 246 ProcessedSeverity processedSeverity = determineProcessedSeverity( |
247 processError(error, options, context.analysisOptions); | 247 error, options, context.analysisOptions); |
248 if (processedSeverity != null) { | 248 if (processedSeverity != null) { |
249 maxSeverity = maxSeverity.max(processedSeverity.severity); | 249 maxSeverity = maxSeverity.max(processedSeverity.severity); |
250 } | 250 } |
251 } | 251 } |
252 } | 252 } |
253 } | 253 } |
254 return maxSeverity; | 254 return maxSeverity; |
255 } | 255 } |
256 | 256 |
257 void _createContext() { | 257 void _createContext() { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 } | 325 } |
326 return uriToFileMap; | 326 return uriToFileMap; |
327 } | 327 } |
328 | 328 |
329 /** | 329 /** |
330 * Print errors for all explicit sources. If [outputPath] is supplied, output | 330 * Print errors for all explicit sources. If [outputPath] is supplied, output |
331 * is sent to a new file at that path. | 331 * is sent to a new file at that path. |
332 */ | 332 */ |
333 void _printErrors({String outputPath}) { | 333 void _printErrors({String outputPath}) { |
334 StringBuffer buffer = new StringBuffer(); | 334 StringBuffer buffer = new StringBuffer(); |
335 ErrorFormatter formatter = new ErrorFormatter( | 335 ErrorFormatter formatter = new HumanErrorFormatter(buffer, options, stats, |
336 buffer, | 336 severityProcessor: (AnalysisError error) => determineProcessedSeverity( |
337 options, | 337 error, options, context.analysisOptions)); |
338 stats, | |
339 (AnalysisError error) => | |
340 processError(error, options, context.analysisOptions)); | |
341 for (Source source in explicitSources) { | 338 for (Source source in explicitSources) { |
342 AnalysisErrorInfo errorInfo = context.getErrors(source); | 339 AnalysisErrorInfo errorInfo = context.getErrors(source); |
343 formatter.formatErrors([errorInfo]); | 340 formatter.formatErrors([errorInfo]); |
344 } | 341 } |
| 342 formatter.flush(); |
345 if (!options.machineFormat) { | 343 if (!options.machineFormat) { |
346 stats.print(buffer); | 344 stats.print(buffer); |
347 } | 345 } |
348 if (outputPath == null) { | 346 if (outputPath == null) { |
349 StringSink sink = options.machineFormat ? errorSink : outSink; | 347 StringSink sink = options.machineFormat ? errorSink : outSink; |
350 sink.write(buffer); | 348 sink.write(buffer); |
351 } else { | 349 } else { |
352 new io.File(outputPath).writeAsStringSync(buffer.toString()); | 350 new io.File(outputPath).writeAsStringSync(buffer.toString()); |
353 } | 351 } |
354 } | 352 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 * Build the inverse mapping of [uriToSourceMap]. | 439 * Build the inverse mapping of [uriToSourceMap]. |
442 */ | 440 */ |
443 static Map<String, Uri> _computePathToUriMap(Map<Uri, File> uriToSourceMap) { | 441 static Map<String, Uri> _computePathToUriMap(Map<Uri, File> uriToSourceMap) { |
444 Map<String, Uri> pathToUriMap = <String, Uri>{}; | 442 Map<String, Uri> pathToUriMap = <String, Uri>{}; |
445 uriToSourceMap.forEach((Uri uri, File file) { | 443 uriToSourceMap.forEach((Uri uri, File file) { |
446 pathToUriMap[file.path] = uri; | 444 pathToUriMap[file.path] = uri; |
447 }); | 445 }); |
448 return pathToUriMap; | 446 return pathToUriMap; |
449 } | 447 } |
450 } | 448 } |
OLD | NEW |