Skip to content

Commit 16b1b5c

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer: Move LinterOptions to the linter package test utilities
Change-Id: I525132a98f2d2a683150393b22ee66b002a4d507 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392244 Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 87d24d3 commit 16b1b5c

File tree

8 files changed

+28
-20
lines changed

8 files changed

+28
-20
lines changed

pkg/analyzer/lib/src/lint/linter.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import 'package:analyzer/src/dart/element/type_system.dart';
2727
import 'package:analyzer/src/error/codes.dart';
2828
import 'package:analyzer/src/lint/linter_visitor.dart' show NodeLintRegistry;
2929
import 'package:analyzer/src/lint/pub.dart';
30-
import 'package:analyzer/src/lint/registry.dart';
3130
import 'package:analyzer/src/lint/state.dart';
3231
import 'package:analyzer/src/workspace/workspace.dart';
3332
import 'package:meta/meta.dart';
@@ -183,20 +182,6 @@ final class LinterContextWithResolvedResults implements LinterContext {
183182
LibraryElement2 get libraryElement2 => libraryElement as LibraryElement2;
184183
}
185184

186-
class LinterOptions {
187-
final Iterable<LintRule> enabledRules;
188-
189-
/// The path to the Dart SDK.
190-
String? dartSdkPath;
191-
192-
/// Whether to gather timing data during analysis.
193-
bool enableTiming = false;
194-
195-
LinterOptions({
196-
Iterable<LintRule>? enabledRules,
197-
}) : enabledRules = enabledRules ?? Registry.ruleRegistry;
198-
}
199-
200185
/// Describes a lint rule.
201186
abstract class LintRule {
202187
/// Used to report lint warnings.

pkg/linter/lib/src/analyzer.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export 'package:analyzer/src/lint/linter.dart'
2121
dart3_3,
2222
LintRule,
2323
LinterContext,
24-
LinterOptions,
2524
NodeLintRegistry,
2625
State;
2726
export 'package:analyzer/src/lint/pub.dart' show PSEntry, PubspecVisitor;

pkg/linter/lib/src/test_utilities/lint_driver.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
1313
import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine;
1414
// ignore: implementation_imports
1515
import 'package:analyzer/src/lint/io.dart';
16-
// ignore: implementation_imports
17-
import 'package:analyzer/src/lint/linter.dart';
16+
17+
import 'linter_options.dart';
1818

1919
import 'analysis_error_info.dart';
2020

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// ignore: implementation_imports
6+
import 'package:analyzer/src/lint/linter.dart';
7+
// ignore: implementation_imports
8+
import 'package:analyzer/src/lint/registry.dart';
9+
10+
class LinterOptions {
11+
final Iterable<LintRule> enabledRules;
12+
13+
/// The path to the Dart SDK.
14+
String? dartSdkPath;
15+
16+
/// Whether to gather timing data during analysis.
17+
bool enableTiming = false;
18+
19+
LinterOptions({
20+
Iterable<LintRule>? enabledRules,
21+
}) : enabledRules = enabledRules ?? Registry.ruleRegistry;
22+
}

pkg/linter/lib/src/test_utilities/test_linter.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ import 'package:analyzer/source/source.dart';
1313
// ignore: implementation_imports
1414
import 'package:analyzer/src/lint/io.dart';
1515
// ignore: implementation_imports
16-
import 'package:analyzer/src/lint/linter.dart';
17-
// ignore: implementation_imports
1816
import 'package:analyzer/src/lint/pub.dart';
1917
import 'package:meta/meta.dart';
2018
import 'package:path/path.dart' as path;
2119

2220
import 'analysis_error_info.dart';
2321
import 'lint_driver.dart';
22+
import 'linter_options.dart';
2423

2524
Source createSource(Uri uri) {
2625
var filePath = uri.toFilePath();

pkg/linter/lib/src/test_utilities/test_resource_provider.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:analyzer/src/test_utilities/mock_sdk.dart';
1212
import 'package:path/path.dart' as path;
1313

1414
import '../analyzer.dart';
15+
import 'linter_options.dart';
1516
import 'test_linter.dart';
1617

1718
/// Builds the [TestLinter] with appropriate mock SDK, resource providers, and

pkg/linter/test/engine_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:analyzer/error/error.dart';
66
import 'package:analyzer/src/lint/linter.dart';
77
import 'package:analyzer/src/lint/pub.dart';
88
import 'package:analyzer/src/string_source.dart' show StringSource;
9+
import 'package:linter/src/test_utilities/linter_options.dart';
910
import 'package:linter/src/test_utilities/test_linter.dart';
1011
import 'package:linter/src/utils.dart';
1112
import 'package:test/test.dart';

pkg/linter/tool/benchmark.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'package:linter/src/extensions.dart';
1616
import 'package:linter/src/rules.dart';
1717
import 'package:linter/src/test_utilities/analysis_error_info.dart';
1818
import 'package:linter/src/test_utilities/formatter.dart';
19+
import 'package:linter/src/test_utilities/linter_options.dart';
1920
import 'package:linter/src/test_utilities/test_linter.dart';
2021
import 'package:yaml/yaml.dart';
2122

0 commit comments

Comments
 (0)