Skip to content

Commit

Permalink
[analyzer] Rename AnalysisOptions.hint to AnalysisOptions.warning
Browse files Browse the repository at this point in the history
Bug: #50796
Change-Id: I7050b4f758976ff555e43f219c6f5c2b0e8d362a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290903
Reviewed-by: Brian Wilkerson <[email protected]>
Reviewed-by: Samuel Rawlins <[email protected]>
Commit-Queue: Samuel Rawlins <[email protected]>
  • Loading branch information
srawlins authored and Commit Queue committed Jul 28, 2023
1 parent b477c15 commit b87dee9
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AnalysisUpdateOptionsHandler extends LegacyHandler {
var generateHints = newOptions.generateHints;
if (generateHints != null) {
updaters.add((engine.AnalysisOptionsImpl options) {
options.hint = generateHints;
options.warning = generateHints;
});
}
var generateLints = newOptions.generateLints;
Expand Down
5 changes: 5 additions & 0 deletions pkg/analyzer/lib/dart/analysis/analysis_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ abstract class AnalysisOptions {

/// Return `true` if analysis is to generate hint results (e.g. best practices
/// and analysis based on certain annotations).
@Deprecated("Use 'warning' instead")
bool get hint;

/// Return `true` if analysis is to generate lint warnings.
Expand All @@ -50,6 +51,10 @@ abstract class AnalysisOptions {
/// there is no `pubspec.yaml` or if it does not contain an SDK range.
VersionConstraint? get sdkVersionConstraint;

/// Return `true` if analysis is to generate warning results (e.g. best
/// practices and analysis based on certain annotations).
bool get warning;

/// Return `true` the lint with the given [name] is enabled.
bool isLintEnabled(String name);
}
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class LibraryAnalyzer {
_computeVerifyErrors(file, unit);
});

if (_analysisOptions.hint) {
if (_analysisOptions.warning) {
var usedImportedElements = <UsedImportedElements>[];
var usedLocalElements = <UsedLocalElements>[];
for (var unit in units.values) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/micro/resolve_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ class FileResolver {
}

if (isThirdParty) {
options.hint = false;
options.warning = false;
}

return options;
Expand Down
13 changes: 10 additions & 3 deletions pkg/analyzer/lib/src/generated/engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ class AnalysisOptionsImpl implements AnalysisOptions {
List<String>? _excludePatterns;

@override
bool hint = true;
bool lint = false;

@override
bool lint = false;
bool warning = true;

/// The lint rules that are to be run in an analysis context if [lint] returns
/// `true`.
Expand Down Expand Up @@ -266,8 +266,8 @@ class AnalysisOptionsImpl implements AnalysisOptions {
enabledPluginNames = options.enabledPluginNames;
errorProcessors = options.errorProcessors;
excludePatterns = options.excludePatterns;
hint = options.hint;
lint = options.lint;
warning = options.warning;
lintRules = options.lintRules;
if (options is AnalysisOptionsImpl) {
enableTiming = options.enableTiming;
Expand Down Expand Up @@ -310,6 +310,13 @@ class AnalysisOptionsImpl implements AnalysisOptions {
/// The set of enabled experiments.
ExperimentStatus get experimentStatus => _contextFeatures;

@override
bool get hint => warning;

/// The implementation-specific setter for [hint].
@Deprecated("Use 'warning=' instead")
set hint(bool value) => warning = value;

@override
List<Linter> get lintRules => _lintRules ??= const <Linter>[];

Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/lint/analysis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ void _updateAnalyzerOptions(
analysisOptions.applyOptions(map);
}

analysisOptions.hint = false;
analysisOptions.lint = options.enableLints;
analysisOptions.warning = false;
analysisOptions.enableTiming = options.enableTiming;
analysisOptions.lintRules = options.enabledLints.toList(growable: false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ environment:
) {
// TODO(brianwilkerson) Consider moving this to AnalysisOptionsImpl.==.
expect(actual.enableTiming, expected.enableTiming);
expect(actual.hint, expected.hint);
expect(actual.lint, expected.lint);
expect(actual.warning, expected.warning);
expect(
actual.lintRules.map((l) => l.name),
unorderedEquals(expected.lintRules.map((l) => l.name)),
Expand Down

0 comments on commit b87dee9

Please sign in to comment.