Skip to content

[LQP Meta] Hooks for overriding constant formatting in Julia sdk#210

Merged
nystrom merged 91 commits intomainfrom
nn-meta-13f-formatter
Feb 20, 2026
Merged

[LQP Meta] Hooks for overriding constant formatting in Julia sdk#210
nystrom merged 91 commits intomainfrom
nn-meta-13f-formatter

Conversation

@nystrom
Copy link
Copy Markdown
Contributor

@nystrom nystrom commented Feb 20, 2026

Summary

  • Move the Julia parser and pretty printer into Parser and Pretty submodules of LogicalQueryProtocol, keeping the main module namespace clean
  • Add a ConstantFormatter extension mechanism to the pretty printer, allowing users to customize how constants (decimals, int128, uint128, ints, floats, strings, bools) are formatted
  • Update codegen templates to generate submodules instead of top-level code, and move shared helpers (_has_proto_field, _get_oneof_field) into protobuf-helpers.jl
  • Rename internal Parser struct to ParserState to avoid collision with the new module name
  • Restructure tests to use ReTestItems @testsetup modules in dedicated *_testsetup.jl files (ParserSetup, PrettySetup)

nystrom and others added 16 commits February 19, 2026 12:29
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements an extension mechanism allowing users to customize how constants
(DecimalValue, Int128Value, UInt128Value) are formatted in the pretty printer
without modifying generated code.

Changes:
- Added abstract ConstantFormatter type and DEFAULT_CONSTANT_FORMATTER singleton
- Updated PrettyPrinter to include constant_formatter field
- Modified format functions to dispatch on formatter type with fallback methods
- Added backward-compatible convenience methods for existing code
- Updated pprint/pretty APIs to accept optional constant_formatter parameter
- Exported ConstantFormatter types and format functions for user extension
- Added comprehensive test suite (10 test items, 23 assertions)

All 115 existing tests pass, maintaining full backward compatibility.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Base automatically changed from nn-meta-13c-print-debug-info to main February 20, 2026 11:14
# Conflicts:
#	meta/src/meta/templates/pretty_printer.jl.template
#	sdks/julia/LogicalQueryProtocol/src/LogicalQueryProtocol.jl
#	sdks/julia/LogicalQueryProtocol/src/pretty.jl
@nystrom nystrom marked this pull request as ready for review February 20, 2026 11:19
nystrom and others added 7 commits February 20, 2026 12:26
Extends the ConstantFormatter mechanism to allow customization of all constant
types: int (Int64/Int32), float (Float64), string, and boolean, in addition to
the existing decimal, int128, and uint128 support.

Changes:
- Added format_int, format_float, format_string, format_bool functions with
  formatter dispatch and default implementations
- Updated codegen templates to route all constant formatting through the
  formatter system
- Added comprehensive tests covering individual and combined type overrides
- Exported new format functions for user extension

All constant formatting now goes through the ConstantFormatter abstraction,
enabling complete control over constant representation in the pretty printer.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds comprehensive unit tests verifying the default formatting behavior for
all constant types: int, float, string, bool, decimal, int128, and uint128.

Tests cover:
- Positive, negative, and zero values
- Edge cases (special float values, escaped characters in strings)
- Two's complement representation for int128
- Hexadecimal formatting for uint128

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Restructures LogicalQueryProtocol Julia SDK to organize parser and pretty
printer as separate submodules (Parser and Pretty) under the main module.

Changes:
- Wrapped parser.jl in Parser module, renamed Parser struct to ParserState
- Wrapped pretty.jl in Pretty module
- Updated templates to generate modularized code
- Moved _has_proto_field/_get_oneof_field to protobuf-helpers.jl for sharing
- Updated LogicalQueryProtocol.jl to include and re-export from submodules
- Updated show.jl to qualify Pretty module references
- Updated codegen to use ParserState type annotation
- Exported Proto, parser/pretty functions, and testing helpers

Users can now access:
- LogicalQueryProtocol.Parser.parse or just parse (re-exported)
- LogicalQueryProtocol.Pretty.pprint or just pprint (re-exported)
- Direct submodule access: LogicalQueryProtocol.Parser, LogicalQueryProtocol.Pretty

Tests reduced from 936 errors to 3 (indent_level, indent!, try_flat exports).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Removes all re-exports of Parser and Pretty module methods from the main
LogicalQueryProtocol module. Users should access these directly from the
submodules:

- LogicalQueryProtocol.Parser.parse()
- LogicalQueryProtocol.Pretty.pprint()
- etc.

Only the submodules themselves (Parser, Pretty, Proto) are now exported.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updates test assertions to expect 'parser::ParserState' instead of
'parser::Parser' after renaming the Parser struct to ParserState to
avoid module/struct name collision.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@nystrom nystrom requested a review from comnik February 20, 2026 12:33
@nystrom nystrom merged commit d1f4553 into main Feb 20, 2026
6 checks passed
@nystrom nystrom deleted the nn-meta-13f-formatter branch February 20, 2026 16:10
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