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

Remove print_assigment for some utilities and less dry code #2010

Open
wants to merge 40 commits into
base: main
Choose a base branch
from

Conversation

phated
Copy link
Member

@phated phated commented Feb 10, 2024

This removes the print_assignment function, as we don't have the concept of an assignment in the parsetree.

As we saw with the previous formatter, having a bunch of flags that you pass to a function is a code smell that makes it harder to tweak specific behavior on specific nodes of the tree. Instead, I've inlined the Doc creation code to the match branches, which is a little bit of duplication right now but will make our lives easier if one branch needs to change.

I've also made helpers to encapsulate the collapsible logic, which already lead to a question during the formatter code review.

@@ -260,6 +260,94 @@ let needs_grouping = (~parent, ~side: infix_side, expr) => {
};
};

let get_op_and_assignment = new_value => {
Copy link
Member

Choose a reason for hiding this comment

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

This name feels confusing to me out of context. I want a name that communicates that it gets the operator and assignment value from an infix assignment expression, but obviously that seems unnecessarily wordy with a name like get_infix_assignment_op_and_value.

Copy link
Member

Choose a reason for hiding this comment

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

What about get_infix_parts?

@phated phated force-pushed the phated/formatter-record-pattern branch from 1899825 to 5ea244f Compare February 19, 2024 19:57
Base automatically changed from phated/formatter-record-pattern to oscar/formatter February 19, 2024 20:29
Base automatically changed from oscar/formatter to main February 19, 2024 23:06
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.

3 participants