| 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.analyzer_impl; | 5 library analyzer_cli.src.analyzer_impl; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } | 252 } |
| 253 | 253 |
| 254 /// Compute the severity of the error; however: | 254 /// Compute the severity of the error; however: |
| 255 /// * if [options.enableTypeChecks] is false, then de-escalate checked-mode | 255 /// * if [options.enableTypeChecks] is false, then de-escalate checked-mode |
| 256 /// compile time errors to a severity of [ErrorSeverity.INFO]. | 256 /// compile time errors to a severity of [ErrorSeverity.INFO]. |
| 257 /// * if [options.hintsAreFatal] is true, escalate hints to errors. | 257 /// * if [options.hintsAreFatal] is true, escalate hints to errors. |
| 258 /// * if [options.lintsAreFatal] is true, escalate lints to errors. | 258 /// * if [options.lintsAreFatal] is true, escalate lints to errors. |
| 259 static ErrorSeverity computeSeverity( | 259 static ErrorSeverity computeSeverity( |
| 260 AnalysisError error, CommandLineOptions options, | 260 AnalysisError error, CommandLineOptions options, |
| 261 [AnalysisContext context]) { | 261 [AnalysisContext context]) { |
| 262 bool isStrongMode = false; | |
| 263 if (context != null) { | 262 if (context != null) { |
| 264 ErrorProcessor processor = ErrorProcessor.getProcessor(context, error); | 263 ErrorProcessor processor = ErrorProcessor.getProcessor(context, error); |
| 265 // If there is a processor for this error, defer to it. | 264 // If there is a processor for this error, defer to it. |
| 266 if (processor != null) { | 265 if (processor != null) { |
| 267 return processor.severity; | 266 return processor.severity; |
| 268 } | 267 } |
| 269 isStrongMode = context.analysisOptions.strongMode; | |
| 270 } | 268 } |
| 271 | 269 |
| 272 if (!options.enableTypeChecks && | 270 if (!options.enableTypeChecks && |
| 273 error.errorCode.type == ErrorType.CHECKED_MODE_COMPILE_TIME_ERROR) { | 271 error.errorCode.type == ErrorType.CHECKED_MODE_COMPILE_TIME_ERROR) { |
| 274 return ErrorSeverity.INFO; | 272 return ErrorSeverity.INFO; |
| 275 } else if (options.hintsAreFatal && error.errorCode is HintCode) { | 273 } else if (options.hintsAreFatal && error.errorCode is HintCode) { |
| 276 return ErrorSeverity.ERROR; | 274 return ErrorSeverity.ERROR; |
| 277 } else if (options.lintsAreFatal && error.errorCode is LintCode) { | 275 } else if (options.lintsAreFatal && error.errorCode is LintCode) { |
| 278 return ErrorSeverity.ERROR; | 276 return ErrorSeverity.ERROR; |
| 279 } else if (isStrongMode && | |
| 280 error is StaticWarningCode && | |
| 281 (error as StaticWarningCode).isStrongModeError) { | |
| 282 return ErrorSeverity.ERROR; | |
| 283 } | 277 } |
| 284 return error.errorCode.errorSeverity; | 278 return error.errorCode.errorSeverity; |
| 285 } | 279 } |
| 286 | 280 |
| 287 /// Return the corresponding package directory or `null` if none is found. | 281 /// Return the corresponding package directory or `null` if none is found. |
| 288 static JavaFile getPackageDirectoryFor(JavaFile sourceFile) { | 282 static JavaFile getPackageDirectoryFor(JavaFile sourceFile) { |
| 289 // We are going to ask parent file, so get absolute path. | 283 // We are going to ask parent file, so get absolute path. |
| 290 sourceFile = sourceFile.getAbsoluteFile(); | 284 sourceFile = sourceFile.getAbsoluteFile(); |
| 291 // Look in the containing directories. | 285 // Look in the containing directories. |
| 292 JavaFile dir = sourceFile.getParentFile(); | 286 JavaFile dir = sourceFile.getParentFile(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } | 357 } |
| 364 | 358 |
| 365 @override | 359 @override |
| 366 void logInformation(String message, [CaughtException exception]) { | 360 void logInformation(String message, [CaughtException exception]) { |
| 367 outSink.writeln(message); | 361 outSink.writeln(message); |
| 368 if (exception != null) { | 362 if (exception != null) { |
| 369 outSink.writeln(exception); | 363 outSink.writeln(exception); |
| 370 } | 364 } |
| 371 } | 365 } |
| 372 } | 366 } |
| OLD | NEW |