| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 247 } |
| 248 | 248 |
| 249 /// Compute the severity of the error; however: | 249 /// Compute the severity of the error; however: |
| 250 /// * if [options.enableTypeChecks] is false, then de-escalate checked-mode | 250 /// * if [options.enableTypeChecks] is false, then de-escalate checked-mode |
| 251 /// compile time errors to a severity of [ErrorSeverity.INFO]. | 251 /// compile time errors to a severity of [ErrorSeverity.INFO]. |
| 252 /// * if [options.hintsAreFatal] is true, escalate hints to errors. | 252 /// * if [options.hintsAreFatal] is true, escalate hints to errors. |
| 253 /// * if [options.lintsAreFatal] is true, escalate lints to errors. | 253 /// * if [options.lintsAreFatal] is true, escalate lints to errors. |
| 254 static ErrorSeverity computeSeverity( | 254 static ErrorSeverity computeSeverity( |
| 255 AnalysisError error, CommandLineOptions options, | 255 AnalysisError error, CommandLineOptions options, |
| 256 [AnalysisContext context]) { | 256 [AnalysisContext context]) { |
| 257 bool isStrongMode = false; |
| 257 if (context != null) { | 258 if (context != null) { |
| 258 ErrorProcessor processor = ErrorProcessor.getProcessor(context, error); | 259 ErrorProcessor processor = ErrorProcessor.getProcessor(context, error); |
| 259 // If there is a processor for this error, defer to it. | 260 // If there is a processor for this error, defer to it. |
| 260 if (processor != null) { | 261 if (processor != null) { |
| 261 return processor.severity; | 262 return processor.severity; |
| 262 } | 263 } |
| 264 isStrongMode = context.analysisOptions.strongMode; |
| 263 } | 265 } |
| 264 | 266 |
| 265 if (!options.enableTypeChecks && | 267 if (!options.enableTypeChecks && |
| 266 error.errorCode.type == ErrorType.CHECKED_MODE_COMPILE_TIME_ERROR) { | 268 error.errorCode.type == ErrorType.CHECKED_MODE_COMPILE_TIME_ERROR) { |
| 267 return ErrorSeverity.INFO; | 269 return ErrorSeverity.INFO; |
| 268 } | 270 } else if (options.hintsAreFatal && error.errorCode is HintCode) { |
| 269 | 271 return ErrorSeverity.ERROR; |
| 270 if (options.hintsAreFatal && error.errorCode is HintCode) { | 272 } else if (options.lintsAreFatal && error.errorCode is LintCode) { |
| 273 return ErrorSeverity.ERROR; |
| 274 } else if (isStrongMode && |
| 275 error is StaticWarningCode && |
| 276 (error as StaticWarningCode).isStrongModeError) { |
| 271 return ErrorSeverity.ERROR; | 277 return ErrorSeverity.ERROR; |
| 272 } | 278 } |
| 273 | |
| 274 if (options.lintsAreFatal && error.errorCode is LintCode) { | |
| 275 return ErrorSeverity.ERROR; | |
| 276 } | |
| 277 | |
| 278 return error.errorCode.errorSeverity; | 279 return error.errorCode.errorSeverity; |
| 279 } | 280 } |
| 280 | 281 |
| 281 /// Return the corresponding package directory or `null` if none is found. | 282 /// Return the corresponding package directory or `null` if none is found. |
| 282 static JavaFile getPackageDirectoryFor(JavaFile sourceFile) { | 283 static JavaFile getPackageDirectoryFor(JavaFile sourceFile) { |
| 283 // We are going to ask parent file, so get absolute path. | 284 // We are going to ask parent file, so get absolute path. |
| 284 sourceFile = sourceFile.getAbsoluteFile(); | 285 sourceFile = sourceFile.getAbsoluteFile(); |
| 285 // Look in the containing directories. | 286 // Look in the containing directories. |
| 286 JavaFile dir = sourceFile.getParentFile(); | 287 JavaFile dir = sourceFile.getParentFile(); |
| 287 while (dir != null) { | 288 while (dir != null) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 342 } |
| 342 | 343 |
| 343 @override | 344 @override |
| 344 void logInformation(String message, [CaughtException exception]) { | 345 void logInformation(String message, [CaughtException exception]) { |
| 345 outSink.writeln(message); | 346 outSink.writeln(message); |
| 346 if (exception != null) { | 347 if (exception != null) { |
| 347 outSink.writeln(exception); | 348 outSink.writeln(exception); |
| 348 } | 349 } |
| 349 } | 350 } |
| 350 } | 351 } |
| OLD | NEW |