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

Correct indentation on parameters with both metadata and default values. #1478

Merged
merged 3 commits into from
May 13, 2024

Conversation

munificent
Copy link
Member

The AST node for a parameter with both metadata and a default value looks like:

DefaultValueFormalParameter
  FormalParameter

The inner node has the metadata and the outer one has the default value. Prior to this PR, that meant that we'd create an AssignPiece for the default value whose left-hand side piece was the function parameter and its metadata. That meant that when the metadata split, the outer AssignPiece would be forced to split.

This slightly awkward change makes the piece structure reflect how the user (and, alas, not Analyzer) thinks of the syntax where the metadata is part of the entire parameter and the default value is inside the parameter.

Fix #1461.

The AST node for a parameter with both metadata and a default value
looks like:

    DefaultValueFormalParameter
      FormalParameter

The inner node has the metadata and the outer one has the default value.
Prior to this PR, that meant that we'd create an AssignPiece for the
default value whose left-hand side piece was the function parameter and
its metadata. That meant that when the metadata split, the outer
AssignPiece would be forced to split.

This slightly awkward change makes the piece structure reflect how the
user (and, alas, not Analyzer) thinks of the syntax where the metadata
is part of the entire parameter and the default value is inside the
parameter.

Fix #1461.
@srawlins
Copy link
Member

srawlins commented May 9, 2024

Woohoo! Just for paper-trail purposes, I believe this will fix #558 when Tall Style is The Style.

lib/src/front_end/piece_factory.dart Outdated Show resolved Hide resolved
munificent and others added 2 commits May 13, 2024 10:19
Co-authored-by: Nate Bosch <nbosch@google.com>
@munificent munificent merged commit bdc8a8c into main May 13, 2024
7 checks passed
@munificent munificent deleted the default-value-and-metadata branch May 13, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[tall] Incorrect indentation with multiple annotations on a parameter
4 participants