Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5a2737b

Browse files
author
Dart CI
committed
Version 2.19.0-154.0.dev
Merge commit 'a76d26545bd3a7f2d4f0225d459cb6da2f16f350' into 'dev'
2 parents 7e5a69f + a76d265 commit 5a2737b

Some content is hidden

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

50 files changed

+1128
-242
lines changed

CHANGELOG.md

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -43,39 +43,43 @@
4343
`kExtensionErrorMin` in [`ServiceExtensionResponse`][] have been removed. They
4444
have been replaced by `invalidParams`, `extensionError`, `extensionErrorMax`,
4545
and `extensionErrorMin`.
46+
- Deprecated `UserTag.MAX_USER_TAGS` in favor of `UserTag.maxUserTags`.
4647

4748
[#34233]: https://github.com/dart-lang/sdk/issues/34233
4849
[`ServiceExtensionResponse`]: https://api.dart.dev/stable/2.17.6/dart-developer/ServiceExtensionResponse-class.html#constants
4950

50-
- Deprecated `UserTag.MAX_USER_TAGS` in favor of `UserTag.maxUserTags`.
51-
52-
#### `dart:mirrors`
53-
54-
- **Breaking change** [#34233][]: The APIs [`MirrorsUsed`][] and [`Comment`][]
55-
have been removed. `MirrorsUsed` was experimental and deprecated; `Comment`
56-
was previously used internally in dart2js. Both are no longer functional.
57-
58-
[#34233]: https://github.com/dart-lang/sdk/issues/34233
59-
[`MirrorsUsed`]: https://api.dart.dev/stable/dart-mirrors/MirrorsUsed-class.html
60-
[`Comment`]: https://api.dart.dev/stable/dart-mirrors/Comment-class.html
6151

6252
#### `dart:html`
6353

54+
- Add constructor and `slice` to `SharedArrayBuffer`.
6455
- Deprecated `registerElement` and `registerElement2` in `Document` and
6556
`HtmlDocument`. These APIs were based on the deprecated Web Components v0.5
6657
specification and are not supported by browsers today. These APIs are expected
6758
to be deleted in a future release. See the related breaking change
6859
request [#49536](https://github.com/dart-lang/sdk/issues/49536).
6960

70-
### `dart:io`
71-
- **Breaking change** [#49647][]: `File.create` now takes new optional
72-
`exclusive` `bool` parameter, and when it is `true` the operation
73-
will fail if target file already exists.
61+
#### `dart:io`
62+
63+
- **Breaking Change** [#49305](https://github.com/dart-lang/sdk/issues/49305):
64+
Disallow negative or hexadecimal content-length headers.
65+
- **Breaking change** [#49647][]: `File.create` now takes new optional
66+
`exclusive` `bool` parameter, and when it is `true` the operation
67+
will fail if target file already exists.
7468

7569
#### `dart:isolate`
7670

7771
- Add `Isolate.run` to run a function in a new isolate.
7872

73+
#### `dart:mirrors`
74+
75+
- **Breaking change** [#34233][]: The APIs [`MirrorsUsed`][] and [`Comment`][]
76+
have been removed. `MirrorsUsed` was experimental and deprecated; `Comment`
77+
was previously used internally in dart2js. Both are no longer functional.
78+
79+
[#34233]: https://github.com/dart-lang/sdk/issues/34233
80+
[`MirrorsUsed`]: https://api.dart.dev/stable/dart-mirrors/MirrorsUsed-class.html
81+
[`Comment`]: https://api.dart.dev/stable/dart-mirrors/Comment-class.html
82+
7983
### Tools
8084

8185
#### Analyzer
@@ -130,17 +134,6 @@ Updated the Linter to `1.27.0`, which includes changes that
130134
- **Breaking change** [49473](https://github.com/dart-lang/sdk/issues/49473):
131135
dart2js no longer supports HTTP URIs as inputs.
132136

133-
### Core libraries
134-
135-
#### `dart:io`
136-
137-
- **Breaking Change** [#49305](https://github.com/dart-lang/sdk/issues/49305):
138-
Disallow negative or hexadecimal content-length headers.
139-
140-
#### `dart:html`
141-
142-
- Add constructor and `slice` to `SharedArrayBuffer`.
143-
144137
## 2.18.0
145138

146139
### Language
@@ -212,10 +205,15 @@ them, you must set the lower bound on the SDK constraint for your package to
212205

213206
- The `Stream.fromIterable` stream can now be listened to more than once.
214207

215-
### `dart:collection`
208+
#### `dart:collection`
216209

217210
- Deprecates `BidirectionalIterator`.
218211

212+
#### `dart:core`
213+
214+
- Allow omitting the `unencodedPath` positional argument to `Uri.http` and
215+
`Uri.https` to default to an empty path.
216+
219217
#### `dart:html`
220218

221219
- Add `connectionState` attribute and `connectionstatechange` listener to
@@ -226,7 +224,6 @@ them, you must set the lower bound on the SDK constraint for your package to
226224
- **Breaking Change** [#49045](https://github.com/dart-lang/sdk/issues/49045):
227225
The `uri` property of `RedirectException` in `dart:io` has been changed to
228226
be nullable. Programs must be updated to handle the `null` case.
229-
230227
- **Breaking Change** [#34218](https://github.com/dart-lang/sdk/issues/34218):
231228
Constants in `dart:io`'s networking APIs following the `SCREAMING_CAPS`
232229
convention have been removed (they were previously deprecated). Please use
@@ -280,11 +277,6 @@ them, you must set the lower bound on the SDK constraint for your package to
280277
281278
- Added `dartify` and a number of minor helper functions.
282279
283-
#### `dart:core`
284-
285-
- Allow omitting the `unencodedPath` positional argument to `Uri.http` and
286-
`Uri.https` to default to an empty path.
287-
288280
### Dart VM
289281
290282
Implementation of `async`/`async*`/`sync*` is revamped in Dart VM,
@@ -635,7 +627,6 @@ them, you must set the lower bound on the SDK constraint for your package to
635627
is unchanged for now, but users who intend to use the native
636628
`Element.scrollIntoViewIfNeeded` should use the new `scrollIntoViewIfNeeded`
637629
definition instead.
638-
639630
- Change `Performance.mark` and `Performance.measure` to accept their different
640631
overloads. `mark` can now accept a `markOptions` map, and `measure` can now
641632
accept a `startMark` and `endMark`, or a `measureOptions` map. Both methods
@@ -676,17 +667,14 @@ them, you must set the lower bound on the SDK constraint for your package to
676667
Constants in `dart:io` following the `SCREAMING_CAPS` convention have been
677668
removed (they were previously deprecated). Please use the corresponding
678669
`lowerCamelCase` constants instead.
679-
670+
- **Breaking Change** [#48513](https://github.com/dart-lang/sdk/issues/48513):
671+
Add a new `allowLegacyUnsafeRenegotiation` poperty to `SecurityContext`,
672+
which allows TLS renegotiation for client secure sockets.
680673
- Add a optional `keyLog` parameter to `SecureSocket.connect` and
681674
`SecureSocket.startConnect`.
682-
683675
- Deprecate `SecureSocket.renegotiate` and `RawSecureSocket.renegotiate`,
684676
which were no-ops.
685677

686-
- **Breaking Change** [#48513](https://github.com/dart-lang/sdk/issues/48513):
687-
Add a new `allowLegacyUnsafeRenegotiation` poperty to `SecurityContext`,
688-
which allows TLS renegotiation for client secure sockets.
689-
690678
### Tools
691679

692680
#### Dart command line

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ vars = {
108108
# For more details, see https://github.com/dart-lang/sdk/issues/30164.
109109
"dart_style_rev": "49bc3ff32b5578b6e19f8fd376d668130941ee29", # manually rev'd
110110

111-
"dartdoc_rev": "14581efa5b7a6083b51f8406ae9e3c5466316a03",
111+
"dartdoc_rev": "0fc363d608109ced7e02e4f9698dd4e0a864fee0",
112112
"devtools_rev": "d131d19091f6b89ac89486bd92440a25a523e8b0",
113113
"ffi_rev": "fb5f2667826c0900e551d19101052f84e35f41bf",
114114
"file_rev": "b2e31cb6ef40b223701dbfa0b907fe58468484d7",

pkg/analysis_server/lib/src/services/correction/dart/add_super_constructor_invocation.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ class _AddInvocation extends CorrectionProducer {
106106
} else {
107107
builder.write(', ');
108108
}
109+
110+
if (parameter.isNamed) {
111+
builder.write('${parameter.name}: ');
112+
}
109113
// default value
110114
builder.addSimpleLinkedEdit(
111115
parameter.name, getDefaultValueCode(parameter.type));

pkg/analysis_server/lib/src/services/correction/dart/convert_to_if_null.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class ConvertToIfNull extends CorrectionProducer {
4747
await builder.addDartFileEdit(file, (builder) {
4848
builder.addReplacement(range.node(node), (builder) {
4949
builder.write(utils.getNodeText(nullableExpression));
50+
51+
if (defaultExpression is NullLiteral) return;
5052
builder.write(' ?? ');
5153
if (parentheses) {
5254
builder.write('(');
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (c) 2022, 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+
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
6+
import 'package:analysis_server/src/services/correction/fix.dart';
7+
import 'package:analyzer/dart/ast/ast.dart';
8+
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
9+
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
10+
import 'package:analyzer_plugin/utilities/range_factory.dart';
11+
import 'package:collection/collection.dart';
12+
13+
class SortCombinators extends CorrectionProducer {
14+
@override
15+
bool get canBeAppliedInBulk => true;
16+
17+
@override
18+
bool get canBeAppliedToFile => true;
19+
20+
@override
21+
FixKind get fixKind => DartFixKind.SORT_COMBINATORS;
22+
23+
@override
24+
FixKind get multiFixKind => DartFixKind.SORT_COMBINATORS_MULTI;
25+
26+
@override
27+
Future<void> compute(ChangeBuilder builder) async {
28+
var node = this.node;
29+
30+
NodeList<SimpleIdentifier> names;
31+
if (node is ShowCombinator) {
32+
names = node.shownNames;
33+
} else if (node is HideCombinator) {
34+
names = node.hiddenNames;
35+
} else {
36+
return;
37+
}
38+
39+
var sorted = names.map((e) => e.name).sorted();
40+
41+
await builder.addDartFileEdit(file, (builder) {
42+
for (var i = 0; i < names.length; i++) {
43+
builder.addSimpleReplacement(range.node(names[i]), sorted[i]);
44+
}
45+
});
46+
}
47+
}

pkg/analysis_server/lib/src/services/correction/dart/use_curly_braces.dart

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import 'package:analysis_server/src/services/correction/assist.dart';
66
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
77
import 'package:analysis_server/src/services/correction/fix.dart';
88
import 'package:analyzer/dart/ast/ast.dart';
9+
import 'package:analyzer/dart/ast/syntactic_entity.dart';
10+
import 'package:analyzer/source/source_range.dart';
911
import 'package:analyzer_plugin/utilities/assist/assist.dart';
1012
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
13+
import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart';
1114
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
1215
import 'package:analyzer_plugin/utilities/range_factory.dart';
1316

@@ -77,17 +80,21 @@ class UseCurlyBraces extends CorrectionProducer {
7780
var indent = prefix + utils.getIndent(1);
7881

7982
await builder.addDartFileEdit(file, (builder) {
80-
builder.addSimpleReplacement(
81-
range.endStart(node.doKeyword, body),
82-
' {$eol$indent',
83-
);
84-
builder.addSimpleReplacement(
85-
range.endStart(body, node.whileKeyword),
86-
'$eol$prefix} ',
87-
);
83+
_replaceRange(
84+
builder, node.doKeyword, body, node.whileKeyword, indent, prefix);
8885
});
8986
}
9087

88+
int _endAfterComments(AstNode node) {
89+
var end = node.end;
90+
var comments = node.endToken.next?.precedingComments;
91+
if (comments != null &&
92+
utils.getLineThis(end) == utils.getLineThis(comments.offset)) {
93+
end = comments.end;
94+
}
95+
return end;
96+
}
97+
9198
Future<void> _forStatement(ChangeBuilder builder, ForStatement node) async {
9299
var body = node.body;
93100
if (body is Block) return;
@@ -96,11 +103,7 @@ class UseCurlyBraces extends CorrectionProducer {
96103
var indent = prefix + utils.getIndent(1);
97104

98105
await builder.addDartFileEdit(file, (builder) {
99-
builder.addSimpleReplacement(
100-
range.endStart(node.rightParenthesis, body),
101-
' {$eol$indent',
102-
);
103-
builder.addSimpleInsertion(body.end, '$eol$prefix}');
106+
_replace(builder, node.rightParenthesis, body, indent, prefix);
104107
});
105108
}
106109

@@ -114,17 +117,12 @@ class UseCurlyBraces extends CorrectionProducer {
114117
var elseKeyword = node.elseKeyword;
115118
if (thenStatement is! Block &&
116119
(thenOrElse == null || thenOrElse == thenStatement)) {
117-
builder.addSimpleReplacement(
118-
range.endStart(node.rightParenthesis, thenStatement),
119-
' {$eol$indent',
120-
);
121-
if (elseKeyword != null) {
122-
builder.addSimpleReplacement(
123-
range.endStart(thenStatement, elseKeyword),
124-
'$eol$prefix} ',
125-
);
120+
if (elseKeyword == null) {
121+
_replace(
122+
builder, node.rightParenthesis, thenStatement, indent, prefix);
126123
} else {
127-
builder.addSimpleInsertion(thenStatement.end, '$eol$prefix}');
124+
_replaceRange(builder, node.rightParenthesis, thenStatement,
125+
elseKeyword, indent, prefix);
128126
}
129127
}
130128

@@ -133,15 +131,37 @@ class UseCurlyBraces extends CorrectionProducer {
133131
elseStatement != null &&
134132
elseStatement is! Block &&
135133
(thenOrElse == null || thenOrElse == elseStatement)) {
136-
builder.addSimpleReplacement(
137-
range.endStart(elseKeyword, elseStatement),
138-
' {$eol$indent',
139-
);
140-
builder.addSimpleInsertion(elseStatement.end, '$eol$prefix}');
134+
_replace(builder, elseKeyword, elseStatement, indent, prefix);
141135
}
142136
});
143137
}
144138

139+
void _replace(DartFileEditBuilder builder, SyntacticEntity left,
140+
AstNode right, String indent, String prefix) {
141+
_replaceLeftParenthesis(builder, left, right, indent);
142+
143+
builder.addSimpleInsertion(_endAfterComments(right), '$eol$prefix}');
144+
}
145+
146+
void _replaceLeftParenthesis(DartFileEditBuilder builder,
147+
SyntacticEntity left, SyntacticEntity right, String indent) {
148+
builder.addSimpleReplacement(
149+
range.endStart(left, right),
150+
' {$eol$indent',
151+
);
152+
}
153+
154+
void _replaceRange(DartFileEditBuilder builder, SyntacticEntity left,
155+
AstNode node, SyntacticEntity right, String indent, String prefix) {
156+
_replaceLeftParenthesis(builder, left, node, indent);
157+
158+
var end = _endAfterComments(node);
159+
builder.addSimpleReplacement(
160+
SourceRange(end, right.offset - end),
161+
'$eol$prefix} ',
162+
);
163+
}
164+
145165
Future<void> _whileStatement(
146166
ChangeBuilder builder, WhileStatement node) async {
147167
var body = node.body;
@@ -151,11 +171,7 @@ class UseCurlyBraces extends CorrectionProducer {
151171
var indent = prefix + utils.getIndent(1);
152172

153173
await builder.addDartFileEdit(file, (builder) {
154-
builder.addSimpleReplacement(
155-
range.endStart(node.rightParenthesis, body),
156-
' {$eol$indent',
157-
);
158-
builder.addSimpleInsertion(body.end, '$eol$prefix}');
174+
_replace(builder, node.rightParenthesis, body, indent, prefix);
159175
});
160176
}
161177
}

pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,8 @@ CompileTimeErrorCode.MISSING_DART_LIBRARY:
679679
status: needsEvaluation
680680
CompileTimeErrorCode.MISSING_DEFAULT_VALUE_FOR_PARAMETER:
681681
status: hasFix
682+
CompileTimeErrorCode.MISSING_DEFAULT_VALUE_FOR_PARAMETER_POSITIONAL:
683+
status: hasFix
682684
CompileTimeErrorCode.MISSING_DEFAULT_VALUE_FOR_PARAMETER_WITH_ANNOTATION:
683685
status: hasFix
684686
CompileTimeErrorCode.MISSING_REQUIRED_ARGUMENT:
@@ -1678,7 +1680,7 @@ LintCode.cast_nullable_to_non_nullable:
16781680
LintCode.close_sinks:
16791681
status: needsEvaluation
16801682
LintCode.combinators_ordering:
1681-
status: needsEvaluation
1683+
status: hasFix
16821684
LintCode.comment_references:
16831685
status: needsEvaluation
16841686
LintCode.conditional_uri_does_not_exist:

pkg/analysis_server/lib/src/services/correction/fix.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,16 @@ class DartFixKind {
15751575
DartFixKindPriority.IN_FILE,
15761576
'Move child properties to ends of arguments everywhere in file',
15771577
);
1578+
static const SORT_COMBINATORS = FixKind(
1579+
'dart.fix.sort.combinators',
1580+
DartFixKindPriority.DEFAULT,
1581+
'Sort combinators',
1582+
);
1583+
static const SORT_COMBINATORS_MULTI = FixKind(
1584+
'dart.fix.sort.combinators.multi',
1585+
DartFixKindPriority.IN_FILE,
1586+
'Sort combinators everywhere in file',
1587+
);
15781588
static const SORT_CONSTRUCTOR_FIRST = FixKind(
15791589
'dart.fix.sort.sortConstructorFirst',
15801590
DartFixKindPriority.DEFAULT,

0 commit comments

Comments
 (0)