| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 return _computeMaxSeverity(); | 222 return _computeMaxSeverity(); |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 | 225 |
| 226 ErrorSeverity _computeMaxSeverity() { | 226 ErrorSeverity _computeMaxSeverity() { |
| 227 ErrorSeverity maxSeverity = ErrorSeverity.NONE; | 227 ErrorSeverity maxSeverity = ErrorSeverity.NONE; |
| 228 if (!options.buildSuppressExitCode) { | 228 if (!options.buildSuppressExitCode) { |
| 229 for (Source source in explicitSources) { | 229 for (Source source in explicitSources) { |
| 230 AnalysisErrorInfo errorInfo = context.getErrors(source); | 230 AnalysisErrorInfo errorInfo = context.getErrors(source); |
| 231 for (AnalysisError error in errorInfo.errors) { | 231 for (AnalysisError error in errorInfo.errors) { |
| 232 ProcessedSeverity processedSeverity = | 232 ProcessedSeverity processedSeverity = determineProcessedSeverity( |
| 233 processError(error, options, context.analysisOptions); | 233 error, options, context.analysisOptions); |
| 234 if (processedSeverity != null) { | 234 if (processedSeverity != null) { |
| 235 maxSeverity = maxSeverity.max(processedSeverity.severity); | 235 maxSeverity = maxSeverity.max(processedSeverity.severity); |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 return maxSeverity; | 240 return maxSeverity; |
| 241 } | 241 } |
| 242 | 242 |
| 243 void _createContext() { | 243 void _createContext() { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 311 } |
| 312 return uriToFileMap; | 312 return uriToFileMap; |
| 313 } | 313 } |
| 314 | 314 |
| 315 /** | 315 /** |
| 316 * Print errors for all explicit sources. If [outputPath] is supplied, output | 316 * Print errors for all explicit sources. If [outputPath] is supplied, output |
| 317 * is sent to a new file at that path. | 317 * is sent to a new file at that path. |
| 318 */ | 318 */ |
| 319 void _printErrors({String outputPath}) { | 319 void _printErrors({String outputPath}) { |
| 320 StringBuffer buffer = new StringBuffer(); | 320 StringBuffer buffer = new StringBuffer(); |
| 321 ErrorFormatter formatter = new ErrorFormatter( | 321 ErrorFormatter formatter = new HumanErrorFormatter(buffer, options, stats, |
| 322 buffer, | 322 severityProcessor: (AnalysisError error) => determineProcessedSeverity( |
| 323 options, | 323 error, options, context.analysisOptions)); |
| 324 stats, | |
| 325 (AnalysisError error) => | |
| 326 processError(error, options, context.analysisOptions)); | |
| 327 for (Source source in explicitSources) { | 324 for (Source source in explicitSources) { |
| 328 AnalysisErrorInfo errorInfo = context.getErrors(source); | 325 AnalysisErrorInfo errorInfo = context.getErrors(source); |
| 329 formatter.formatErrors([errorInfo]); | 326 formatter.formatErrors([errorInfo]); |
| 330 } | 327 } |
| 328 formatter.flush(); |
| 331 if (!options.machineFormat) { | 329 if (!options.machineFormat) { |
| 332 stats.print(buffer); | 330 stats.print(buffer); |
| 333 } | 331 } |
| 334 if (outputPath == null) { | 332 if (outputPath == null) { |
| 335 StringSink sink = options.machineFormat ? errorSink : outSink; | 333 StringSink sink = options.machineFormat ? errorSink : outSink; |
| 336 sink.write(buffer); | 334 sink.write(buffer); |
| 337 } else { | 335 } else { |
| 338 new io.File(outputPath).writeAsStringSync(buffer.toString()); | 336 new io.File(outputPath).writeAsStringSync(buffer.toString()); |
| 339 } | 337 } |
| 340 } | 338 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 * Build the inverse mapping of [uriToSourceMap]. | 418 * Build the inverse mapping of [uriToSourceMap]. |
| 421 */ | 419 */ |
| 422 static Map<String, Uri> _computePathToUriMap(Map<Uri, File> uriToSourceMap) { | 420 static Map<String, Uri> _computePathToUriMap(Map<Uri, File> uriToSourceMap) { |
| 423 Map<String, Uri> pathToUriMap = <String, Uri>{}; | 421 Map<String, Uri> pathToUriMap = <String, Uri>{}; |
| 424 uriToSourceMap.forEach((Uri uri, File file) { | 422 uriToSourceMap.forEach((Uri uri, File file) { |
| 425 pathToUriMap[file.path] = uri; | 423 pathToUriMap[file.path] = uri; |
| 426 }); | 424 }); |
| 427 return pathToUriMap; | 425 return pathToUriMap; |
| 428 } | 426 } |
| 429 } | 427 } |
| OLD | NEW |