Skip to content

Commit d8cc4c5

Browse files
committed
Address review feedback
1 parent a312617 commit d8cc4c5

33 files changed

+100
-133
lines changed

pkl-core/src/main/java/org/pkl/core/ast/member/ClassProperty.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public ClassProperty(
5454
this.initializer = initializer;
5555
}
5656

57-
/** Returned annotations are ordered from base class to leaf class then from top to bottom */
5857
public List<VmTyped> getAllAnnotations(boolean ascending) {
5958
var annotations = new ArrayList<VmTyped>();
6059

pkl-core/src/main/java/org/pkl/core/runtime/Identifier.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public final class Identifier implements Comparable<Identifier> {
5050
// members of pkl.base#Listing and pkl.base#Mapping
5151
public static final Identifier DEFAULT = get("default");
5252

53-
// members of pkl.base#ValueRenderer subclasses
53+
// members of pkl.base#BaseValueRenderer subclasses
5454
public static final Identifier MODE = get("mode");
5555
public static final Identifier INDENT = get("indent");
5656
public static final Identifier INDENT_WIDTH = get("indentWidth");
@@ -62,9 +62,12 @@ public final class Identifier implements Comparable<Identifier> {
6262
public static final Identifier ROOT_ELEMENT_NAME = get("rootElementName");
6363
public static final Identifier ROOT_ELEMENT_ATTRIBUTES = get("rootElementAttributes");
6464
public static final Identifier CONVERTERS = get("converters");
65-
public static final Identifier ANNOTATION_TRANSFORMERS = get("annotationTransformers");
65+
public static final Identifier CONVERT_PROPERTY_TRANSFORMERS = get("convertPropertyTransformers");
6666
public static final Identifier USE_MAPPING = get("useMapping");
6767

68+
// members of pkl.base#ConvertProperty
69+
public static final Identifier RENDER = get("render");
70+
6871
// members of pkl.base#RegexMatch
6972
public static final Identifier VALUE = get("value");
7073

@@ -144,9 +147,6 @@ public final class Identifier implements Comparable<Identifier> {
144147
// members of pkl.yaml
145148
public static final Identifier MAX_COLLECTION_ALIASES = get("maxCollectionAliases");
146149

147-
// members of pkl.convert
148-
public static final Identifier RENDER = get("render");
149-
150150
// common in lambdas etc
151151
public static final Identifier IT = get("it");
152152

pkl-core/src/main/java/org/pkl/core/runtime/VmFunction.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ public Object apply(Object arg1, Object arg2) {
6464
return getCallTarget().call(thisValue, this, arg1, arg2);
6565
}
6666

67-
// if call site is a node, use ApplyVmFunction3Node.execute() or DirectCallNode.call() instead of
68-
// this method
69-
public Object apply(Object arg1, Object arg2, Object arg3) {
70-
return getCallTarget().call(thisValue, this, arg1, arg2, arg3);
71-
}
72-
7367
public VmFunction copy(
7468
int newParamCount, @Nullable PklRootNode newRootNode, @Nullable Object newExtraStorage) {
7569
return new VmFunction(

pkl-core/src/main/java/org/pkl/core/runtime/VmPklBinaryEncoder.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,6 @@ protected void visitProperty(Identifier name, Object value, boolean isFirst) {
258258
visit(value);
259259
}
260260

261-
@Override
262-
protected void visitPropertyRenderDirective(VmTyped value, boolean isFirst) {
263-
visitRenderDirective(value);
264-
}
265-
266261
@Override
267262
public void visitClass(VmClass value) {
268263
try {

pkl-core/src/main/java/org/pkl/core/stdlib/AbstractRenderer.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ public void visit(Object value) {
163163
/** Visits a property of a {@link VmDynamic} or {@link VmTyped}. */
164164
protected abstract void visitProperty(Identifier name, Object value, boolean isFirst);
165165

166-
/** Perform logic for rendering a render directive in place of a property */
167-
protected abstract void visitPropertyRenderDirective(VmTyped value, boolean isFirst);
168-
169166
protected abstract void endDynamic(VmDynamic value, boolean isEmpty);
170167

171168
protected abstract void endTyped(VmTyped value, boolean isEmpty);
@@ -338,14 +335,14 @@ public final void visitMap(VmMap value) {
338335
private void doVisitProperty(
339336
Identifier name,
340337
Object value,
341-
@Nullable ClassProperty property,
338+
@Nullable ClassProperty classProperty,
342339
SourceSection sourceSection,
343340
MutableBoolean isFirst) {
344341
var prevSourceSection = currSourceSection;
345342
currSourceSection = sourceSection;
346343
currPath.push(name);
347-
if (property != null) {
348-
var propVal = converter.convertProperty(property, value, currPath);
344+
if (classProperty != null) {
345+
var propVal = converter.convertProperty(classProperty, value, currPath);
349346
name = propVal.getFirst();
350347
value = propVal.getSecond();
351348
}

pkl-core/src/main/java/org/pkl/core/stdlib/PklConverter.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
public final class PklConverter implements VmValueConverter<Object> {
2525
private final Map<VmClass, VmFunction> typeConverters;
26-
private final Map<VmClass, VmFunction> annotationTransformers;
26+
private final Map<VmClass, VmFunction> convertPropertyTransformers;
2727
private final Pair<Object[], VmFunction>[] pathConverters;
2828
private final Object rendererOrParser;
2929

@@ -48,13 +48,12 @@ public final class PklConverter implements VmValueConverter<Object> {
4848
private final @Nullable VmFunction typeAliasConverter;
4949

5050
private PklConverter(
51-
VmMapping converters, VmMapping annotationTransformers, Object rendererOrParser) {
52-
// As of 0.18, `converters` is forced by the mapping type check,
53-
// but let's not rely on this implementation detail.
51+
VmMapping converters, VmMapping convertPropertyTransformers, Object rendererOrParser) {
5452
converters.force(false, false);
55-
annotationTransformers.force(false, false);
53+
convertPropertyTransformers.force(false, false);
5654
typeConverters = createTypeConverters(converters);
57-
this.annotationTransformers = createAnnotationTransformers(annotationTransformers);
55+
this.convertPropertyTransformers =
56+
createConvertPropertyTransformers(convertPropertyTransformers);
5857
pathConverters = createPathConverters(converters);
5958
this.rendererOrParser = rendererOrParser;
6059

@@ -84,9 +83,9 @@ private PklConverter(
8483

8584
public static PklConverter fromRenderer(VmTyped renderer) {
8685
var converters = (VmMapping) VmUtils.readMember(renderer, Identifier.CONVERTERS);
87-
var annotationTransformers =
88-
(VmMapping) VmUtils.readMember(renderer, Identifier.ANNOTATION_TRANSFORMERS);
89-
return new PklConverter(converters, annotationTransformers, renderer);
86+
var convertPropertyTransformers =
87+
(VmMapping) VmUtils.readMember(renderer, Identifier.CONVERT_PROPERTY_TRANSFORMERS);
88+
return new PklConverter(converters, convertPropertyTransformers, renderer);
9089
}
9190

9291
public static PklConverter fromParser(VmTyped parser) {
@@ -216,7 +215,7 @@ public Pair<Identifier, Object> convertProperty(
216215
continue;
217216
}
218217

219-
var transformer = findAnnotationTransformer(annotation.getVmClass());
218+
var transformer = findConvertPropertyTransformer(annotation.getVmClass());
220219
if (transformer != null) {
221220
annotation = (VmTyped) transformer.apply(annotation);
222221
}
@@ -241,9 +240,10 @@ private Map<VmClass, VmFunction> createTypeConverters(VmMapping converters) {
241240
return result;
242241
}
243242

244-
private Map<VmClass, VmFunction> createAnnotationTransformers(VmMapping annotationTransformers) {
243+
private Map<VmClass, VmFunction> createConvertPropertyTransformers(
244+
VmMapping convertPropertyTransformers) {
245245
var result = new HashMap<VmClass, VmFunction>();
246-
annotationTransformers.iterateMemberValues(
246+
convertPropertyTransformers.iterateMemberValues(
247247
(key, member, value) -> {
248248
assert value != null; // forced in ctor
249249
result.put((VmClass) key, ((VmFunction) value));
@@ -287,8 +287,8 @@ private Pair<Object[], VmFunction>[] createPathConverters(VmMapping converters)
287287
return findConverterByType(typeConverters, clazz);
288288
}
289289

290-
private @Nullable VmFunction findAnnotationTransformer(VmClass clazz) {
291-
return findConverterByType(annotationTransformers, clazz);
290+
private @Nullable VmFunction findConvertPropertyTransformer(VmClass clazz) {
291+
return findConverterByType(convertPropertyTransformers, clazz);
292292
}
293293

294294
private <T> @Nullable T findConverterByType(Map<VmClass, T> bag, VmClass clazz) {

pkl-core/src/main/java/org/pkl/core/stdlib/base/JsonRendererNodes.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,6 @@ protected void visitProperty(Identifier name, Object value, boolean isFirst) {
233233
visit(value);
234234
}
235235

236-
@Override
237-
protected void visitPropertyRenderDirective(VmTyped value, boolean isFirst) {
238-
if (!isFirst) builder.append(',');
239-
startNewLine();
240-
visitRenderDirective(value);
241-
}
242-
243236
@Override
244237
protected void endDynamic(VmDynamic value, boolean isEmpty) {
245238
if (value.hasElements()) {

pkl-core/src/main/java/org/pkl/core/stdlib/base/PListRendererNodes.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,6 @@ protected void visitProperty(Identifier name, Object value, boolean isFirst) {
279279
builder.append(LINE_BREAK);
280280
}
281281

282-
@Override
283-
protected void visitPropertyRenderDirective(VmTyped value, boolean isFirst) {
284-
if (isFirst) {
285-
builder.append("<dict>").append(LINE_BREAK);
286-
}
287-
builder.append(currIndent);
288-
visitRenderDirective(value);
289-
builder.append(LINE_BREAK);
290-
}
291-
292282
@Override
293283
protected void endDynamic(VmDynamic value, boolean isEmpty) {
294284
if (value.hasElements()) {

pkl-core/src/main/java/org/pkl/core/stdlib/base/PcfRenderer.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,6 @@ protected void visitProperty(Identifier name, Object value, boolean isFirst) {
279279
visit(value);
280280
}
281281

282-
@Override
283-
protected void visitPropertyRenderDirective(VmTyped value, boolean isFirst) {
284-
if (!builder.isEmpty()) {
285-
builder.append('\n');
286-
builder.append(currIndent);
287-
}
288-
visitRenderDirective(value);
289-
}
290-
291282
@Override
292283
protected void endDynamic(VmDynamic value, boolean isEmpty) {
293284
endObject(value, isEmpty);

pkl-core/src/main/java/org/pkl/core/stdlib/base/PropertiesRendererNodes.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,6 @@ protected void visitProperty(Identifier name, Object value, boolean isFirst) {
231231
visitKeyedValue(value);
232232
}
233233

234-
@Override
235-
protected void visitPropertyRenderDirective(VmTyped value, boolean isFirst) {
236-
builder.append(VmUtils.readTextProperty(value));
237-
if (isDocument) {
238-
writeLineBreak();
239-
}
240-
}
241-
242234
@Override
243235
protected void endDynamic(VmDynamic value, boolean isEmpty) {}
244236

0 commit comments

Comments
 (0)