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.
Add support for extracting translations from generic struct fields and methods.
The struct field extraction logic is aligned with the function call's extraction logic, and the generic struct handling logic is added.
Redesign
util.ObjectToKey()
helper to support the generic struct use-case.The
funcCallExtractor
targets*ast.CallExpr
, whereas thedefinitionExtractorRunner
*ast.FuncDecl
AST nodes. Using theutil.ObjectToKey()
helper on these two targets returns inconsistent object keys for the same logical AST node.Given a generic struct
used as
resolves to the following object key specification
github.com/vorlif/testdata/debug.func (github.com/vorlif/testdata/debug.GenericStruct[string]).Method(string)
for thefuncCallExtractor
, butgithub.com/vorlif/testdata/debug.func (github.com/vorlif/testdata/debug.GenericStruct[T]).Method(string)
for thedefinitionExtractorRunner
resulting in translation targets not being mappable between different invocations, and omitted from the output.
The change in design introduces a simplified object keying pattern, which relies on symbol names being unique within a package context to generate globally unique keys, allowing more control over the key's format.
The
*ast.CallExpr
and*ast.FuncDecl
type name formatting discrepancy is solved by reformatting the type name string. This simplistic approach is used due to the*types.Signature
type's limited API which doesn't expose higher granularity typing information.