Tweaks for LinterExceptionHandler.
Boolean parameters are easier to understand when they are named. And the word "linter" does not add much, we already know this. Change-Id: Ib34488acd43230ac516b5fe2d3928c96dfbc6a0a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208900 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
7bc076c9e0
commit
a468bd2e22
@@ -352,10 +352,14 @@ class LibraryAnalyzer {
|
||||
}
|
||||
|
||||
// Run lints that handle specific node types.
|
||||
unit.accept(LinterVisitor(
|
||||
unit.accept(
|
||||
LinterVisitor(
|
||||
nodeRegistry,
|
||||
LinterExceptionHandler(_analysisOptions.propagateLinterExceptions)
|
||||
.logException));
|
||||
LinterExceptionHandler(
|
||||
propagateExceptions: _analysisOptions.propagateLinterExceptions,
|
||||
).logException,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _computeVerifyErrors(FileState file, CompilationUnit unit) {
|
||||
|
||||
@@ -1308,9 +1308,11 @@ class DeferredLibraryReferenceDetector extends RecursiveAstVisitor<void> {
|
||||
class LinterExceptionHandler {
|
||||
/// Indicates whether linter exceptions should be propagated to the caller (by
|
||||
/// re-throwing them)
|
||||
final bool propagateLinterExceptions;
|
||||
final bool propagateExceptions;
|
||||
|
||||
LinterExceptionHandler(this.propagateLinterExceptions);
|
||||
LinterExceptionHandler({
|
||||
required this.propagateExceptions,
|
||||
});
|
||||
|
||||
/// A method that can be passed to the `LinterVisitor` constructor to handle
|
||||
/// exceptions that occur during linting.
|
||||
@@ -1332,7 +1334,7 @@ class LinterExceptionHandler {
|
||||
// TODO(39284): should this exception be silent?
|
||||
AnalysisEngine.instance.instrumentationService.logException(
|
||||
SilentException(buffer.toString(), exception, stackTrace));
|
||||
if (propagateLinterExceptions) {
|
||||
if (propagateExceptions) {
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,10 +348,14 @@ class LibraryAnalyzer {
|
||||
}
|
||||
|
||||
// Run lints that handle specific node types.
|
||||
unit.accept(LinterVisitor(
|
||||
unit.accept(
|
||||
LinterVisitor(
|
||||
nodeRegistry,
|
||||
LinterExceptionHandler(_analysisOptions.propagateLinterExceptions)
|
||||
.logException));
|
||||
LinterExceptionHandler(
|
||||
propagateExceptions: _analysisOptions.propagateLinterExceptions,
|
||||
).logException,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _computeVerifyErrors(FileState file, CompilationUnit unit) {
|
||||
|
||||
@@ -18,8 +18,8 @@ class LinterVisitor extends RecursiveAstVisitor<void> {
|
||||
final LintRuleExceptionHandler exceptionHandler;
|
||||
|
||||
LinterVisitor(this.registry, [LintRuleExceptionHandler? exceptionHandler])
|
||||
: exceptionHandler =
|
||||
exceptionHandler ?? LinterExceptionHandler(true).logException;
|
||||
: exceptionHandler = exceptionHandler ??
|
||||
LinterExceptionHandler(propagateExceptions: true).logException;
|
||||
|
||||
@override
|
||||
void visitAdjacentStrings(AdjacentStrings node) {
|
||||
|
||||
Reference in New Issue
Block a user