Skip to content

Commit 91cce5d

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer: Simplify AnalysisOptionsImpl
There were three private fields that were unnecessarily backed by public getters and and setters. https://dart.dev/effective-dart/usage#dont-wrap-a-field-in-a-getter-and-setter-unnecessarily If the three fields are intended to be writable, they can just be made public. Change-Id: I3add352e3433b4e9707a0c056c659fbffdaa7cfc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389040 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 45017c1 commit 91cce5d

File tree

1 file changed

+11
-42
lines changed

1 file changed

+11
-42
lines changed

pkg/analyzer/lib/src/generated/engine.dart

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ typedef AnalyzeFunctionBodiesPredicate = bool Function(Source source);
4242
/// An analysis context also represents the state of the analysis, which includes
4343
/// knowing which sources have been included in the analysis (either directly or
4444
/// indirectly) and the results of the analysis. Sources must be added and
45-
/// removed from the context using the method [applyChanges], which is also used
46-
/// to notify the context when sources have been modified and, consequently,
47-
/// previously known results might have been invalidated.
45+
/// removed from the context, which is also used to notify the context when
46+
/// sources have been modified and, consequently, previously known results might
47+
/// have been invalidated.
4848
///
4949
/// There are two ways to access the results of the analysis. The most common is
5050
/// to use one of the 'get' methods to access the results. The 'get' methods have
@@ -63,8 +63,7 @@ typedef AnalyzeFunctionBodiesPredicate = bool Function(Source source);
6363
/// However, this is not always acceptable. Some clients need to keep the
6464
/// analysis results up-to-date. For such clients there is a mechanism that
6565
/// allows them to incrementally perform needed analysis and get notified of the
66-
/// consequent changes to the analysis results. This mechanism is realized by the
67-
/// method [performAnalysisTask].
66+
/// consequent changes to the analysis results.
6867
///
6968
/// Analysis engine allows for having more than one context. This can be used,
7069
/// for example, to perform one analysis based on the state of files on disk and
@@ -196,12 +195,11 @@ class AnalysisOptionsImpl implements AnalysisOptions {
196195
/// Return `true` if timing data should be gathered during execution.
197196
bool enableTiming = false;
198197

199-
/// A list of error processors that are to be used when reporting errors in
200-
/// some analysis context.
201-
List<ErrorProcessor>? _errorProcessors;
198+
@override
199+
List<ErrorProcessor> errorProcessors = [];
202200

203-
/// A list of exclude patterns used to exclude some sources from analysis.
204-
List<String>? _excludePatterns;
201+
@override
202+
List<String> excludePatterns = [];
205203

206204
/// The associated `analysis_options.yaml` file (or `null` if there is none).
207205
File? file;
@@ -212,12 +210,11 @@ class AnalysisOptionsImpl implements AnalysisOptions {
212210
@override
213211
bool warning = true;
214212

215-
/// The lint rules that are to be run in an analysis context if [lint] returns
216-
/// `true`.
217-
List<LintRule>? _lintRules;
213+
@override
214+
List<LintRule> lintRules = [];
218215

219216
/// Indicates whether linter exceptions should be propagated to the caller (by
220-
/// re-throwing them)
217+
/// re-throwing them).
221218
bool propagateLinterExceptions = false;
222219

223220
/// Whether implicit casts should be reported as potential problems.
@@ -290,25 +287,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
290287
@Deprecated("Use 'enabledLegacyPluginNames' instead")
291288
List<String> get enabledPluginNames => enabledLegacyPluginNames;
292289

293-
@override
294-
List<ErrorProcessor> get errorProcessors =>
295-
_errorProcessors ??= const <ErrorProcessor>[];
296-
297-
/// Set the list of error [processors] that are to be used when reporting
298-
/// errors in some analysis context.
299-
set errorProcessors(List<ErrorProcessor> processors) {
300-
_errorProcessors = processors;
301-
}
302-
303-
@override
304-
List<String> get excludePatterns => _excludePatterns ??= const <String>[];
305-
306-
/// Set the exclude patterns used to exclude some sources from analysis to
307-
/// those in the given list of [patterns].
308-
set excludePatterns(List<String> patterns) {
309-
_excludePatterns = patterns;
310-
}
311-
312290
/// The set of enabled experiments.
313291
ExperimentStatus get experimentStatus => _contextFeatures;
314292

@@ -319,15 +297,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
319297
@Deprecated("Use 'warning=' instead")
320298
set hint(bool value) => warning = value;
321299

322-
@override
323-
List<LintRule> get lintRules => _lintRules ??= const [];
324-
325-
/// Set the lint rules that are to be run in an analysis context if [lint]
326-
/// returns `true`.
327-
set lintRules(List<LintRule> rules) {
328-
_lintRules = rules;
329-
}
330-
331300
Uint32List get signature {
332301
if (_signature == null) {
333302
ApiSignature buffer = ApiSignature();

0 commit comments

Comments
 (0)