diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/ClassProperty.java b/pkl-core/src/main/java/org/pkl/core/ast/member/ClassProperty.java index d3f602c2..6a2ee637 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/ClassProperty.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/ClassProperty.java @@ -16,6 +16,7 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.source.SourceSection; +import java.util.ArrayList; import java.util.List; import org.pkl.core.Member.SourceLocation; import org.pkl.core.PClass; @@ -67,8 +68,44 @@ public final class ClassProperty extends ClassMember { return name.toString(); } - public VmTyped getMirror() { - return MirrorFactories.propertyFactory.create(this); + public static final class Mirror { + private final ClassProperty prop; + private final VmClass clazz; + + Mirror(ClassProperty prop, VmClass clazz) { + this.prop = prop; + this.clazz = clazz; + } + + public ClassProperty getProperty() { + return prop; + } + + public List getAllAnnotations() { + var annotations = new ArrayList(); + for (var klazz = clazz; klazz != null; klazz = klazz.getSuperclass()) { + var p = klazz.getDeclaredProperty(prop.getName()); + if (p != null) { + annotations.addAll(p.getAnnotations()); + } + } + return annotations; + } + + public VmSet getAllModifierMirrors() { + var mods = 0; + for (var klazz = clazz; klazz != null; klazz = klazz.getSuperclass()) { + var parent = klazz.getDeclaredProperty(prop.getName()); + if (parent != null) { + mods |= parent.getModifiers(); + } + } + return VmModifier.getMirrors(mods, false); + } + } + + public VmTyped getMirror(VmClass clazz) { + return MirrorFactories.propertyFactory.create(new Mirror(this, clazz)); } public VmSet getModifierMirrors() { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/MirrorFactories.java b/pkl-core/src/main/java/org/pkl/core/runtime/MirrorFactories.java index 52bc2905..093abd26 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/MirrorFactories.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/MirrorFactories.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public final class MirrorFactories { public static final VmObjectFactory typeAliasFactory = new VmObjectFactory<>(ReflectModule::getTypeAliasClass); - public static final VmObjectFactory propertyFactory = + public static final VmObjectFactory propertyFactory = new VmObjectFactory<>(ReflectModule::getPropertyClass); public static final VmObjectFactory methodFactory = @@ -146,8 +146,10 @@ public final class MirrorFactories { .addProperty("superclass", VmClass::getSuperclassMirror) .addProperty("supertype", VmClass::getSupertypeMirror) .addMapProperty("properties", VmClass::getPropertyMirrors) + .addMapProperty("allProperties", VmClass::getAllPropertyMirrors) .addTypedProperty("enclosingDeclaration", VmClass::getModuleMirror) - .addMapProperty("methods", VmClass::getMethodMirrors); + .addMapProperty("methods", VmClass::getMethodMirrors) + .addMapProperty("allMethods", VmClass::getAllMethodMirrors); typeAliasFactory .addTypedProperty( @@ -164,24 +166,30 @@ public final class MirrorFactories { propertyFactory .addTypedProperty( - "location", property -> sourceLocationFactory.create(property.getHeaderSection())) + "location", + property -> sourceLocationFactory.create(property.getProperty().getHeaderSection())) .addProperty( "docComment", - property -> VmNull.lift(VmUtils.exportDocComment(property.getDocComment()))) - .addListProperty("annotations", property -> VmList.create(property.getAnnotations())) - .addSetProperty("modifiers", ClassProperty::getModifierMirrors) - .addStringProperty("name", property -> property.getName().toString()) - .addTypedProperty("type", ClassProperty::getTypeMirror) + property -> + VmNull.lift(VmUtils.exportDocComment(property.getProperty().getDocComment()))) + .addListProperty( + "annotations", property -> VmList.create(property.getProperty().getAnnotations())) + .addListProperty("allAnnotations", property -> VmList.create(property.getAllAnnotations())) + .addSetProperty("modifiers", property -> property.getProperty().getModifierMirrors()) + .addSetProperty("allModifiers", ClassProperty.Mirror::getAllModifierMirrors) + .addStringProperty("name", property -> property.getProperty().getName().toString()) + .addTypedProperty("type", property -> property.getProperty().getTypeMirror()) .addProperty( "defaultValue", property -> - property.isAbstract() - || property.isExternal() - || property.getInitializer().isUndefined() + property.getProperty().isAbstract() + || property.getProperty().isExternal() + || property.getProperty().getInitializer().isUndefined() ? VmNull.withoutDefault() : // get default from prototype because it's cached there - VmUtils.readMember(property.getOwner(), property.getName())); + VmUtils.readMember( + property.getProperty().getOwner(), property.getProperty().getName())); methodFactory .addTypedProperty( diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmClass.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmClass.java index c693267c..08d44f50 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmClass.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmClass.java @@ -575,7 +575,16 @@ public final class VmClass extends VmValue { var builder = VmMap.builder(); for (var property : declaredProperties.getValues()) { if (property.isLocal()) continue; - builder.add(property.getName().toString(), property.getMirror()); + builder.add(property.getName().toString(), property.getMirror(this)); + } + return builder.build(); + } + + public VmMap getAllPropertyMirrors() { + var builder = VmMap.builder(); + for (var property : getAllProperties().getValues()) { + if (property.isLocal()) continue; + builder.add(property.getName().toString(), property.getMirror(this)); } return builder.build(); } @@ -589,6 +598,15 @@ public final class VmClass extends VmValue { return builder.build(); } + public VmMap getAllMethodMirrors() { + var builder = VmMap.builder(); + for (var method : getAllMethods().getValues()) { + if (method.isLocal()) continue; + builder.add(method.getName().toString(), method.getMirror()); + } + return builder.build(); + } + @Override @TruffleBoundary public PClass export() { diff --git a/pkl-core/src/test/files/LanguageSnippetTests/input/api/reflect4.pkl b/pkl-core/src/test/files/LanguageSnippetTests/input/api/reflect4.pkl new file mode 100644 index 00000000..e34e3dc5 --- /dev/null +++ b/pkl-core/src/test/files/LanguageSnippetTests/input/api/reflect4.pkl @@ -0,0 +1,88 @@ +amends ".../snippetTest.pkl" + +import "pkl:reflect" + +local class MyAnn extends Annotation + +open local class A { + inheritedFromA: String + overriddenInBFromA: String + overriddenInCFromA: String + overriddenInBCFromA: String + + fixed modA: String = "" + fixed modAOverrideB: String = "" + fixed modAOverrideC: String = "" + fixed modAOverrideBC: String = "" + fixed modAOverrideCB: String = "" + + @Unlisted + annA: String + @Unlisted + annAOverrideB: String + @Unlisted + annAOverrideC: String + @Unlisted + annAOverrideBC: String +} + +open local class B extends A { + inheritedFromB: String + overriddenInBFromA: Int + overriddenInCFromB: String + overriddenInBCFromA: Int + + fixed modB: String = "" + hidden fixed modAOverrideB: Int = 0 + hidden fixed modAOverrideBC: Int = 0 + fixed modAOverrideCB: Int = 0 + + @Unlisted + annB: String + @MyAnn + annAOverrideB: String + @MyAnn + annAOverrideBC: String +} + +local class C extends B { + fromC: String + overriddenInCFromA: Int + overriddenInCFromB: Int + overriddenInBCFromA: Boolean + + fixed modC: String = "" + hidden fixed modAOverrideC: Int = 0 + fixed modAOverrideBC: Boolean = false + hidden fixed modAOverrideCB: Boolean = false + + @Unlisted + annC: String + @MyAnn + annAOverrideC: String + @AlsoKnownAs { names { "mergedAnnotations" } } + annAOverrideBC: String +} + +local class DisplayProperty { + hidden property: reflect.Property + fixed name = property.name + fixed annotations = property.annotations.map((it) -> it.toString()).toListing() + fixed allAnnotations = property.allAnnotations.map((it) -> it.toString()).toListing() + fixed modifiers = property.modifiers.toListing() + fixed allModifiers = property.allModifiers.toListing() + fixed type = property.type.getPropertyOrNull("referent")?.getPropertyOrNull("name") ?? "unknown" +} + +examples { + ["C"] { + reflect.Class(C).allProperties.mapValues((_, it) -> new DisplayProperty { property = it }).toMapping() + } + ["module"] { + new DisplayProperty { property = reflect.Class(module.getClass()).properties["output"] } + } +} + +output { // override to test example "module", allModifiers should contain "hidden" + text = super.text + "\n// hello world" +} diff --git a/pkl-core/src/test/files/LanguageSnippetTests/output/api/reflect4.pcf b/pkl-core/src/test/files/LanguageSnippetTests/output/api/reflect4.pcf new file mode 100644 index 00000000..94ce1d7c --- /dev/null +++ b/pkl-core/src/test/files/LanguageSnippetTests/output/api/reflect4.pcf @@ -0,0 +1,243 @@ +examples { + ["C"] { + new { + ["inheritedFromA"] { + name = "inheritedFromA" + annotations {} + allAnnotations {} + modifiers {} + allModifiers {} + type = "String" + } + ["overriddenInBFromA"] { + name = "overriddenInBFromA" + annotations {} + allAnnotations {} + modifiers {} + allModifiers {} + type = "Int" + } + ["overriddenInCFromA"] { + name = "overriddenInCFromA" + annotations {} + allAnnotations {} + modifiers {} + allModifiers {} + type = "Int" + } + ["overriddenInBCFromA"] { + name = "overriddenInBCFromA" + annotations {} + allAnnotations {} + modifiers {} + allModifiers {} + type = "Boolean" + } + ["modA"] { + name = "modA" + annotations {} + allAnnotations {} + modifiers { + "fixed" + } + allModifiers { + "fixed" + } + type = "String" + } + ["modAOverrideB"] { + name = "modAOverrideB" + annotations {} + allAnnotations {} + modifiers { + "hidden" + "fixed" + } + allModifiers { + "hidden" + "fixed" + } + type = "Int" + } + ["modAOverrideC"] { + name = "modAOverrideC" + annotations {} + allAnnotations {} + modifiers { + "hidden" + "fixed" + } + allModifiers { + "hidden" + "fixed" + } + type = "Int" + } + ["modAOverrideBC"] { + name = "modAOverrideBC" + annotations {} + allAnnotations {} + modifiers { + "fixed" + } + allModifiers { + "hidden" + "fixed" + } + type = "Boolean" + } + ["modAOverrideCB"] { + name = "modAOverrideCB" + annotations {} + allAnnotations {} + modifiers { + "hidden" + "fixed" + } + allModifiers { + "hidden" + "fixed" + } + type = "Boolean" + } + ["annA"] { + name = "annA" + annotations { + "new Unlisted {}" + } + allAnnotations { + "new Unlisted {}" + } + modifiers {} + allModifiers {} + type = "String" + } + ["annAOverrideB"] { + name = "annAOverrideB" + annotations { + "new MyAnn {}" + } + allAnnotations { + "new MyAnn {}" + "new Unlisted {}" + } + modifiers {} + allModifiers {} + type = "String" + } + ["annAOverrideC"] { + name = "annAOverrideC" + annotations { + "new MyAnn {}" + } + allAnnotations { + "new MyAnn {}" + "new Unlisted {}" + } + modifiers {} + allModifiers {} + type = "String" + } + ["annAOverrideBC"] { + name = "annAOverrideBC" + annotations { + "new AlsoKnownAs { names { \"mergedAnnotations\" } }" + } + allAnnotations { + "new AlsoKnownAs { names { \"mergedAnnotations\" } }" + "new MyAnn {}" + "new Unlisted {}" + } + modifiers {} + allModifiers {} + type = "String" + } + ["inheritedFromB"] { + name = "inheritedFromB" + annotations {} + allAnnotations {} + modifiers {} + allModifiers {} + type = "String" + } + ["overriddenInCFromB"] { + name = "overriddenInCFromB" + annotations {} + allAnnotations {} + modifiers {} + allModifiers {} + type = "Int" + } + ["modB"] { + name = "modB" + annotations {} + allAnnotations {} + modifiers { + "fixed" + } + allModifiers { + "fixed" + } + type = "String" + } + ["annB"] { + name = "annB" + annotations { + "new Unlisted {}" + } + allAnnotations { + "new Unlisted {}" + } + modifiers {} + allModifiers {} + type = "String" + } + ["fromC"] { + name = "fromC" + annotations {} + allAnnotations {} + modifiers {} + allModifiers {} + type = "String" + } + ["modC"] { + name = "modC" + annotations {} + allAnnotations {} + modifiers { + "fixed" + } + allModifiers { + "fixed" + } + type = "String" + } + ["annC"] { + name = "annC" + annotations { + "new Unlisted {}" + } + allAnnotations { + "new Unlisted {}" + } + modifiers {} + allModifiers {} + type = "String" + } + } + } + ["module"] { + new { + name = "output" + annotations {} + allAnnotations {} + modifiers {} + allModifiers { + "hidden" + } + type = "unknown" + } + } +} + +// hello world \ No newline at end of file diff --git a/pkl-core/src/test/files/LanguageSnippetTests/output/api/reflectedDeclaration.pcf b/pkl-core/src/test/files/LanguageSnippetTests/output/api/reflectedDeclaration.pcf index 0d2ebfca..1096b081 100644 --- a/pkl-core/src/test/files/LanguageSnippetTests/output/api/reflectedDeclaration.pcf +++ b/pkl-core/src/test/files/LanguageSnippetTests/output/api/reflectedDeclaration.pcf @@ -62,6 +62,7 @@ alias { superclass = null supertype = null properties = Map() + allProperties = Map() methods = Map("getClass", new { location { line = 45 @@ -112,6 +113,56 @@ alias { name = "transform" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } supertype { referent { @@ -145,6 +196,7 @@ alias { superclass = null supertype = null properties = Map() + allProperties = Map() methods = Map("getClass", new { location { line = 45 @@ -195,10 +247,61 @@ alias { name = "transform" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } typeArguments = List() } properties = Map() + allProperties = Map() methods = Map("xor", new { location { line = 1070 @@ -250,6 +353,106 @@ alias { name = "other" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }, "xor", new { + location { + line = 1070 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1070" + } + docComment = """ + Tells if exactly one of [this] and [other] is [true] (exclusive or). + + Facts: + ``` + !true.xor(true) + true.xor(false) + false.xor(true) + !false.xor(false) + ``` + """ + annotations = List() + modifiers = Set() + name = "xor" + typeParameters = List() + parameters = Map("other", new { + name = "other" + }) + }, "implies", new { + location { + line = 1083 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1083" + } + docComment = """ + Tells if [this] implies [other] (logical consequence). + + *Note*: This function does not short-circuit; [other] is always evaluated. + + Facts: + ``` + true.implies(true) + !true.implies(false) + false.implies(true) + false.implies(false) + ``` + """ + annotations = List() + modifiers = Set() + name = "implies" + typeParameters = List() + parameters = Map("other", new { + name = "other" + }) + }) } typeArguments = List() }, new { @@ -303,6 +506,7 @@ alias { superclass = null supertype = null properties = Map() + allProperties = Map() methods = Map("getClass", new { location { line = 45 @@ -353,6 +557,56 @@ alias { name = "transform" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } supertype { referent { @@ -386,6 +640,7 @@ alias { superclass = null supertype = null properties = Map() + allProperties = Map() methods = Map("getClass", new { location { line = 45 @@ -436,6 +691,56 @@ alias { name = "transform" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } typeArguments = List() } @@ -464,6 +769,13 @@ alias { }) modifiers = Set() name = "length" + allModifiers = Set() + allAnnotations = List(new { + names { + "size" + "count" + } + }) }, "lastIndex", new { location { line = 1120 @@ -486,6 +798,8 @@ alias { annotations = List() modifiers = Set() name = "lastIndex" + allModifiers = Set() + allAnnotations = List() }, "isEmpty", new { location { line = 1130 @@ -505,6 +819,8 @@ alias { annotations = List() modifiers = Set() name = "isEmpty" + allModifiers = Set() + allAnnotations = List() }, "isBlank", new { location { line = 1141 @@ -525,6 +841,8 @@ alias { annotations = List() modifiers = Set() name = "isBlank" + allModifiers = Set() + allAnnotations = List() }, "isRegex", new { location { line = 1144 @@ -535,6 +853,8 @@ alias { annotations = List() modifiers = Set() name = "isRegex" + allModifiers = Set() + allAnnotations = List() }, "isBase64", new { location { line = 1154 @@ -555,6 +875,10 @@ alias { }) modifiers = Set() name = "isBase64" + allModifiers = Set() + allAnnotations = List(new { + version = "0.29.0" + }) }, "md5", new { location { line = 1161 @@ -571,6 +895,8 @@ alias { annotations = List() modifiers = Set() name = "md5" + allModifiers = Set() + allAnnotations = List() }, "sha1", new { location { line = 1167 @@ -586,6 +912,8 @@ alias { annotations = List() modifiers = Set() name = "sha1" + allModifiers = Set() + allAnnotations = List() }, "sha256", new { location { line = 1172 @@ -600,6 +928,8 @@ alias { annotations = List() modifiers = Set() name = "sha256" + allModifiers = Set() + allAnnotations = List() }, "sha256Int", new { location { line = 1176 @@ -613,6 +943,8 @@ alias { annotations = List() modifiers = Set() name = "sha256Int" + allModifiers = Set() + allAnnotations = List() }, "base64", new { location { line = 1179 @@ -623,6 +955,8 @@ alias { annotations = List() modifiers = Set() name = "base64" + allModifiers = Set() + allAnnotations = List() }, "base64Decoded", new { location { line = 1187 @@ -640,6 +974,8 @@ alias { annotations = List() modifiers = Set() name = "base64Decoded" + allModifiers = Set() + allAnnotations = List() }, "base64DecodedBytes", new { location { line = 1196 @@ -659,6 +995,10 @@ alias { }) modifiers = Set() name = "base64DecodedBytes" + allModifiers = Set() + allAnnotations = List(new { + version = "0.29.0" + }) }, "chars", new { location { line = 1204 @@ -676,6 +1016,8 @@ alias { annotations = List() modifiers = Set() name = "chars" + allModifiers = Set() + allAnnotations = List() }, "codePoints", new { location { line = 1212 @@ -693,6 +1035,302 @@ alias { annotations = List() modifiers = Set() name = "codePoints" + allModifiers = Set() + allAnnotations = List() + }) + allProperties = Map("length", new { + location { + line = 1107 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1107" + } + docComment = """ + The number of characters in this string. + + *Note*: The runtime complexity of this operation is `O(n)`. + + Facts: + ``` + "".length == 0 + "abc".length == 3 + ``` + """ + annotations = List(new { + names { + "size" + "count" + } + }) + modifiers = Set() + name = "length" + allModifiers = Set() + allAnnotations = List(new { + names { + "size" + "count" + } + }) + }, "lastIndex", new { + location { + line = 1120 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1120" + } + docComment = """ + The index of the last character in this string (same as `length - 1`). + + Returns `-1` for an empty string. + + *Note*: The runtime complexity of this operation is `O(n)`. + + Facts: + ``` + "".lastIndex == -1 + "abc".lastIndex == 2 + ``` + """ + annotations = List() + modifiers = Set() + name = "lastIndex" + allModifiers = Set() + allAnnotations = List() + }, "isEmpty", new { + location { + line = 1130 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1130" + } + docComment = """ + Tells whether this string is empty. + + Facts: + ``` + "".isEmpty + !(" ".isEmpty) + !("abc".isEmpty) + ``` + """ + annotations = List() + modifiers = Set() + name = "isEmpty" + allModifiers = Set() + allAnnotations = List() + }, "isBlank", new { + location { + line = 1141 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1141" + } + docComment = """ + Tells if all characters in this string have Unicode property "White_Space". + + Facts: + ``` + "".isBlank + " ".isBlank + "\\t\\n\\r".isBlank + !("abc".isBlank) + ``` + """ + annotations = List() + modifiers = Set() + name = "isBlank" + allModifiers = Set() + allAnnotations = List() + }, "isRegex", new { + location { + line = 1144 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1144" + } + docComment = "Tells if this string is a valid regular expression according to [Regex]." + annotations = List() + modifiers = Set() + name = "isRegex" + allModifiers = Set() + allAnnotations = List() + }, "isBase64", new { + location { + line = 1154 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1154" + } + docComment = """ + Tells if this is a valid base64-encoded string. + + Facts: + ``` + "AQIDBA==".isBase64 + !"hello there".isBase64 + ``` + """ + annotations = List(new { + version = "0.29.0" + }) + modifiers = Set() + name = "isBase64" + allModifiers = Set() + allAnnotations = List(new { + version = "0.29.0" + }) + }, "md5", new { + location { + line = 1161 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1161" + } + docComment = """ + The [MD5](https://en.wikipedia.org/wiki/MD5) + hash of this string's UTF-8 byte sequence + as hexadecimal string. + + MD5 is cryptographically broken and should not be used for secure applications. + """ + annotations = List() + modifiers = Set() + name = "md5" + allModifiers = Set() + allAnnotations = List() + }, "sha1", new { + location { + line = 1167 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1167" + } + docComment = """ + The [SHA-1](https://en.wikipedia.org/wiki/SHA-1) + hash of this string's UTF-8 byte sequence. + + SHA-1 is cryptographically broken and should not be used for secure applications. + """ + annotations = List() + modifiers = Set() + name = "sha1" + allModifiers = Set() + allAnnotations = List() + }, "sha256", new { + location { + line = 1172 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1172" + } + docComment = """ + The [SHA-256](https://en.wikipedia.org/wiki/SHA-2) + cryptographic hash of this string's UTF-8 byte sequence + as hexadecimal string. + """ + annotations = List() + modifiers = Set() + name = "sha256" + allModifiers = Set() + allAnnotations = List() + }, "sha256Int", new { + location { + line = 1176 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1176" + } + docComment = """ + The first 64 bits of the [SHA-256](https://en.wikipedia.org/wiki/SHA-2) + cryptographic hash of this string's UTF-8 byte sequence. + """ + annotations = List() + modifiers = Set() + name = "sha256Int" + allModifiers = Set() + allAnnotations = List() + }, "base64", new { + location { + line = 1179 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1179" + } + docComment = "The Base64 encoding of this string's UTF-8 byte sequence." + annotations = List() + modifiers = Set() + name = "base64" + allModifiers = Set() + allAnnotations = List() + }, "base64Decoded", new { + location { + line = 1187 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1187" + } + docComment = """ + The inverse of [base64]. + + Facts: + ``` + "abc".base64.base64Decoded == "abc" + ``` + """ + annotations = List() + modifiers = Set() + name = "base64Decoded" + allModifiers = Set() + allAnnotations = List() + }, "base64DecodedBytes", new { + location { + line = 1196 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1196" + } + docComment = """ + Converts this base64-format string into [Bytes]. + + Facts: + ``` + "AQIDBA==".base64DecodedBytes = Bytes(1, 2, 3, 4) + ``` + """ + annotations = List(new { + version = "0.29.0" + }) + modifiers = Set() + name = "base64DecodedBytes" + allModifiers = Set() + allAnnotations = List(new { + version = "0.29.0" + }) + }, "chars", new { + location { + line = 1204 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1204" + } + docComment = """ + The Unicode characters in this string. + + Facts: + ``` + "abc".chars == List("a", "b", "c") + ``` + """ + annotations = List() + modifiers = Set() + name = "chars" + allModifiers = Set() + allAnnotations = List() + }, "codePoints", new { + location { + line = 1212 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1212" + } + docComment = """ + The Unicode code points in this string. + + Facts: + ``` + "abc".codePoints == List(0x61, 0x62, 0x63) + ``` + """ + annotations = List() + modifiers = Set() + name = "codePoints" + allModifiers = Set() + allAnnotations = List() }) methods = Map("getOrNull", new { location { @@ -1575,6 +2213,936 @@ alias { name = "charset" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }, "getOrNull", new { + location { + line = 1224 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1224" + } + docComment = """ + Returns the character at [index], or [null] if [index] is out of range. + + Facts: + ``` + "abcde".getOrNull(-1) == null + "abcde".getOrNull(0) == "a" + "abcde".getOrNull(2) == "c" + "abcde".getOrNull(4) == "e" + "abcde".getOrNull(5) == null + ``` + """ + annotations = List() + modifiers = Set() + name = "getOrNull" + typeParameters = List() + parameters = Map("index", new { + name = "index" + }) + }, "substring", new { + location { + line = 1238 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1238" + } + docComment = """ + Returns the substring from [start] until [exclusiveEnd]. + + Throws if [start] is outside range `0`..[length] or [exclusiveEnd] is outside range [start]..[length]. + + Facts: + ``` + "abcde".substring(0, 0) == "" + "abcde".substring(0, 1) == "a" + "abcde".substring(1, 4) == "bcd" + "abcde".substring(4, 5) == "e" + "abcde".substring(5, 5) == "" + ``` + """ + annotations = List() + modifiers = Set() + name = "substring" + typeParameters = List() + parameters = Map("start", new { + name = "start" + }, "exclusiveEnd", new { + name = "exclusiveEnd" + }) + }, "substringOrNull", new { + location { + line = 1256 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1256" + } + docComment = """ + Returns the substring from [start] until [exclusiveEnd]. + + Returns [null] if [start] is outside range `0`..[length] or [exclusiveEnd] is outside range [start]..[length]. + + Facts: + ``` + "abcde".substringOrNull(0, 0) == "" + "abcde".substringOrNull(0, 1) == "a" + "abcde".substringOrNull(1, 4) == "bcd" + "abcde".substringOrNull(4, 5) == "e" + "abcde".substringOrNull(5, 5) == "" + + "abcde".substringOrNull(-1, 3) == null + "abcde".substringOrNull(0, 6) == null + "abcde".substringOrNull(3, 2) == null + ``` + """ + annotations = List() + modifiers = Set() + name = "substringOrNull" + typeParameters = List() + parameters = Map("start", new { + name = "start" + }, "exclusiveEnd", new { + name = "exclusiveEnd" + }) + }, "repeat", new { + location { + line = 1266 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1266" + } + docComment = """ + Concatenates [count] copies of this string. + + Facts: + ``` + "abc".repeat(0) == "" + "abc".repeat(1) == "abc" + "abc".repeat(3) == "abcabcabc" + ``` + """ + annotations = List() + modifiers = Set() + name = "repeat" + typeParameters = List() + parameters = Map("count", new { + name = "count" + }) + }, "contains", new { + location { + line = 1269 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1269" + } + docComment = "Tells whether this string contains [pattern]." + annotations = List() + modifiers = Set() + name = "contains" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }) + }, "matches", new { + location { + line = 1273 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1273" + } + docComment = "Tells whether this string matches [regex] in its entirety." + annotations = List(new { + names { + "test" + } + }) + modifiers = Set() + name = "matches" + typeParameters = List() + parameters = Map("regex", new { + name = "regex" + }) + }, "startsWith", new { + location { + line = 1276 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1276" + } + docComment = "Tells whether this string starts with [pattern]." + annotations = List() + modifiers = Set() + name = "startsWith" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }) + }, "endsWith", new { + location { + line = 1279 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1279" + } + docComment = "Tells whether this string ends with [pattern]." + annotations = List() + modifiers = Set() + name = "endsWith" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }) + }, "indexOf", new { + location { + line = 1285 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1285" + } + docComment = """ + Returns the zero-based index of the first occurrence of [pattern] + in this string. + + Throws if [pattern] does not occur in this string. + """ + annotations = List() + modifiers = Set() + name = "indexOf" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }) + }, "indexOfOrNull", new { + location { + line = 1289 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1289" + } + docComment = """ + Returns the zero-based index of the first occurrence of [pattern] + in this string, or [null] if [pattern] does not occur in this string. + """ + annotations = List() + modifiers = Set() + name = "indexOfOrNull" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }) + }, "lastIndexOf", new { + location { + line = 1295 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1295" + } + docComment = """ + Returns the zero-based index of the last occurrence of [pattern] + in this string. + + Throws if [pattern] does not occur in this string. + """ + annotations = List() + modifiers = Set() + name = "lastIndexOf" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }) + }, "lastIndexOfOrNull", new { + location { + line = 1299 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1299" + } + docComment = """ + Returns the zero-based index of the last occurrence of [pattern] + in this string, or [null] if [pattern] does not occur in this string. + """ + annotations = List() + modifiers = Set() + name = "lastIndexOfOrNull" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }) + }, "take", new { + location { + line = 1305 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1305" + } + docComment = """ + Returns the first [n] characters of this string. + + Returns [this] if [n] is greater than or equal to [length]. + """ + annotations = List(new { + names { + "limit" + } + }) + modifiers = Set() + name = "take" + typeParameters = List() + parameters = Map("n", new { + name = "n" + }) + }, "takeWhile", new { + location { + line = 1308 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1308" + } + docComment = "Returns the longest prefix of this string that satisfies [predicate]." + annotations = List() + modifiers = Set() + name = "takeWhile" + typeParameters = List() + parameters = Map("predicate", new { + name = "predicate" + }) + }, "takeLast", new { + location { + line = 1313 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1313" + } + docComment = """ + Returns the last [n] characters of this string. + + Returns [this] if [n] is greater than or equal to [length]. + """ + annotations = List() + modifiers = Set() + name = "takeLast" + typeParameters = List() + parameters = Map("n", new { + name = "n" + }) + }, "takeLastWhile", new { + location { + line = 1316 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1316" + } + docComment = "Returns the longest suffix of this string that satisfies [predicate]." + annotations = List() + modifiers = Set() + name = "takeLastWhile" + typeParameters = List() + parameters = Map("predicate", new { + name = "predicate" + }) + }, "drop", new { + location { + line = 1322 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1322" + } + docComment = """ + Removes the first [n] characters of this string. + + Returns the empty string if [n] is greater than or equal to [length]. + """ + annotations = List(new { + names { + "skip" + } + }) + modifiers = Set() + name = "drop" + typeParameters = List() + parameters = Map("n", new { + name = "n" + }) + }, "dropWhile", new { + location { + line = 1326 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1326" + } + docComment = "Removes the longest prefix of this string that satisfies [predicate]." + annotations = List(new { + names { + "skipWhile" + } + }) + modifiers = Set() + name = "dropWhile" + typeParameters = List() + parameters = Map("predicate", new { + name = "predicate" + }) + }, "dropLast", new { + location { + line = 1332 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1332" + } + docComment = """ + Removes the last [n] characters of this string. + + Returns the empty string if [n] is greater than or equal to [length]. + """ + annotations = List(new { + names { + "skipLast" + } + }) + modifiers = Set() + name = "dropLast" + typeParameters = List() + parameters = Map("n", new { + name = "n" + }) + }, "dropLastWhile", new { + location { + line = 1336 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1336" + } + docComment = "Removes the longest suffix of this string that satisfies [predicate]." + annotations = List(new { + names { + "skipLastWhile" + } + }) + modifiers = Set() + name = "dropLastWhile" + typeParameters = List() + parameters = Map("predicate", new { + name = "predicate" + }) + }, "replaceFirst", new { + location { + line = 1341 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1341" + } + docComment = """ + Replaces the first occurrence of [pattern] in this string with [replacement]. + + Returns this string unchanged if [pattern] does not occur in this string. + """ + annotations = List() + modifiers = Set() + name = "replaceFirst" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }, "replacement", new { + name = "replacement" + }) + }, "replaceLast", new { + location { + line = 1346 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1346" + } + docComment = """ + Replaces the last occurrence of [pattern] in this string with [replacement]. + + Returns this string unchanged if [pattern] does not occur in this string. + """ + annotations = List() + modifiers = Set() + name = "replaceLast" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }, "replacement", new { + name = "replacement" + }) + }, "replaceAll", new { + location { + line = 1351 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1351" + } + docComment = """ + Replaces all occurrences of [pattern] in this string with [replacement]. + + Returns this string unchanged if [pattern] does not occur in this string. + """ + annotations = List() + modifiers = Set() + name = "replaceAll" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }, "replacement", new { + name = "replacement" + }) + }, "replaceFirstMapped", new { + location { + line = 1356 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1356" + } + docComment = """ + Replaces the first occurrence of [pattern] in this string with the return value of [mapper]. + + Returns this string unchanged if [pattern] does not occur in this string. + """ + annotations = List() + modifiers = Set() + name = "replaceFirstMapped" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }, "mapper", new { + name = "mapper" + }) + }, "replaceLastMapped", new { + location { + line = 1361 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1361" + } + docComment = """ + Replaces the last occurrence of [pattern] in this string with the return value of [mapper]. + + Returns this string unchanged if [pattern] does not occur in this string. + """ + annotations = List() + modifiers = Set() + name = "replaceLastMapped" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }, "mapper", new { + name = "mapper" + }) + }, "replaceAllMapped", new { + location { + line = 1366 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1366" + } + docComment = """ + Replaces all occurrences of [pattern] in this string with the return value of [mapper]. + + Returns this string unchanged if [pattern] does not occur in this string. + """ + annotations = List() + modifiers = Set() + name = "replaceAllMapped" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }, "mapper", new { + name = "mapper" + }) + }, "replaceRange", new { + location { + line = 1371 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1371" + } + docComment = """ + Replaces the characters between [start] and [exclusiveEnd] with [replacement]. + + Inserts [replacement] at index [start] if `start == exclusiveEnd`. + """ + annotations = List() + modifiers = Set() + name = "replaceRange" + typeParameters = List() + parameters = Map("start", new { + name = "start" + }, "exclusiveEnd", new { + name = "exclusiveEnd" + }, "replacement", new { + name = "replacement" + }) + }, "toUpperCase", new { + location { + line = 1374 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1374" + } + docComment = "Performs a locale-independent character-by-character conversion of this string to uppercase." + annotations = List() + modifiers = Set() + name = "toUpperCase" + typeParameters = List() + parameters = Map() + }, "toLowerCase", new { + location { + line = 1377 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1377" + } + docComment = "Performs a locale-independent character-by-character conversion of this string to lowercase." + annotations = List() + modifiers = Set() + name = "toLowerCase" + typeParameters = List() + parameters = Map() + }, "reverse", new { + location { + line = 1380 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1380" + } + docComment = "Reverses the order of characters in this string." + annotations = List() + modifiers = Set() + name = "reverse" + typeParameters = List() + parameters = Map() + }, "trim", new { + location { + line = 1384 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1384" + } + docComment = "Removes any leading and trailing characters with Unicode property \"White_Space\" from this string." + annotations = List(new { + names { + "strip" + } + }) + modifiers = Set() + name = "trim" + typeParameters = List() + parameters = Map() + }, "trimStart", new { + location { + line = 1388 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1388" + } + docComment = "Removes any leading characters with Unicode property \"White_Space\" from this string." + annotations = List(new { + names { + "stripLeft" + "stripStart" + "stripLeading" + "trimLeft" + "trimLeading" + } + }) + modifiers = Set() + name = "trimStart" + typeParameters = List() + parameters = Map() + }, "trimEnd", new { + location { + line = 1392 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1392" + } + docComment = "Removes any trailing characters with Unicode property \"White_Space\" from this string." + annotations = List(new { + names { + "stripRight" + "stripEnd" + "stripTrailing" + "trimRight" + "trimTrailin" + } + }) + modifiers = Set() + name = "trimEnd" + typeParameters = List() + parameters = Map() + }, "padStart", new { + location { + line = 1398 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1398" + } + docComment = """ + Increases the length of this string to [width] by adding leading [char]s. + + Returns this string unchanged if its length is already equal to or greater than [width]. + """ + annotations = List(new { + names { + "padLeft" + } + }) + modifiers = Set() + name = "padStart" + typeParameters = List() + parameters = Map("width", new { + name = "width" + }, "char", new { + name = "char" + }) + }, "padEnd", new { + location { + line = 1404 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1404" + } + docComment = """ + Increases the length of this string to [width] by adding trailing [char]s. + + Returns this string unchanged if its length is already equal to or greater than [width]. + """ + annotations = List(new { + names { + "padRight" + } + }) + modifiers = Set() + name = "padEnd" + typeParameters = List() + parameters = Map("width", new { + name = "width" + }, "char", new { + name = "char" + }) + }, "split", new { + location { + line = 1407 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1407" + } + docComment = "Splits this string around matches of [pattern]." + annotations = List() + modifiers = Set() + name = "split" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }) + }, "splitLimit", new { + location { + line = 1422 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1422" + } + docComment = """ + Splits this string matches of [pattern], up to [limit] substrings. + + Returns a [List] with at most [limit] elements. + If the limit has been reached, the last entry will contain the un-split remainder of this string. + + Facts: + ``` + "a.b.c".splitLimit(".", 2) == List("a", "b.c") + "a.b.c".splitLimit(".", 1) == List("a.b.c") + "a.b.c".splitLimit(".", 50) == List("a", "b", "c") + "a.b:c".splitLimit(Regex("[.:]"), 3) == List("a", "b", "c") + ``` + """ + annotations = List(new { + version = "0.27.0" + }) + modifiers = Set() + name = "splitLimit" + typeParameters = List() + parameters = Map("pattern", new { + name = "pattern" + }, "limit", new { + name = "limit" + }) + }, "capitalize", new { + location { + line = 1432 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1432" + } + docComment = """ + Converts the first character of this string to title case. + + Facts: + ``` + "pigeon".capitalize() == "Pigeon" + "pigeon bird".capitalize() == "Pigeon bird" + "".capitalize() == "" + ``` + """ + annotations = List() + modifiers = Set() + name = "capitalize" + typeParameters = List() + parameters = Map() + }, "decapitalize", new { + location { + line = 1442 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1442" + } + docComment = """ + Converts the first character of this string to lower case. + + Facts: + ``` + "Pigeon".decapitalize() == "pigeon" + "Pigeon Bird".decapitalize() == "pigeon Bird" + "".decapitalize() == "" + ``` + """ + annotations = List() + modifiers = Set() + name = "decapitalize" + typeParameters = List() + parameters = Map() + }, "toInt", new { + location { + line = 1448 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1448" + } + docComment = """ + Parses this string as a signed decimal (base 10) integer. + + Throws if this string cannot be parsed as a signed decimal integer, + or if the integer is too large to fit into [Int]. + """ + annotations = List() + modifiers = Set() + name = "toInt" + typeParameters = List() + parameters = Map() + }, "toIntOrNull", new { + location { + line = 1454 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1454" + } + docComment = """ + Parses this string as a signed decimal (base 10) integer. + + Returns [null] if this string cannot be parsed as a signed decimal integer, + or if the integer is too large to fit into [Int]. + """ + annotations = List() + modifiers = Set() + name = "toIntOrNull" + typeParameters = List() + parameters = Map() + }, "toFloat", new { + location { + line = 1459 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1459" + } + docComment = """ + Parses this string as a floating point number. + + Throws if this string cannot be parsed as a floating point number. + """ + annotations = List() + modifiers = Set() + name = "toFloat" + typeParameters = List() + parameters = Map() + }, "toFloatOrNull", new { + location { + line = 1464 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1464" + } + docComment = """ + Parses this string as a floating point number. + + Returns [null] if this string cannot be parsed as a floating point number. + """ + annotations = List() + modifiers = Set() + name = "toFloatOrNull" + typeParameters = List() + parameters = Map() + }, "toBoolean", new { + location { + line = 1469 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1469" + } + docComment = """ + Parses `"true"` to [true] and `"false"` to [false] (case-insensitive). + + Throws if this string is neither `"true"` nor `"false"` (case-insensitive). + """ + annotations = List() + modifiers = Set() + name = "toBoolean" + typeParameters = List() + parameters = Map() + }, "toBooleanOrNull", new { + location { + line = 1474 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1474" + } + docComment = """ + Parses `"true"` to [true] and `"false"` to [false] (case-insensitive). + + Returns [null] if this string is neither `"true"` nor `"false"` (case-insensitive). + """ + annotations = List() + modifiers = Set() + name = "toBooleanOrNull" + typeParameters = List() + parameters = Map() + }, "encodeToBytes", new { + location { + line = 1483 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1483" + } + docComment = """ + Returns the bytes of this string, encoded using [charset]. + + Facts: + ``` + "Parrot".encodeToBytes("UTF-8") == Bytes(80, 97, 114, 114, 111, 116) + ``` + """ + annotations = List(new { + version = "0.29.0" + }) + modifiers = Set() + name = "encodeToBytes" + typeParameters = List() + parameters = Map("charset", new { + name = "charset" + }) + }) } typeArguments = List() }) @@ -1697,6 +3265,7 @@ rec { superclass = null supertype = null properties = Map() + allProperties = Map() methods = Map("getClass", new { location { line = 45 @@ -1747,6 +3316,56 @@ rec { name = "transform" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } supertype { referent { @@ -1780,6 +3399,7 @@ rec { superclass = null supertype = null properties = Map() + allProperties = Map() methods = Map("getClass", new { location { line = 45 @@ -1830,11 +3450,112 @@ rec { name = "transform" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } typeArguments = List() } properties = Map() + allProperties = Map() methods = Map() + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } supertype { referent { @@ -1927,6 +3648,7 @@ rec { superclass = null supertype = null properties = Map() + allProperties = Map() methods = Map("getClass", new { location { line = 45 @@ -1977,6 +3699,56 @@ rec { name = "transform" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } supertype { referent { @@ -2010,6 +3782,7 @@ rec { superclass = null supertype = null properties = Map() + allProperties = Map() methods = Map("getClass", new { location { line = 45 @@ -2060,15 +3833,117 @@ rec { name = "transform" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } typeArguments = List() } properties = Map() + allProperties = Map() methods = Map() + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } typeArguments = List() } properties = Map() + allProperties = Map() methods = Map("hasProperty", new { location { line = 1779 @@ -2144,6 +4019,130 @@ rec { typeParameters = List() parameters = Map() }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }, "hasProperty", new { + location { + line = 1779 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1779" + } + docComment = "Tells if this object has a property with the given [name]." + annotations = List() + modifiers = Set() + name = "hasProperty" + typeParameters = List() + parameters = Map("name", new { + name = "name" + }) + }, "getProperty", new { + location { + line = 1784 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1784" + } + docComment = """ + Returns the value of the property with the given [name]. + + Throws if a property with this name does not exist. + """ + annotations = List() + modifiers = Set() + name = "getProperty" + typeParameters = List() + parameters = Map("name", new { + name = "name" + }) + }, "getPropertyOrNull", new { + location { + line = 1789 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1789" + } + docComment = """ + Returns the value of the property with the given [name]. + + Returns [null] if a property with this name does not exist. + """ + annotations = List() + modifiers = Set() + name = "getPropertyOrNull" + typeParameters = List() + parameters = Map("name", new { + name = "name" + }) + }, "toDynamic", new { + location { + line = 1792 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1792" + } + docComment = "Converts this object to a [Dynamic] object." + annotations = List() + modifiers = Set() + name = "toDynamic" + typeParameters = List() + parameters = Map() + }, "toMap", new { + location { + line = 1795 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1795" + } + docComment = "Converts this object to a [Map]." + annotations = List() + modifiers = Set() + name = "toMap" + typeParameters = List() + parameters = Map() + }) } supertype { referent { @@ -2251,6 +4250,7 @@ rec { superclass = null supertype = null properties = Map() + allProperties = Map() methods = Map("getClass", new { location { line = 45 @@ -2301,6 +4301,56 @@ rec { name = "transform" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } supertype { referent { @@ -2334,6 +4384,7 @@ rec { superclass = null supertype = null properties = Map() + allProperties = Map() methods = Map("getClass", new { location { line = 45 @@ -2384,11 +4435,112 @@ rec { name = "transform" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } typeArguments = List() } properties = Map() + allProperties = Map() methods = Map() + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } supertype { referent { @@ -2481,6 +4633,7 @@ rec { superclass = null supertype = null properties = Map() + allProperties = Map() methods = Map("getClass", new { location { line = 45 @@ -2531,6 +4684,56 @@ rec { name = "transform" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } supertype { referent { @@ -2564,6 +4767,7 @@ rec { superclass = null supertype = null properties = Map() + allProperties = Map() methods = Map("getClass", new { location { line = 45 @@ -2614,15 +4818,117 @@ rec { name = "transform" }) }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } typeArguments = List() } properties = Map() + allProperties = Map() methods = Map() + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }) } typeArguments = List() } properties = Map() + allProperties = Map() methods = Map("hasProperty", new { location { line = 1779 @@ -2698,6 +5004,130 @@ rec { typeParameters = List() parameters = Map() }) + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L45" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L50" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L55" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }, "hasProperty", new { + location { + line = 1779 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1779" + } + docComment = "Tells if this object has a property with the given [name]." + annotations = List() + modifiers = Set() + name = "hasProperty" + typeParameters = List() + parameters = Map("name", new { + name = "name" + }) + }, "getProperty", new { + location { + line = 1784 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1784" + } + docComment = """ + Returns the value of the property with the given [name]. + + Throws if a property with this name does not exist. + """ + annotations = List() + modifiers = Set() + name = "getProperty" + typeParameters = List() + parameters = Map("name", new { + name = "name" + }) + }, "getPropertyOrNull", new { + location { + line = 1789 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1789" + } + docComment = """ + Returns the value of the property with the given [name]. + + Returns [null] if a property with this name does not exist. + """ + annotations = List() + modifiers = Set() + name = "getPropertyOrNull" + typeParameters = List() + parameters = Map("name", new { + name = "name" + }) + }, "toDynamic", new { + location { + line = 1792 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1792" + } + docComment = "Converts this object to a [Dynamic] object." + annotations = List() + modifiers = Set() + name = "toDynamic" + typeParameters = List() + parameters = Map() + }, "toMap", new { + location { + line = 1795 + column = 3 + displayUri = "https://github.com/apple/pkl/blob/$commitId/stdlib/base.pkl#L1795" + } + docComment = "Converts this object to a [Map]." + annotations = List() + modifiers = Set() + name = "toMap" + typeParameters = List() + parameters = Map() + }) } typeArguments = List() } @@ -2711,8 +5141,147 @@ rec { annotations = List() modifiers = Set() name = "rec" + allModifiers = Set() + allAnnotations = List() + }) + allProperties = Map("rec", new { + location { + line = 6 + column = 3 + displayUri = "file:///$snippetsDir/input/api/reflectedDeclaration.pkl" + } + docComment = null + annotations = List() + modifiers = Set() + name = "rec" + allModifiers = Set() + allAnnotations = List() }) methods = Map() + allMethods = Map("getClass", new { + location { + line = 45 + column = 3 + displayUri = "pkl:base" + } + docComment = "Returns the class of [this]." + annotations = List() + modifiers = Set() + name = "getClass" + typeParameters = List() + parameters = Map() + }, "toString", new { + location { + line = 50 + column = 3 + displayUri = "pkl:base" + } + docComment = """ + Returns a string representation of [this]. + + This method is used to convert the values of string interpolation expressions to strings. + """ + annotations = List() + modifiers = Set() + name = "toString" + typeParameters = List() + parameters = Map() + }, "ifNonNull", new { + location { + line = 55 + column = 3 + displayUri = "pkl:base" + } + docComment = """ + Returns `this |> transform` if [this] is non-null, and [null] otherwise. + + This method is the complement of the `??` operator and the equivalent of an `Option` type's `map` and `flatMap` methods. + """ + annotations = List() + modifiers = Set() + name = "ifNonNull" + typeParameters = List(new { + name = "Result" + variance = null + }) + parameters = Map("transform", new { + name = "transform" + }) + }, "hasProperty", new { + location { + line = 1779 + column = 3 + displayUri = "pkl:base" + } + docComment = "Tells if this object has a property with the given [name]." + annotations = List() + modifiers = Set() + name = "hasProperty" + typeParameters = List() + parameters = Map("name", new { + name = "name" + }) + }, "getProperty", new { + location { + line = 1784 + column = 3 + displayUri = "pkl:base" + } + docComment = """ + Returns the value of the property with the given [name]. + + Throws if a property with this name does not exist. + """ + annotations = List() + modifiers = Set() + name = "getProperty" + typeParameters = List() + parameters = Map("name", new { + name = "name" + }) + }, "getPropertyOrNull", new { + location { + line = 1789 + column = 3 + displayUri = "pkl:base" + } + docComment = """ + Returns the value of the property with the given [name]. + + Returns [null] if a property with this name does not exist. + """ + annotations = List() + modifiers = Set() + name = "getPropertyOrNull" + typeParameters = List() + parameters = Map("name", new { + name = "name" + }) + }, "toDynamic", new { + location { + line = 1792 + column = 3 + displayUri = "pkl:base" + } + docComment = "Converts this object to a [Dynamic] object." + annotations = List() + modifiers = Set() + name = "toDynamic" + typeParameters = List() + parameters = Map() + }, "toMap", new { + location { + line = 1795 + column = 3 + displayUri = "pkl:base" + } + docComment = "Converts this object to a [Map]." + annotations = List() + modifiers = Set() + name = "toMap" + typeParameters = List() + parameters = Map() + }) } typeArguments = List() } diff --git a/stdlib/reflect.pkl b/stdlib/reflect.pkl index 55916706..3b421918 100644 --- a/stdlib/reflect.pkl +++ b/stdlib/reflect.pkl @@ -252,11 +252,19 @@ external class Class extends TypeDeclaration { /// Does not include properties declared in superclasses. properties: Map + /// The properties declared in this class and all superclasses. + @Since { version = "0.30.0" } + allProperties: Map + /// The methods declared in this class. /// /// Does not include methods declared in superclasses. methods: Map + /// The methods declared in this class and all superclasses. + @Since { version = "0.30.0" } + allMethods: Map + /// Tells if this class is a subclass of [other]. /// /// Every class is a subclass of itself. @@ -284,6 +292,16 @@ external class Property extends Declaration { /// /// [null] if this property does not have a default value. hidden defaultValue: Any + + /// The modifiers of this property, merged with any from the containing class's superclasses. + @Since { version = "0.30.0" } + allModifiers: Set + + /// The annotations of this module, appended with any from the containing class's superclasses. + /// + /// Annotations are ordered starting with the current class and walking up the class hierarchy. + @Since { version = "0.30.0" } + allAnnotations: List } /// A method declaration.