analyzer: Tidy CodeStyleOptions
Privatize `_options` and then consistently use helper function.
Change-Id: I984396adf8cf59cbfa2b3ed45a0b6011b509560b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389023
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
diff --git a/pkg/analyzer/lib/src/analysis_options/code_style_options.dart b/pkg/analyzer/lib/src/analysis_options/code_style_options.dart
index 1a0f5d8..0b6e4ea 100644
--- a/pkg/analyzer/lib/src/analysis_options/code_style_options.dart
+++ b/pkg/analyzer/lib/src/analysis_options/code_style_options.dart
@@ -9,16 +9,15 @@
/// The concrete implementation of [CodeStyleOptions].
class CodeStyleOptionsImpl implements CodeStyleOptions {
/// The analysis options that owns this instance.
- final AnalysisOptions options;
+ final AnalysisOptions _options;
@override
final bool useFormatter;
- CodeStyleOptionsImpl(this.options, {required this.useFormatter});
+ CodeStyleOptionsImpl(this._options, {required this.useFormatter});
@override
- bool get addTrailingCommas =>
- options.isLintEnabled('require_trailing_commas');
+ bool get addTrailingCommas => _isLintEnabled('require_trailing_commas');
@override
bool get makeLocalsFinal => _isLintEnabled('prefer_final_locals');
@@ -36,8 +35,7 @@
bool get specifyTypes => _isLintEnabled('always_specify_types');
@override
- bool get usePackageUris =>
- options.isLintEnabled('always_use_package_imports');
+ bool get usePackageUris => _isLintEnabled('always_use_package_imports');
@override
bool get useRelativeUris => _isLintEnabled('prefer_relative_imports');
@@ -75,13 +73,13 @@
return doubleCount > singleCount ? '"' : "'";
}
- /// Return `true` if the lint with the given [name] is enabled.
- bool _isLintEnabled(String name) => options.isLintEnabled(name);
+ /// Returns whether the lint rule with the given [name] is enabled.
+ bool _isLintEnabled(String name) => _options.isLintEnabled(name);
- /// Return the preferred lint quote, otherwise `null`.
- String? _lintQuote() => _isLintEnabled("prefer_single_quotes")
+ /// Returns the preferred lint quote, otherwise `null`.
+ String? _lintQuote() => _isLintEnabled('prefer_single_quotes')
? "'"
- : _isLintEnabled("prefer_double_quotes")
+ : _isLintEnabled('prefer_double_quotes')
? '"'
: null;
}