valast icon indicating copy to clipboard operation
valast copied to clipboard

customtype: add ability to register any custom type

Open bobheadxi opened this issue 1 year ago • 1 comments

This change extends https://github.com/hexops/valast/pull/25 to allow any type to be configured with a custom AST representation, and demonstrates this by migrating the existing time.Time handling to use this - see stdtypes.go for example. The existing time.Time asserts that the functionality remains unchanged.

This is useful for any type in the same situation as time.Time, including type aliases of time.Time

This could be useful for https://github.com/hexops/valast/issues/21 and https://github.com/hexops/valast/issues/11, allowing users to bring their own representations of types, though it currently does not allow you to override types that are already registered.

  • [x] By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.

bobheadxi avatar Jul 24 '24 19:07 bobheadxi

looks great, I only have one minor comment but otherwise happy with that approach. Let me know when you update & want this merged/a new version released.

emidoots avatar Jul 24 '24 21:07 emidoots

ping

keegancsmith avatar Feb 18 '25 10:02 keegancsmith