Skip to content

Commit

Permalink
[stable] Roll latest dart_style into the SDK.
Browse files Browse the repository at this point in the history
The fixes are:

1. Comments in switch expressions would force the next line to split:

```
// Before:
return switch (level) {
  0 => a,
  // Comment.
  1
      when flag =>
    b,
};

// After:
return switch (level) {
  0 => a,
  // Comment.
  1 when flag => b,
};
```

2. Method calls on split record literals split before the ".":

```
// Before:
final a = (
  element,
  element,
)
    .getter;

// After:
final a = (
  element,
  element,
).getter;
```

3. Change how parameter metadata is formatted:

```
// Before:
function(
    @required
        int n,
    @deprecated('Some long deprecation string.')
        String s) {
  ...
}

// After:
function(
    @required int n,
    @deprecated('Some long deprecation string.')
    String s) {
  ...
}
```

This change also significantly improves performance in rare cases where
a function has many parameters.

Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/302500
Change-Id: I56cd6ceb81ad9c98ca7f5d34eea05ef5d29228fb
Fixes: #52346
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302451
Reviewed-by: Alexander Thomas <[email protected]>
Commit-Queue: Bob Nystrom <[email protected]>
  • Loading branch information
munificent authored and Commit Queue committed May 12, 2023
1 parent 2794288 commit 06b4ead
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 3.0.1

### Tools

#### Formatter

- Don't indent parameters with metadata annotations.
- Don't split before `.` following a record literal.
- Don't split unnecessarily in switch expression cases following comments.

## 3.0.0 - 2023-05-10

### Language
Expand Down
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ vars = {
# and land the review.
#
# For more details, see https://github.com/dart-lang/sdk/issues/30164.
"dart_style_rev": "6c9bc10cf2dc6496b2ce863c8d614aa0781abf90", # disable rev_sdk_deps.dart
"dart_style_rev": "156f5c8c3bfe4e3b8e7adc95f7cf24d9500f11c6", # disable rev_sdk_deps.dart
"dartdoc_rev": "1a7952b13858ed307185a28f9b4ea861c0abb1c5",
"ffi_rev": "04fa38ab45cb2957f9059e03031b53906c2c4385",
"file_rev": "72a67c33f90bfb7e10057e286e06d2fe3baa4d98",
Expand Down

0 comments on commit 06b4ead

Please sign in to comment.