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

Format top-level and local variable declarations. #1280

Merged
merged 4 commits into from
Oct 13, 2023
Merged

Conversation

munificent
Copy link
Member

@munificent munificent commented Oct 12, 2023

This required tweaking the way partial solutions are ordered so that the solver doesn't avoid overflowing solutions that will ultimately lead to non-overflowing lower cost ones.

Requiring the states to be a zero-based and contiguous makes it harder
for some pieces to support different sets of different states based on
what they contain. For example, an ImportPiece only supports states for
splitting the names inside a single combinator when there is more than
one combinator.

To model that with contiguous states requires the piece to carefully
track how state indexes are shifted or splitting pieces into different
classes to handle the different sets of states.

Instead, with this change, we simply allow the piece to return a list
of states that may be non-contiguous. They can then omit states that
don't make sense given the piece's contents. This makes ImportPiece
simpler and I think will be useful for other pieces that have a variety
of ways they can split.

Also wrap state values in a class to make things a little clearer and
more type safe.
@munificent munificent requested a review from natebosch October 12, 2023 22:17
Copy link
Member

@natebosch natebosch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message could use much more detail.

lib/src/back_end/solution.dart Show resolved Hide resolved
lib/src/front_end/ast_node_visitor.dart Outdated Show resolved Hide resolved
lib/src/piece/variable.dart Show resolved Hide resolved
Base automatically changed from non-contiguous-states to main October 13, 2023 18:32
# Conflicts:
#	lib/src/piece/piece.dart
#	lib/src/piece/postfix.dart
@munificent munificent merged commit c179702 into main Oct 13, 2023
7 checks passed
@munificent munificent deleted the format-variables branch October 13, 2023 18:46
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.

2 participants