Skip to content
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

Please start passing in a language version to dart_style #1304

Closed
Tracked by #56688
munificent opened this issue Sep 10, 2024 · 0 comments · Fixed by #1307
Closed
Tracked by #56688

Please start passing in a language version to dart_style #1304

munificent opened this issue Sep 10, 2024 · 0 comments · Fixed by #1307
Labels
package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@munificent
Copy link
Member

Greetings http team friends!

The formatter is moving to being language version aware. This means that when it's parsing some code, it needs to be told what language version to parse it as. The DartFormatter constructor now takes an optional parameter where you can pass in the language version. In a future version of dart_style, that parameter will become mandatory.

If you own code that uses dart_style as a library, you should update your code to pass in a language version. To migrate:

  1. Update your constraint on dart_style to ^2.3.7. That's the version where the new parameter was added.

  2. If you know the precise language version the code should be parsed as, then pass in that version (as an instance of the pub_semver package's Version class). This is what "real" tools should do.

    For simple one-off scripts and other utilities where precise behavior doesn't matter much, you can pass in DartFormatter.latestLanguageVersion to unconditionally parse the code as the latest language version that the formatter itself supports.

When the --tall-style experiment flag ships, the passed in language version will also be used to determine whether you get the current formatting style or the new "tall" style.

The constructor calls that I think are relevant are:

http/pkgs/http_client_conformance_tests/bin/generate_server_wrappers.dart:
   47:   final formatter = DartFormatter();

http/pkgs/web_socket_conformance_tests/bin/generate_server_wrappers.dart:
   40:   final formatter = DartFormatter();

Thank you!

@munificent munificent added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) package:http labels Sep 10, 2024
munificent added a commit that referenced this issue Sep 24, 2024
Going forward, the formatter needs to know what language version it
should use to parse input code. This updates the generator to pass in a
version. (In this case, since it's just used for code generation, it
unconditionally passes in the latest language version, which should be
fine.)

Fix #1304.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant