-
Notifications
You must be signed in to change notification settings - Fork 121
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
Tall style implementation #1403
Labels
Comments
This was referenced Aug 2, 2024
This was referenced Aug 2, 2024
3 tasks
24 tasks
munificent
added a commit
to dart-archive/code_builder
that referenced
this issue
Oct 22, 2024
We're in [the process of](dart-lang/dart_style#1403) moving dart_style to [a new formatting style](dart-lang/dart_style#1253). That involves making the formatter [aware of the language version of what it's formatting](dart-lang/dart_style#1402). That in turn means that the library API now lets you pass in a language version. In dart_style 2.3.7 [you can pass in a language version but the parameter is optional](https://pub.dev/documentation/dart_style/latest/dart_style/DartFormatter/DartFormatter.html). In the forthcoming 3.0.0 release, that parameter will become mandatory. This updates every call to `DartFormatter()` to pass in the latest language version. If there's a more specific version that should be used, let me know and I'll update the PR. Thanks!
munificent
added a commit
to dart-archive/code_builder
that referenced
this issue
Oct 23, 2024
* Update dart_style to pass in a language version to DartFormatter. We're in [the process of](dart-lang/dart_style#1403) moving dart_style to [a new formatting style](dart-lang/dart_style#1253). That involves making the formatter [aware of the language version of what it's formatting](dart-lang/dart_style#1402). That in turn means that the library API now lets you pass in a language version. In dart_style 2.3.7 [you can pass in a language version but the parameter is optional](https://pub.dev/documentation/dart_style/latest/dart_style/DartFormatter/DartFormatter.html). In the forthcoming 3.0.0 release, that parameter will become mandatory. This updates every call to `DartFormatter()` to pass in the latest language version. * Update CHANGELOG and analysis_options.yaml. * Require Dart SDK 3.5.0.
munificent
added a commit
to google/googleapis.dart
that referenced
this issue
Oct 24, 2024
We're in [the process of](dart-lang/dart_style#1403) moving dart_style to [a new formatting style](dart-lang/dart_style#1253). That involves making the formatter [aware of the language version of what it's formatting](dart-lang/dart_style#1402). That in turn means that the library API now lets you pass in a language version. In dart_style 2.3.7 [you can pass in a language version but the parameter is optional](https://pub.dev/documentation/dart_style/latest/dart_style/DartFormatter/DartFormatter.html). In the forthcoming 3.0.0 release, that parameter will become mandatory. This updates the call to `DartFormatter()` to pass in the latest language version. If there's a more specific version that should be used, let me know and I'll update the PR.
munificent
added a commit
to dart-lang/i18n
that referenced
this issue
Oct 25, 2024
We're in [the process of](dart-lang/dart_style#1403) moving dart_style to [a new formatting style](dart-lang/dart_style#1253). That involves making the formatter [aware of the language version of what it's formatting](dart-lang/dart_style#1402). That in turn means that the library API now lets you pass in a language version. In dart_style 2.3.7 [you can pass in a language version but the parameter is optional](https://pub.dev/documentation/dart_style/latest/dart_style/DartFormatter/DartFormatter.html). In the forthcoming 3.0.0 release, that parameter will become mandatory. This updates the two calls to `DartFormatter()` in intl_translation/bin to pass in a language version. It attempts to look for a surrounding package_config.json file and uses the language version from that (which is what other Dart tools do). If that files, it just defaults to using the latest language version that the formatter supports.
munificent
added a commit
to google/googleapis.dart
that referenced
this issue
Oct 25, 2024
We're in [the process of](dart-lang/dart_style#1403) moving dart_style to [a new formatting style](dart-lang/dart_style#1253). That involves making the formatter [aware of the language version of what it's formatting](dart-lang/dart_style#1402). That in turn means that the library API now lets you pass in a language version. In dart_style 2.3.7 [you can pass in a language version but the parameter is optional](https://pub.dev/documentation/dart_style/latest/dart_style/DartFormatter/DartFormatter.html). In the forthcoming 3.0.0 release, that parameter will become mandatory. This updates the call to `DartFormatter()` to pass in the latest language version. If there's a more specific version that should be used, let me know and I'll update the PR.
mosuem
pushed a commit
to dart-lang/tools
that referenced
this issue
Oct 25, 2024
…rt-archive/code_builder#466) * Update dart_style to pass in a language version to DartFormatter. We're in [the process of](dart-lang/dart_style#1403) moving dart_style to [a new formatting style](dart-lang/dart_style#1253). That involves making the formatter [aware of the language version of what it's formatting](dart-lang/dart_style#1402). That in turn means that the library API now lets you pass in a language version. In dart_style 2.3.7 [you can pass in a language version but the parameter is optional](https://pub.dev/documentation/dart_style/latest/dart_style/DartFormatter/DartFormatter.html). In the forthcoming 3.0.0 release, that parameter will become mandatory. This updates every call to `DartFormatter()` to pass in the latest language version. * Update CHANGELOG and analysis_options.yaml. * Require Dart SDK 3.5.0.
copybara-service bot
pushed a commit
to dart-lang/i18n
that referenced
this issue
Oct 25, 2024
-- f9f3ade by Robert Nystrom <[email protected]>: Pass a language version to DartFormatter(). We're in [the process of](dart-lang/dart_style#1403) moving dart_style to [a new formatting style](dart-lang/dart_style#1253). That involves making the formatter [aware of the language version of what it's formatting](dart-lang/dart_style#1402). That in turn means that the library API now lets you pass in a language version. In dart_style 2.3.7 [you can pass in a language version but the parameter is optional](https://pub.dev/documentation/dart_style/latest/dart_style/DartFormatter/DartFormatter.html). In the forthcoming 3.0.0 release, that parameter will become mandatory. This updates the two calls to `DartFormatter()` in intl_translation/bin to pass in a language version. It attempts to look for a surrounding package_config.json file and uses the language version from that (which is what other Dart tools do). If that files, it just defaults to using the latest language version that the formatter supports. PiperOrigin-RevId: 689754530
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This meta issue tracks work remaining to be done to ship the new "tall style" proposal (#1253).
Implement tall style:
Implement all language syntax using the new internal representation and formatter. There should be no more
throw UnimplementedError
in the codebase.(Make the formatter aware of the language version of what it's formatting #1402) Add support for detecting the language version of each file being formatted.
Address remaining
TODO(tall)
andTODO(perf)
comments in code. For many of these, we may ultimately decide to do nothing, keep the current behavior, and simply remove the TODOs. But once we have migrated the regression tests and run the new formatter on a large corpus, we should be in a better position to make those decisions.Migrate the regression tests. Since we'll support both the short and tall styles for a while, we'll want to fork them and keep the old ones. There is a
test/regression_tall/
directory already, so we can just fork and migrate thetest/regression/
subdirectories into there and reformat them using the new tall style. We'll probably want to do it a subdirectory at a time (since it's so much code). The important part is to manually review the formatted results and see if the new style is producing the output we want.Run the new formatter on a large corpus of code. Look at the diffs and evaluate the results. Does it look like we expect? Does it produce weird output on unusual code? Are there style rules or heuristics we want to tweak? Does the performance degrade on some kinds of code?
Close issues that are now fixed or invalid. There are likely a bunch of long-standing style issues that the new style either directly fixes or where the issue is now irrelevant because the new style takes an entirely different approach. We can close those out.
Get feedback. We can do much of the evaluation ourselves, and we know that most users are generally in favor of the new style. But to minimize churn after it ships, it would help to send out a request for anyone who cares to try out the new style on their code and file issues for output they don't like.
Make migration easier:
When the new style ships, users will start mass migrating code. That can change the indentation of lines, which may in turn cause long strings and comments to go past the page width. Before this feature ships, we may want to consider:
(Wrap strings automatically with dartfmt #909) Support splitting long strings.
(Support for re-wrapping comments? #982) Support re-wrapping comments.
(Allow disabling formatting for a region of code. #1522) Add the ability to opt regions out code out of automated formatting. Some folks on the Flutter team have expressed a strong desire to still be able to hand-format some code where the automated formatting doesn't preserve alignment across rows in things like large table-like collection literals.
Add support for project-wide style configuration to opt old code into the new style. Project-wide configuration of line length is a long-standing issue (File-level page width configuration #1157). If we have that, we can also use it to let users opt into the tall style even for files whose language version is older than when the tall style ships. This can be useful for package maintainers who are deliberately staying on an older language version to be compatible with users on older SDKs but still want to use the newer style.
This one doesn't necessarily need to be done before we ship the new style.
Integrate it into tools:
Roll a version of dart_style with language version support into the Dart SDK.
[Meta] Ship the new formatting style and migrate to it sdk#56688 Talk to the analyzer and other IDE integration folks about updating their integration to use that new API and pass in language versions when requesting formatting.
Ship support for tall style:
Remove support for
dart format --fix
. The tall style doesn't support it and now thatdart fix
supports all of the same changes and can be run in a faster mode with no static analysis, we have no intention of re-implementing it. Instead, we declare a breaking change and remove support for it for both short and tall styles. This means bumping dart_style to 3.0.0.Remove the old
dartformat
anddartfmt
CLI commands and the old CLI. A few years back when we changed the way to run the formatter fromdartfmt
(its own top-level shell command) todart format
, we also designed a new better set of command line options. That's what you get when you rundart format
. But if you globally activate the dart_style package, that still exposes two executables that (for compatibility) continue to use the old CLI.Since we are making a 3.0.0 breaking change to dart_style anyway, and (as far as I know), those commands are rarely used, now is a good time to remove them.
Ship the experiment. Instead of relying on an experiment flag to determine which style you get, use the language version of the file being formatted. If it's above
3.x
(wherex
is whatever Dart SDK version the new formatter will ship in), you get the tall style. Otherwise, you get the short style.Update README. Make it use the new style and describe how to opt regions of code out of formatting.
(https://dart-review.googlesource.com/c/sdk/+/391263) Roll the new formatter into the Dart SDK.
Remove support for short style:
For some number of Dart SDK releases,
dart format
will support both short and tall styles (and use language version and project configuration to pick which one a user gets where). But we don't indent to support short style on older code in perpetuity. Eventually, we will remove support for short style entirely and even older language version files will be formatted using the tall style.Decide what version of the Dart SDK will no longer support the short style. Coordinate with leads and PMs to decide when we want to remove support.
Announce the intent to stop supporting the older style. Send a notification on all the various channels letting users know that the upcoming Dart SDK release will change the formatting of their older language versioned files. Encourage users to pre-emptively configure their project to use the new style on all of their files to minimize disruption.
Remove support for short style. Delete the old AST visitor, Chunk internal representation, line splitter, and short style tests. Rejoice at the simpler, cleaner formatter codebase.
Roll it into the Dart SDK.
The text was updated successfully, but these errors were encountered: