Repository navigation
Replace manual AST type stitching with go/types - #7
Merged
Merged
Conversation
The interface extraction logic manually traversed AST nodes to rebuild
type strings, which missed interface{}, func, chan types and multi-name
parameters. Replace ~110 lines of hand-rolled type formatters with
go/types' TypeString and Scope().Lookup(), simplify packages.Config to
only NeedName|NeedTypes, and remove dead helper functions.
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.
Summary
identName,ellipsisName,selectorExprName,starExprName,arrayTypeName,mapTypeName) withgo/types.TypeString()andScope().Lookup()packages.Configmode fromNeedName|NeedTypes|NeedTypesInfo|NeedSyntaxtoNeedName|NeedTypestoLowerCamelCaseand unreachablelen(interfaces) == 0checkThis fixes several limitations of the manual approach:
interface{},func,chantypesany,uintptr,complex64/128)a, b int) only capturing the first nameTest plan
go build .passesgo vet .passesgo test -v .passes (TestTemplateValidationPipeline— parse, generate_and_go_fix, final_build)