Skip to content

Commit 6f1bd8d

Browse files
author
Dart CI
committed
Version 3.11.0-91.0.dev
Merge 781cf0e into dev
2 parents ac065fc + 781cf0e commit 6f1bd8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5957
-3872
lines changed

pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_error_code.g.dart

Lines changed: 63 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
2727
LocatableDiagnostic Function({required Object p0, required Object p1})
2828
>
2929
conflictingKey = TransformSetErrorTemplate(
30-
'conflicting_key',
31-
"The key '{0}' can't be used when '{1}' is also used.",
30+
name: 'conflicting_key',
31+
problemMessage: "The key '{0}' can't be used when '{1}' is also used.",
3232
withArguments: _withArgumentsConflictingKey,
3333
expectedTypes: [ExpectedType.object, ExpectedType.object],
3434
);
3535

3636
/// No parameters.
3737
static const TransformSetErrorWithoutArguments expectedPrimary =
3838
TransformSetErrorWithoutArguments(
39-
'expected_primary',
40-
"Expected either an identifier or a string literal.",
39+
name: 'expected_primary',
40+
problemMessage: "Expected either an identifier or a string literal.",
4141
expectedTypes: [],
4242
);
4343

@@ -48,8 +48,9 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
4848
LocatableDiagnostic Function({required Object p0, required Object p1})
4949
>
5050
incompatibleElementKind = TransformSetErrorTemplate(
51-
'incompatible_element_kind',
52-
"An element of kind '{0}' can't be replaced by an element of kind '{1}'.",
51+
name: 'incompatible_element_kind',
52+
problemMessage:
53+
"An element of kind '{0}' can't be replaced by an element of kind '{1}'.",
5354
withArguments: _withArgumentsIncompatibleElementKind,
5455
expectedTypes: [ExpectedType.object, ExpectedType.object],
5556
);
@@ -61,8 +62,9 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
6162
LocatableDiagnostic Function({required Object p0, required Object p1})
6263
>
6364
invalidChangeForKind = TransformSetErrorTemplate(
64-
'invalid_change_for_kind',
65-
"A change of type '{0}' can't be used for an element of kind '{1}'.",
65+
name: 'invalid_change_for_kind',
66+
problemMessage:
67+
"A change of type '{0}' can't be used for an element of kind '{1}'.",
6668
withArguments: _withArgumentsInvalidChangeForKind,
6769
expectedTypes: [ExpectedType.object, ExpectedType.object],
6870
);
@@ -73,8 +75,8 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
7375
LocatableDiagnostic Function({required Object p0})
7476
>
7577
invalidCharacter = TransformSetErrorTemplate(
76-
'invalid_character',
77-
"Invalid character '{0}'.",
78+
name: 'invalid_character',
79+
problemMessage: "Invalid character '{0}'.",
7880
withArguments: _withArgumentsInvalidCharacter,
7981
expectedTypes: [ExpectedType.object],
8082
);
@@ -85,8 +87,8 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
8587
LocatableDiagnostic Function({required Object p0})
8688
>
8789
invalidKey = TransformSetErrorTemplate(
88-
'invalid_key',
89-
"Keys must be of type 'String' but found the type '{0}'.",
90+
name: 'invalid_key',
91+
problemMessage: "Keys must be of type 'String' but found the type '{0}'.",
9092
withArguments: _withArgumentsInvalidKey,
9193
expectedTypes: [ExpectedType.object],
9294
);
@@ -97,19 +99,20 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
9799
LocatableDiagnostic Function({required Object p0})
98100
>
99101
invalidParameterStyle = TransformSetErrorTemplate(
100-
'invalid_parameter_style',
101-
"The parameter style must be one of the following: {0}.",
102+
name: 'invalid_parameter_style',
103+
problemMessage: "The parameter style must be one of the following: {0}.",
102104
withArguments: _withArgumentsInvalidParameterStyle,
103105
expectedTypes: [ExpectedType.object],
104106
);
105107

106108
/// No parameters.
107-
static const TransformSetErrorWithoutArguments invalidRequiredIf =
108-
TransformSetErrorWithoutArguments(
109-
'invalid_required_if',
109+
static const TransformSetErrorWithoutArguments
110+
invalidRequiredIf = TransformSetErrorWithoutArguments(
111+
name: 'invalid_required_if',
112+
problemMessage:
110113
"The key 'requiredIf' can only be used with optional named parameters.",
111-
expectedTypes: [],
112-
);
114+
expectedTypes: [],
115+
);
113116

114117
/// Parameters:
115118
/// Object p0: the key with which the value is associated
@@ -123,8 +126,9 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
123126
})
124127
>
125128
invalidValue = TransformSetErrorTemplate(
126-
'invalid_value',
127-
"The value of '{0}' should be of type '{1}' but is of type '{2}'.",
129+
name: 'invalid_value',
130+
problemMessage:
131+
"The value of '{0}' should be of type '{1}' but is of type '{2}'.",
128132
withArguments: _withArgumentsInvalidValue,
129133
expectedTypes: [
130134
ExpectedType.object,
@@ -140,8 +144,8 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
140144
LocatableDiagnostic Function({required Object p0, required Object p1})
141145
>
142146
invalidValueOneOf = TransformSetErrorTemplate(
143-
'invalid_value_one_of',
144-
"The value of '{0}' must be one of the following: '{1}'.",
147+
name: 'invalid_value_one_of',
148+
problemMessage: "The value of '{0}' must be one of the following: '{1}'.",
145149
withArguments: _withArgumentsInvalidValueOneOf,
146150
expectedTypes: [ExpectedType.object, ExpectedType.object],
147151
);
@@ -152,8 +156,8 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
152156
LocatableDiagnostic Function({required Object p0})
153157
>
154158
missingKey = TransformSetErrorTemplate(
155-
'missing_key',
156-
"Missing the required key '{0}'.",
159+
name: 'missing_key',
160+
problemMessage: "Missing the required key '{0}'.",
157161
withArguments: _withArgumentsMissingKey,
158162
expectedTypes: [ExpectedType.object],
159163
);
@@ -164,17 +168,17 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
164168
LocatableDiagnostic Function({required Object p0})
165169
>
166170
missingOneOfMultipleKeys = TransformSetErrorTemplate(
167-
'missing_one_of_multiple_keys',
168-
"Exactly one of the following keys must be provided: {0}.",
171+
name: 'missing_one_of_multiple_keys',
172+
problemMessage: "Exactly one of the following keys must be provided: {0}.",
169173
withArguments: _withArgumentsMissingOneOfMultipleKeys,
170174
expectedTypes: [ExpectedType.object],
171175
);
172176

173177
/// No parameters.
174178
static const TransformSetErrorWithoutArguments missingTemplateEnd =
175179
TransformSetErrorWithoutArguments(
176-
'missing_template_end',
177-
"Missing the end brace for the template.",
180+
name: 'missing_template_end',
181+
problemMessage: "Missing the end brace for the template.",
178182
expectedTypes: [],
179183
);
180184

@@ -184,17 +188,17 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
184188
LocatableDiagnostic Function({required Object p0})
185189
>
186190
missingToken = TransformSetErrorTemplate(
187-
'missing_token',
188-
"Expected to find {0}.",
191+
name: 'missing_token',
192+
problemMessage: "Expected to find {0}.",
189193
withArguments: _withArgumentsMissingToken,
190194
expectedTypes: [ExpectedType.object],
191195
);
192196

193197
/// No parameters.
194198
static const TransformSetErrorWithoutArguments missingUri =
195199
TransformSetErrorWithoutArguments(
196-
'missing_uri',
197-
"At least one URI must be provided.",
200+
name: 'missing_uri',
201+
problemMessage: "At least one URI must be provided.",
198202
expectedTypes: [],
199203
);
200204

@@ -204,8 +208,8 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
204208
LocatableDiagnostic Function({required Object p0})
205209
>
206210
undefinedVariable = TransformSetErrorTemplate(
207-
'undefined_variable',
208-
"The variable '{0}' isn't defined.",
211+
name: 'undefined_variable',
212+
problemMessage: "The variable '{0}' isn't defined.",
209213
withArguments: _withArgumentsUndefinedVariable,
210214
expectedTypes: [ExpectedType.object],
211215
);
@@ -216,8 +220,8 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
216220
LocatableDiagnostic Function({required Object p0})
217221
>
218222
unexpectedTransformSetToken = TransformSetErrorTemplate(
219-
'unexpected_transform_set_token',
220-
"Didn't expect to find {0}.",
223+
name: 'unexpected_transform_set_token',
224+
problemMessage: "Didn't expect to find {0}.",
221225
withArguments: _withArgumentsUnexpectedTransformSetToken,
222226
expectedTypes: [ExpectedType.object],
223227
);
@@ -228,8 +232,8 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
228232
LocatableDiagnostic Function({required Object p0})
229233
>
230234
unknownAccessor = TransformSetErrorTemplate(
231-
'unknown_accessor',
232-
"The accessor '{0}' is invalid.",
235+
name: 'unknown_accessor',
236+
problemMessage: "The accessor '{0}' is invalid.",
233237
withArguments: _withArgumentsUnknownAccessor,
234238
expectedTypes: [ExpectedType.object],
235239
);
@@ -240,26 +244,27 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
240244
LocatableDiagnostic Function({required Object p0})
241245
>
242246
unsupportedKey = TransformSetErrorTemplate(
243-
'unsupported_key',
244-
"The key '{0}' isn't supported.",
247+
name: 'unsupported_key',
248+
problemMessage: "The key '{0}' isn't supported.",
245249
withArguments: _withArgumentsUnsupportedKey,
246250
expectedTypes: [ExpectedType.object],
247251
);
248252

249253
/// No parameters.
250254
static const TransformSetErrorWithoutArguments unsupportedStatic =
251255
TransformSetErrorWithoutArguments(
252-
'unsupported_static',
253-
"The key 'static' is only supported for elements in a class, enum, "
256+
name: 'unsupported_static',
257+
problemMessage:
258+
"The key 'static' is only supported for elements in a class, enum, "
254259
"extension, or mixin.",
255260
expectedTypes: [],
256261
);
257262

258263
/// No parameters.
259264
static const TransformSetErrorWithoutArguments unsupportedVersion =
260265
TransformSetErrorWithoutArguments(
261-
'unsupported_version',
262-
"Only version '1' is supported at this time.",
266+
name: 'unsupported_version',
267+
problemMessage: "Only version '1' is supported at this time.",
263268
expectedTypes: [],
264269
);
265270

@@ -270,8 +275,8 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
270275
LocatableDiagnostic Function({required Object p0, required Object p1})
271276
>
272277
wrongToken = TransformSetErrorTemplate(
273-
'wrong_token',
274-
"Expected to find {0}, but found {1}.",
278+
name: 'wrong_token',
279+
problemMessage: "Expected to find {0}, but found {1}.",
275280
withArguments: _withArgumentsWrongToken,
276281
expectedTypes: [ExpectedType.object, ExpectedType.object],
277282
);
@@ -282,24 +287,22 @@ class TransformSetErrorCode extends DiagnosticCodeWithExpectedTypes {
282287
LocatableDiagnostic Function({required Object p0})
283288
>
284289
yamlSyntaxError = TransformSetErrorTemplate(
285-
'yaml_syntax_error',
286-
"Parse error: {0}",
290+
name: 'yaml_syntax_error',
291+
problemMessage: "Parse error: {0}",
287292
withArguments: _withArgumentsYamlSyntaxError,
288293
expectedTypes: [ExpectedType.object],
289294
);
290295

291296
/// Initialize a newly created error code to have the given [name].
292-
const TransformSetErrorCode(
293-
String name,
294-
String problemMessage, {
297+
const TransformSetErrorCode({
298+
required super.name,
299+
required super.problemMessage,
295300
super.correctionMessage,
296301
super.hasPublishedDocs = false,
297302
super.isUnresolvedIdentifier = false,
298303
String? uniqueName,
299304
required super.expectedTypes,
300305
}) : super(
301-
name: name,
302-
problemMessage: problemMessage,
303306
type: DiagnosticType.COMPILE_TIME_ERROR,
304307
uniqueName: 'TransformSetErrorCode.${uniqueName ?? name}',
305308
);
@@ -442,9 +445,9 @@ final class TransformSetErrorTemplate<T extends Function>
442445
final T withArguments;
443446

444447
/// Initialize a newly created error code to have the given [name].
445-
const TransformSetErrorTemplate(
446-
super.name,
447-
super.problemMessage, {
448+
const TransformSetErrorTemplate({
449+
required super.name,
450+
required super.problemMessage,
448451
super.correctionMessage,
449452
super.hasPublishedDocs = false,
450453
super.isUnresolvedIdentifier = false,
@@ -457,9 +460,9 @@ final class TransformSetErrorTemplate<T extends Function>
457460
final class TransformSetErrorWithoutArguments extends TransformSetErrorCode
458461
with DiagnosticWithoutArguments {
459462
/// Initialize a newly created error code to have the given [name].
460-
const TransformSetErrorWithoutArguments(
461-
super.name,
462-
super.problemMessage, {
463+
const TransformSetErrorWithoutArguments({
464+
required super.name,
465+
required super.problemMessage,
463466
super.correctionMessage,
464467
super.hasPublishedDocs = false,
465468
super.isUnresolvedIdentifier = false,

pkg/analysis_server_plugin/doc/testing_rules.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
# Testing rules
22

3-
<!-- TODO(srawlins): Link to analyzer_testing, when published. -->
4-
5-
The `analyzer_testing` package provides an API for testing analysis rules. Tests
6-
can be written concisely, encouraging the plugin author to write test cases with
7-
good coverage of possible Dart syntax, and the analysis rules themselves.
3+
The [`analyzer_testing`][] package provides an API for testing analysis rules.
4+
Tests can be written concisely, encouraging the plugin author to write test
5+
cases with good coverage of possible Dart syntax, and the analysis rules
6+
themselves.
87

98
## The test class
109

11-
Analysis rule tests that are written with the `analyzer_testing` package's
10+
Analysis rule tests that are written with the [`analyzer_testing`][] package's
1211
support use a class hierarchy to specify shared variables, helper methods, and
1312
set-up and tear-down code. This is all based on the [`test_reflective_loader`][]
1413
package. Here is the basic structure:
1514

1615

1716
```dart
18-
import 'package:analyzer/src/lint/registry.dart';
1917
import 'package:analyzer_testing/analysis_rule/analysis_rule.dart';
2018
import 'package:my_rule/src/rules/my_rule.dart';
2119
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -24,13 +22,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
2422
class MyRuleTest extends AnalysisRuleTest {
2523
@override
2624
void setUp() {
27-
Registry.ruleRegistry.registerLintRule(MyRule());
25+
rule = MyRule();
2826
super.setUp();
2927
}
3028
31-
@override
32-
String get analysisRule => 'my_rule';
33-
3429
// Test cases go here.
3530
}
3631
```
@@ -52,11 +47,8 @@ components of the `MyRuleTest` class.
5247
`newFile`.
5348
* `void setUp` - Override this method to provide some set-up code that is
5449
executed before each test. This method must call `super.setUp()`. This method
55-
is where we register the analysis rule that we are testing:
56-
`Registry.ruleRegistry.registerLintRule(MyRule());`.
57-
* `String get analysisRule` - This getter must be implemented, returning the
58-
analysis rule name, so that the test knows what analysis rule to expect. This
59-
is the name that the rule class passes up to the super-constructor.
50+
is where we instantiate the analysis rule that we are testing:
51+
`rule = MyRule();`.
6052

6153
## The test cases
6254

@@ -154,5 +146,6 @@ With this `main` function, tests can be run in the same way as class `test`
154146
package tests. They can be run in the usual ways, such as using the IDE, or by
155147
running `dart test` or `dart --enable-asserts test/my_rule_test.dart`.
156148

149+
[`analyzer_testing`]: https://pub.dev/packages/analyzer_testing
157150
[writing rules]: https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server_plugin/doc/writing_rules.md
158151
[`test_reflective_loader`]: https://pub.dev/packages/test_reflective_loader

pkg/analyzer/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,7 @@ package:analyzer/dart/ast/ast.dart:
12561256
returnType (getter: TypeAnnotation?)
12571257
typeParameters (getter: TypeParameterList?)
12581258
FunctionTypedFormalParameter (class extends Object implements NormalFormalParameter):
1259+
keyword (getter: Token?)
12591260
name (getter: Token)
12601261
parameters (getter: FormalParameterList)
12611262
question (getter: Token?)

0 commit comments

Comments
 (0)