mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 14:20:35 +01:00
[PR #1333] SPICE-0024: Annotation converters
#1024
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/1333
Author: @HT154
Created: 11/26/2025
Status: 🔄 Open
Base:
main← Head:annotation-converters📝 Commits (3)
08871a2AddAnnotation-based converters274ba33Annotation converters as a separate BaseRenderer property192ed70Add implicit property name converter annotations for built-in renderers📊 Changes
46 files changed (+639 additions, -71 deletions)
View changed files
📝
pkl-core/src/main/java/org/pkl/core/ast/member/ClassProperty.java(+16 -7)📝
pkl-core/src/main/java/org/pkl/core/runtime/Identifier.java(+1 -0)➕
pkl-core/src/main/java/org/pkl/core/runtime/JsonModule.java(+45 -0)📝
pkl-core/src/main/java/org/pkl/core/runtime/JsonnetModule.java(+9 -1)📝
pkl-core/src/main/java/org/pkl/core/runtime/ModuleCache.java(+8 -2)➕
pkl-core/src/main/java/org/pkl/core/runtime/ProtobufModule.java(+45 -0)📝
pkl-core/src/main/java/org/pkl/core/runtime/TestRunner.java(+2 -2)📝
pkl-core/src/main/java/org/pkl/core/runtime/VmClass.java(+2 -2)📝
pkl-core/src/main/java/org/pkl/core/runtime/VmFunction.java(+6 -0)📝
pkl-core/src/main/java/org/pkl/core/runtime/VmPklBinaryEncoder.java(+1 -1)📝
pkl-core/src/main/java/org/pkl/core/runtime/VmValueConverter.java(+5 -0)📝
pkl-core/src/main/java/org/pkl/core/runtime/XmlModule.java(+9 -1)➕
pkl-core/src/main/java/org/pkl/core/runtime/YamlModule.java(+45 -0)📝
pkl-core/src/main/java/org/pkl/core/stdlib/AbstractRenderer.java(+18 -3)📝
pkl-core/src/main/java/org/pkl/core/stdlib/PklConverter.java(+85 -2)📝
pkl-core/src/main/java/org/pkl/core/stdlib/base/JsonRendererNodes.java(+5 -3)📝
pkl-core/src/main/java/org/pkl/core/stdlib/base/PListRendererNodes.java(+1 -3)📝
pkl-core/src/main/java/org/pkl/core/stdlib/base/PcfRendererNodes.java(+6 -4)📝
pkl-core/src/main/java/org/pkl/core/stdlib/base/PropertiesRendererNodes.java(+2 -3)📝
pkl-core/src/main/java/org/pkl/core/stdlib/base/YamlRendererNodes.java(+7 -3)...and 26 more files
📄 Description
This has been banging around in my head for a while and I finally needed to get it out.
This PR adds a new property
BaseValueRenderer#annotationConvertersthat enables defining converters that act on both the property name and value of annotated properties ofTypedvalues.This enables defining declarative key and/or value transformations in cases where neither
Class- nor path-based converters can be applied gracefully. It is also the only way to express transforming the resulting property names inTypedobjects without applying a converter to the entire containing type, which is cumbersome at best.This PR originally overloaded
BaseValueRenderer#convertersfor this purpose. This implementation has been preserved in the first commit in the PR if you wish to compare that to implementation with the new property. A limitation of the previous design is that you can't have both a class and annotation converter for the sameAnnotationsubclass (though this is probably unlikely to be an issue in practice).SPICE: https://github.com/apple/pkl-evolution/pull/26
This also fixes a silly wart in the API for getting class property mirrors.
Resolves #576
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.