Skip to content

Commit 1c64983

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer: Add docs to ExpectedDiagnostic, LintRuleTest, and PubPackageResolutionTest
These will (likely / in some capacity) become public API. Change-Id: Ia9af4a227956d1335ad1d748e6100d12befc40f1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425582 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 2284e20 commit 1c64983

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

pkg/linter/test/rule_test_support.dart

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,17 @@ class ExpectedDiagnostic {
5050
/// The offset of the beginning of the diagnostic's region.
5151
final int _offset;
5252

53-
/// The offset of the beginning of the diagnostic's region.
53+
/// The length of the diagnostic's region.
5454
final int _length;
5555

5656
/// A pattern that should be contained in the diagnostic message or `null` if
5757
/// the message contents should not be checked.
5858
final Pattern? _messageContains;
5959

60-
// A pattern that should be contained in the error's correction message, or
61-
// `null` if the correction message contents should not be checked.
60+
/// A pattern that should be contained in the error's correction message, or
61+
/// `null` if the correction message contents should not be checked.
6262
final Pattern? _correctionContains;
6363

64-
/// Initialize a newly created diagnostic description.
6564
ExpectedDiagnostic(
6665
this._diagnosticMatcher,
6766
this._offset,
@@ -96,6 +95,7 @@ mixin LanguageVersion219Mixin on PubPackageResolutionTest {
9695
}
9796

9897
abstract class LintRuleTest extends PubPackageResolutionTest {
98+
/// The name of the lint rule which this test is concerned with.
9999
String get lintRule;
100100

101101
@override
@@ -107,6 +107,12 @@ abstract class LintRuleTest extends PubPackageResolutionTest {
107107
return [ruleName];
108108
}
109109

110+
/// Returns an "expected diagnostic" for [lintRule] (or [name], if given) at
111+
/// [offset] and [length].
112+
///
113+
/// If given, [messageContains] is used to match against a diagnostic's
114+
/// message, and [correctionContains] is used to match against a diagnostic's
115+
/// correction message.
110116
ExpectedDiagnostic lint(
111117
int offset,
112118
int length, {
@@ -125,27 +131,52 @@ abstract class LintRuleTest extends PubPackageResolutionTest {
125131
class PubPackageResolutionTest extends _ContextResolutionTest {
126132
final List<String> _lintRules = const [];
127133

134+
/// Adds the 'fixnum' package as a dependency to the package-under-test.
135+
///
136+
/// This allows `package:fixnum/fixnum.dart` imports to resolve.
128137
bool get addFixnumPackageDep => false;
129138

139+
/// Adds the 'flutter' package as a dependency to the package-under-test.
140+
///
141+
/// This allows various `package:flutter/` imports to resolve.
130142
bool get addFlutterPackageDep => false;
131143

144+
/// Adds the 'js' package as a dependency to the package-under-test.
145+
///
146+
/// This allows various `package:js/` imports to resolve.
132147
bool get addJsPackageDep => false;
133148

149+
/// Adds the 'kernel' package as a dependency to the package-under-test.
150+
///
151+
/// This allows various `package:kernel/` imports to resolve.
134152
bool get addKernelPackageDep => false;
135153

154+
/// Adds the 'meta' package as a dependency to the package-under-test.
155+
///
156+
/// This allows various `package:meta/` imports to resolve.
136157
bool get addMetaPackageDep => false;
137158

159+
/// Adds the 'test_reflective_loader' package as a dependency to the
160+
/// package-under-test.
161+
///
162+
/// This allows various `package:test_reflective_loader/` imports to resolve.
138163
bool get addTestReflectiveLoaderPackageDep => false;
139164

165+
/// Whether to print out the syntax tree being tested, on a test failure.
140166
bool get dumpAstOnFailures => true;
141167

168+
/// The list of language experiments to be enabled for these tests.
142169
List<String> get experiments => experimentsForTests;
143170

144171
String get testFileName => 'test.dart';
145172

146173
@override
147174
String get testFilePath => '$testPackageLibPath/$testFileName';
148175

176+
/// The language version for the package-under-test.
177+
///
178+
/// Used for writing out a package config file. A `null` value means no
179+
/// 'languageVersion' is written to the package config file.
149180
String? get testPackageLanguageVersion => null;
150181

151182
String get testPackageLibPath => '$testPackageRootPath/lib';

0 commit comments

Comments
 (0)