This repository was archived by the owner on Apr 14, 2026. It is now read-only.
Centralize import/helper tracking via CodegenContext and add behavior…#7
Merged
mromaszewicz merged 2 commits intomainfrom Feb 8, 2026
Merged
Centralize import/helper tracking via CodegenContext and add behavior…#7mromaszewicz merged 2 commits intomainfrom
mromaszewicz merged 2 commits intomainfrom
Conversation
…al tests for helper templates Replace the scattered ParamUsageTracker and per-phase import collection with a single CodegenContext that all generators share. This eliminates duplicate param tracker creation across client, server, webhook, and callback code paths, and moves import registration, helper tracking, param function tracking, and custom type tracking into one place. Key changes to code generation pipeline: - Add CodegenContext (codegen_context.go) as the centralized tracker for imports, helpers, param functions, and custom type templates - Refactor Generate() in codegen.go into three phases: (1) generate all code sections, (2) render helpers/params/custom types, (3) assemble output — eliminating repeated param/form-helper generation per phase - Remove ParamUsageTracker from paramgen.go; its logic is absorbed by CodegenContext.NeedParam(), GetRequiredParamTemplates(), etc. - Update TypeGenerator to delegate imports and template tracking to ctx - Update GatherOperations, GatherWebhookOperations, and GatherCallbackOperations to accept *CodegenContext instead of *ParamUsageTracker - Move loadCustomType into CodegenContext.loadAndRegisterCustomType so custom type imports are registered directly on the context Add behavioral tests for helper function templates (test/helpers/): - genhelpers/main.go: CLI generator tool that reads ParamHelpersTemplate, MarshalFormHelperTemplate, and ParamTemplates registries, writes .gen.go files with goimports to prune unused imports - 16 generated .gen.go files: helpers, marshal_form, plus style/bind for simple, simple_explode, form, form_explode, label, label_explode, and deepObject - 7 test files (55 tests) covering marshalForm, primitiveToString, BindStringToObject, Date, escape/unescape, and roundtrip style-then-bind for all parameter styles Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
…al tests for helper templates
Replace the scattered ParamUsageTracker and per-phase import collection with a single CodegenContext that all generators share. This eliminates duplicate param tracker creation across client, server, webhook, and callback code paths, and moves import registration, helper tracking, param function tracking, and custom type tracking into one place.
Key changes to code generation pipeline:
Add behavioral tests for helper function templates (test/helpers/):