Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: pretty print poc #480

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

Draft
psteinroe wants to merge 53 commits into main
base: main
Choose a base branch
Loading
from pretty-print
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
8350bdd
i guess i will try this
psteinroe Aug 21, 2025
9e039b7
progress
psteinroe Aug 21, 2025
048db82
progress
psteinroe Aug 21, 2025
0911372
progress
psteinroe Aug 21, 2025
75101a6
progress
psteinroe Aug 22, 2025
111de33
progress
psteinroe Aug 22, 2025
a34467d
progress
psteinroe Aug 22, 2025
4405de6
progress
psteinroe Aug 25, 2025
e91137b
chore: add agentic loop poc
psteinroe Aug 26, 2025
9f587b1
progress
psteinroe Aug 26, 2025
fbb05e5
progress
psteinroe Aug 27, 2025
166e9bb
progress
psteinroe Aug 28, 2025
9a5fb50
progress
psteinroe Aug 28, 2025
215625a
progress
psteinroe Aug 29, 2025
2b935e9
progress
psteinroe Aug 29, 2025
9da08d8
progress
psteinroe Aug 31, 2025
d00ffdc
progress
psteinroe Aug 31, 2025
8fd9060
progress
psteinroe Sep 1, 2025
ad93e98
progress
psteinroe Sep 3, 2025
b8181a6
progress
psteinroe Sep 3, 2025
a764d58
progress
psteinroe Sep 3, 2025
aebf166
progress
psteinroe Sep 3, 2025
4d377e5
progress
psteinroe Sep 5, 2025
32c9f88
progress
psteinroe Sep 5, 2025
d14958c
progress
psteinroe Sep 5, 2025
20d9cae
progress
psteinroe Sep 5, 2025
d03fea5
progress
psteinroe Sep 6, 2025
1f26910
progress
psteinroe Sep 6, 2025
9caaea9
progress
psteinroe Sep 6, 2025
2434372
progress
psteinroe Sep 6, 2025
62685be
progress
psteinroe Sep 8, 2025
23cf241
progress
psteinroe Sep 8, 2025
48e9406
progress
psteinroe Sep 9, 2025
d3d5d18
progress
psteinroe Sep 10, 2025
5cee7af
progress
psteinroe Sep 11, 2025
4acf8c6
progress
psteinroe Sep 12, 2025
b72b244
progress
psteinroe Sep 15, 2025
af987f1
progress
psteinroe Sep 18, 2025
8ff7313
Merge branch 'main' into pretty-print
psteinroe Sep 18, 2025
aa7c304
progress
psteinroe Sep 20, 2025
1f3ef97
fix: joins
psteinroe Sep 20, 2025
864f7ae
fix: joins
psteinroe Sep 20, 2025
534e057
fix: cleanup GroupStart
psteinroe Sep 20, 2025
82cf149
progress
psteinroe Sep 20, 2025
be311d9
progress
psteinroe Sep 21, 2025
17f44b9
progress
psteinroe Sep 21, 2025
27366cf
progress
psteinroe Sep 22, 2025
74dd155
progress
psteinroe Sep 22, 2025
6c4aea4
progress
psteinroe Sep 22, 2025
8f2d607
progress
psteinroe Sep 23, 2025
b6e36eb
progress
psteinroe Sep 23, 2025
e20198f
progress
psteinroe Sep 23, 2025
1a32873
progress
psteinroe Sep 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run -p xtask --"
78 changes: 78 additions & 0 deletions Cargo.lock
View file Open in desktop

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion Cargo.toml
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
[workspace]
members = ["crates/*", "lib/*", "xtask/codegen", "xtask/rules_check", "docs/codegen"]
members = [
"crates/*",
"lib/*",
"xtask/codegen",
"xtask/rules_check",
"xtask/agentic",
"xtask/download_regression_tests",
"docs/codegen",
]
resolver = "2"

[workspace.package]
Expand All @@ -23,7 +31,9 @@ biome_js_syntax = "0.5.7"
biome_rowan = "0.5.7"
biome_string_case = "0.5.8"
bpaf = { version = "0.9.15", features = ["derive"] }
camino = "1.1.9"
crossbeam = "0.8.4"
dir-test = "0.4.1"
enumflags2 = "0.7.11"
ignore = "0.4.23"
indexmap = { version = "2.6.0", features = ["serde"] }
Expand Down Expand Up @@ -78,6 +88,8 @@ pgt_lexer_codegen = { path = "./crates/pgt_lexer_codegen", version = "0
pgt_lsp = { path = "./crates/pgt_lsp", version = "0.0.0" }
pgt_markup = { path = "./crates/pgt_markup", version = "0.0.0" }
pgt_plpgsql_check = { path = "./crates/pgt_plpgsql_check", version = "0.0.0" }
pgt_pretty_print = { path = "./crates/pgt_pretty_print", version = "0.0.0" }
pgt_pretty_print_codegen = { path = "./crates/pgt_pretty_print_codegen", version = "0.0.0" }
pgt_query = { path = "./crates/pgt_query", version = "0.0.0" }
pgt_query_ext = { path = "./crates/pgt_query_ext", version = "0.0.0" }
pgt_query_macros = { path = "./crates/pgt_query_macros", version = "0.0.0" }
Expand Down
56 changes: 56 additions & 0 deletions STATE.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Pretty Print Formatter State

## Current Phase: Code Quality Improvements - COMPLETED ✅

## Last Completed Work
- Fixed all forbidden patterns in nodes.rs:
- Removed length-based formatting logic (e.g., `if items.len() > 3`)
- Eliminated manual child node parsing patterns (e.g., `if let Some(pgt_query::protobuf::node::Node::List(list))`)
- Enhanced List implementation with context-aware formatting
- Added helper functions for common string formatting patterns
- Cleaned up ObjectOpfamily/ObjectOpclass handling
- Fixed clippy warnings and compilation errors

## Issues Found and Fixed

### 1. Length-based Formatting ✅ FIXED
- **Issue**: Code changing formatting behavior based on list length
- **Locations**: InsertStmt (line 1159), AExprList (line 1258)
- **Solution**: Use consistent formatting with SoftOrSpace, let renderer decide breaks

### 2. Manual Child Node Parsing ✅ FIXED
- **Issue**: Parent nodes manually inspecting child node types instead of calling `to_tokens()`
- **Locations**:
- DropStmt (line 1742)
- RangeFunction (line 2228)
- DefElem instances (lines 3019, 3100, 3172, 3277)
- RenameStmt (line 6314)
- AlterObjectSchemaStmt (line 6489)
- AlterOwnerStmt (line 6581)
- **Solution**: Use `node.to_tokens(e)` and enhanced List context handling

### 3. Code Quality Improvements ✅ FIXED
- Added EventEmitter helper methods for string formatting
- Consolidated identical if blocks in List implementation
- Fixed clippy warnings (collapsible if/else, unused code, etc.)
- Improved ObjectOpfamily/ObjectOpclass logic with cleaner pattern matching

## Architecture Improvements Made
- **Proper separation of concerns**: Parent nodes call `child.to_tokens(e)`
- **Context-aware child formatting**: List node uses EventEmitter context functions
- **Helper functions**: Common string formatting patterns abstracted
- **Consistent patterns**: No hardcoded conditional logic based on lengths or types

## Documentation Updates
- Updated `agentic/pretty_printer.md` with new forbidden patterns
- Added string formatting helper guidance
- Added manual child node parsing prevention rules

## Code Quality Status
- All forbidden patterns eliminated ✅
- Clippy warnings addressed ✅
- Compilation successful ✅
- Architecture follows clean separation of concerns ✅

## Notes for Resumption
This architectural cleanup phase is complete. All forbidden patterns have been eliminated and the codebase now follows proper parent-child delegation patterns with context-aware formatting. The next phase would be to continue with the main formatting task using the improved, clean architecture.
Loading

AltStyle によって変換されたページ (->オリジナル) /