Skip to content

review of printing patterns #1223

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

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

review of printing patterns #1223

wants to merge 11 commits into from

Conversation

Janther
Copy link
Contributor

@Janther Janther commented Jul 29, 2025

spotted 2 patterns that further clean our printers:

  • printGroupAndIndentIfBreakPair: usually we do have a group followed by an indentIfBreak pointing to that same group. This involves creating a Symbol. All of this can be put in the same logic.

  • printIndentedGroupOrSpacedDocument: when printing (usually the body of a loop statement) we have to choose between a [' ', body] or group(indent([line, body])) this can be simplified by just having a helper with the body and a condition.

I also had a look at the printPreservingEmptyLines helper and added the logic for the comments when there are no lines. This also showed me that our printComments function was ignoring empty lines between comments.

Finally the printSeparatedItem helper has a grouped option that should always be false if the firstSeparator is a hardline

@Janther Janther requested a review from fvictorio July 29, 2025 14:58
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.

1 participant