Repository navigation
Conversation
…lace bool flags with enums The renderer never read the kind of a group. Every emitter, list callback and helper now takes the emitter first. The variants that took a bool (CASE alignment, ONLY, ALTER TYPE attributes, object arguments, JSON format prefix, set operation side) take an enum.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #995.
Three mechanical changes that the rest of the stack builds on. No output changes: every snapshot stays as it is.
What changed
GroupKindis gone. Everygroup_starttook a kind, generated from the parser's node list, but the renderer never read it.LayoutEvent::GroupStartcarries nothing now,emit_parenthesized_conditionno longer takes a kind, and thegroup_kindmacro is removed frompgls_pretty_print_codegen.emit_node,emit_node_enum,emit_node_with, the list callbacks and the few private helpers that took(node, e)now take(e, node), like everyemit_<node>already did. Closures passed to list helpers are|e, node|, and where a closure only forwarded to a function, the function is passed directly.case_expr:BranchPlacement::{Aligned, Indented}replacesalign: bool.range_var:Only::{Allowed, Omitted}replacesallow_only: bool.alter_table_cmd:emit_alter_table_cmd_of(e, cmd, ObjectType)replacesfor_type: bool, so ALTER TABLE passes its own object type.object_with_args:ObjectArguments::{Signature, AggregateSignature, Omitted}replaces two bools and theemit_object_name_only/emit_object_with_args_for_aggregatewrappers.json_value_expr:Prefix::{Space, None}replacesprefix_space: bool.select_stmt: the set operation check takes theOperandSidefromutils/predicates.rsinstead ofis_left_operand: bool.The bools left in parameters carry state rather than pick a variant: whether something was already written (
emitted_any,has_content,first), whether a row is followed by a comma, and whether a space precedes ENCODING.Tests
cargo test -p pgls_pretty_print: no snapshot changes.cargo test -p pgls_pretty_print --release --test option_matrix -- --ignoredcargo clippy --workspace --all-targets -- -D warnings