Skip to content

Enable support for inline class syntax #1185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Format patterns and related features.
* Format record expressions and record type annotations.
* Format class modifiers `base`, `final`, `interface`, `mixin`, and `sealed`.
* Format `inline class` declarations.
* Format unnamed libraries.

## Bug fixes and style changes
Expand All @@ -20,7 +21,7 @@
* Fix metadata test to not fail when record syntax makes whitespace between
metadata annotation names and `(` significant ([sdk#50769][]).
* Require Dart 2.19.
* Require `package:analyzer` `^5.1.0`.
* Require `package:analyzer` `^5.7.0`.

[sdk#50769]: https://github.com/dart-lang/sdk/issues/50769

Expand All @@ -47,7 +48,7 @@
* Don't allow a line comment in an argument list to cause preceding arguments
to be misformatted.
* Remove blank lines after a line comment at the end of a body.
* Require `package:analyzer` `>=4.4.0 <6.0.0`.
* Require `package:analyzer` `>=4.4.0 <6.0.0`.

# 2.2.3

Expand Down
1 change: 1 addition & 0 deletions lib/src/dart_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class DartFormatter {
var featureSet = FeatureSet.fromEnableFlags2(
sdkLanguageVersion: Version(2, 19, 0),
flags: [
'inline-class',
'class-modifiers',
if (patterns) 'patterns',
'records',
Expand Down
1 change: 1 addition & 0 deletions lib/src/source_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ class SourceVisitor extends ThrowingAstVisitor {
modifier(node.finalKeyword);
modifier(node.sealedKeyword);
modifier(node.mixinKeyword);
modifier(node.inlineKeyword);
token(node.classKeyword);
space();
token(node.name);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:
sdk: ">=2.19.0 <3.0.0"

dependencies:
analyzer: ^5.6.0
analyzer: ^5.7.0
args: ">=1.0.0 <3.0.0"
path: ^1.0.0
pub_semver: ">=1.4.4 <3.0.0"
Expand Down
6 changes: 5 additions & 1 deletion test/whitespace/classes.unit
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,8 @@ base mixin class C11 = Object
abstract mixin class C12 = Object
with Mixin;
abstract base mixin class C13 = Object
with Mixin;
with Mixin;
>>> inline classes
inline class C {}
<<<
inline class C {}