Skip to content

Commit 843a178

Browse files
srawlinsCommit Queue
authored andcommitted
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 <[email protected]> Reviewed-by: Keerti Parthasarathy <[email protected]>
1 parent 2e46be4 commit 843a178

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

pkg/analyzer/lib/src/analysis_options/code_style_options.dart

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ import 'package:analyzer/dart/ast/ast.dart';
99
/// The concrete implementation of [CodeStyleOptions].
1010
class CodeStyleOptionsImpl implements CodeStyleOptions {
1111
/// The analysis options that owns this instance.
12-
final AnalysisOptions options;
12+
final AnalysisOptions _options;
1313

1414
@override
1515
final bool useFormatter;
1616

17-
CodeStyleOptionsImpl(this.options, {required this.useFormatter});
17+
CodeStyleOptionsImpl(this._options, {required this.useFormatter});
1818

1919
@override
20-
bool get addTrailingCommas =>
21-
options.isLintEnabled('require_trailing_commas');
20+
bool get addTrailingCommas => _isLintEnabled('require_trailing_commas');
2221

2322
@override
2423
bool get makeLocalsFinal => _isLintEnabled('prefer_final_locals');
@@ -36,8 +35,7 @@ class CodeStyleOptionsImpl implements CodeStyleOptions {
3635
bool get specifyTypes => _isLintEnabled('always_specify_types');
3736

3837
@override
39-
bool get usePackageUris =>
40-
options.isLintEnabled('always_use_package_imports');
38+
bool get usePackageUris => _isLintEnabled('always_use_package_imports');
4139

4240
@override
4341
bool get useRelativeUris => _isLintEnabled('prefer_relative_imports');
@@ -75,13 +73,13 @@ class CodeStyleOptionsImpl implements CodeStyleOptions {
7573
return doubleCount > singleCount ? '"' : "'";
7674
}
7775

78-
/// Return `true` if the lint with the given [name] is enabled.
79-
bool _isLintEnabled(String name) => options.isLintEnabled(name);
76+
/// Returns whether the lint rule with the given [name] is enabled.
77+
bool _isLintEnabled(String name) => _options.isLintEnabled(name);
8078

81-
/// Return the preferred lint quote, otherwise `null`.
82-
String? _lintQuote() => _isLintEnabled("prefer_single_quotes")
79+
/// Returns the preferred lint quote, otherwise `null`.
80+
String? _lintQuote() => _isLintEnabled('prefer_single_quotes')
8381
? "'"
84-
: _isLintEnabled("prefer_double_quotes")
82+
: _isLintEnabled('prefer_double_quotes')
8583
? '"'
8684
: null;
8785
}

0 commit comments

Comments
 (0)