mirror of
https://github.com/apple/pkl.git
synced 2026-05-18 04:46:59 +02:00
Address warning diagnostics (#1395)
This addressess various warning diagnostics throughout the codebase.
This commit is contained in:
+1
-3
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -14,8 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
// https://youtrack.jetbrains.com/issue/KTIJ-19369
|
// https://youtrack.jetbrains.com/issue/KTIJ-19369
|
||||||
@file:Suppress("DSL_SCOPE_VIOLATION")
|
|
||||||
|
|
||||||
import org.jetbrains.gradle.ext.ActionDelegationConfig
|
import org.jetbrains.gradle.ext.ActionDelegationConfig
|
||||||
import org.jetbrains.gradle.ext.ActionDelegationConfig.TestRunner.PLATFORM
|
import org.jetbrains.gradle.ext.ActionDelegationConfig.TestRunner.PLATFORM
|
||||||
import org.jetbrains.gradle.ext.ProjectSettings
|
import org.jetbrains.gradle.ext.ProjectSettings
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import org.pkl.config.java.JavaType;
|
|||||||
import org.pkl.core.ModuleSource;
|
import org.pkl.core.ModuleSource;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings({"unused", "NewClassNamingConvention"})
|
||||||
// the pkl-jvm-examples repo has a similar example
|
// the pkl-jvm-examples repo has a similar example
|
||||||
public class JavaConfigExample {
|
public class JavaConfigExample {
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.pkl.core.PObject;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
// the pkl-jvm-examples repo has a similar example
|
// the pkl-jvm-examples repo has a similar example
|
||||||
@SuppressWarnings({"unchecked", "unused", "ConstantConditions"})
|
@SuppressWarnings({"unchecked", "unused", "ConstantConditions", "NewClassNamingConvention"})
|
||||||
public class CoreEvaluatorExample {
|
public class CoreEvaluatorExample {
|
||||||
@Test
|
@Test
|
||||||
public void usage() {
|
public void usage() {
|
||||||
|
|||||||
@@ -9,12 +9,18 @@ googleJavaFormat = "1.25.2"
|
|||||||
# must not use `+` because used in download URL
|
# must not use `+` because used in download URL
|
||||||
# 23.1.x requires JDK 20+
|
# 23.1.x requires JDK 20+
|
||||||
graalVm = "25.0.0"
|
graalVm = "25.0.0"
|
||||||
|
#noinspection UnusedVersionCatalogEntry
|
||||||
graalVmJdkVersion = "25.0.0"
|
graalVmJdkVersion = "25.0.0"
|
||||||
# slightly hacky but convenient place so we remember to update the checksum
|
# slightly hacky but convenient place so we remember to update the checksum
|
||||||
|
#noinspection UnusedVersionCatalogEntry
|
||||||
graalVmSha256-macos-x64 = "04278cf867d040e29dc71dd7727793f0ea67eb72adce8a35d04b87b57906778d"
|
graalVmSha256-macos-x64 = "04278cf867d040e29dc71dd7727793f0ea67eb72adce8a35d04b87b57906778d"
|
||||||
|
#noinspection UnusedVersionCatalogEntry
|
||||||
graalVmSha256-macos-aarch64 = "c446d5aaeda98660a4c14049d299e9fba72105a007df89f19d27cf3979d37158"
|
graalVmSha256-macos-aarch64 = "c446d5aaeda98660a4c14049d299e9fba72105a007df89f19d27cf3979d37158"
|
||||||
|
#noinspection UnusedVersionCatalogEntry
|
||||||
graalVmSha256-linux-x64 = "1862f2ce97387a303cae4c512cb21baf36fafd2457c3cbbc10d87db94b89d3dd"
|
graalVmSha256-linux-x64 = "1862f2ce97387a303cae4c512cb21baf36fafd2457c3cbbc10d87db94b89d3dd"
|
||||||
|
#noinspection UnusedVersionCatalogEntry
|
||||||
graalVmSha256-linux-aarch64 = "6c3c8b7617006c5d174d9cf7d357ccfb4bae77a4df1294ee28084fcb6eea8921"
|
graalVmSha256-linux-aarch64 = "6c3c8b7617006c5d174d9cf7d357ccfb4bae77a4df1294ee28084fcb6eea8921"
|
||||||
|
#noinspection UnusedVersionCatalogEntry
|
||||||
graalVmSha256-windows-x64 = "33ef1d186b5c1e95465fcc97e637bc26e72d5f2250a8615b9c5d667ed5c17fd0"
|
graalVmSha256-windows-x64 = "33ef1d186b5c1e95465fcc97e637bc26e72d5f2250a8615b9c5d667ed5c17fd0"
|
||||||
ideaExtPlugin = "1.1.9"
|
ideaExtPlugin = "1.1.9"
|
||||||
intellijPlugin = "2.10.1"
|
intellijPlugin = "2.10.1"
|
||||||
@@ -62,6 +68,7 @@ geantyref = { group = "io.leangen.geantyref", name = "geantyref", version.ref =
|
|||||||
graalCompiler = { group = "org.graalvm.compiler", name = "compiler", version.ref = "graalVm" }
|
graalCompiler = { group = "org.graalvm.compiler", name = "compiler", version.ref = "graalVm" }
|
||||||
graalSdk = { group = "org.graalvm.sdk", name = "graal-sdk", version.ref = "graalVm" }
|
graalSdk = { group = "org.graalvm.sdk", name = "graal-sdk", version.ref = "graalVm" }
|
||||||
graalJs = { group = "org.graalvm.js", name = "js", version.ref = "graalVm" }
|
graalJs = { group = "org.graalvm.js", name = "js", version.ref = "graalVm" }
|
||||||
|
#noinspection UnusedVersionCatalogEntry
|
||||||
intellij = { group = "com.jetbrains.intellij.idea", name = "ideaIC", version.ref = "intellij" }
|
intellij = { group = "com.jetbrains.intellij.idea", name = "ideaIC", version.ref = "intellij" }
|
||||||
javaPoet = { group = "com.palantir.javapoet", name = "javapoet", version.ref = "javaPoet" }
|
javaPoet = { group = "com.palantir.javapoet", name = "javapoet", version.ref = "javaPoet" }
|
||||||
javaxInject = { group = "javax.inject", name = "javax.inject", version.ref = "javaxInject" }
|
javaxInject = { group = "javax.inject", name = "javax.inject", version.ref = "javaxInject" }
|
||||||
@@ -75,7 +82,6 @@ junitApi = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.re
|
|||||||
junitEngine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" }
|
junitEngine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" }
|
||||||
junitParams = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "junit" }
|
junitParams = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "junit" }
|
||||||
junitLauncher = { group = "org.junit.platform", name = "junit-platform-launcher", version.ref = "junitPlatform" }
|
junitLauncher = { group = "org.junit.platform", name = "junit-platform-launcher", version.ref = "junitPlatform" }
|
||||||
kotlinCompilerEmbeddable = { group = "org.jetbrains.kotlin", name = "kotlin-compiler-embeddable", version.ref = "kotlin" }
|
|
||||||
kotlinPlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
|
kotlinPlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||||
kotlinPoet = { group = "com.squareup", name = "kotlinpoet", version.ref = "kotlinPoet" }
|
kotlinPoet = { group = "com.squareup", name = "kotlinpoet", version.ref = "kotlinPoet" }
|
||||||
kotlinReflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" }
|
kotlinReflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" }
|
||||||
@@ -84,8 +90,10 @@ kotlinStdLib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", ve
|
|||||||
kotlinxHtml = { group = "org.jetbrains.kotlinx", name = "kotlinx-html-jvm", version.ref = "kotlinxHtml" }
|
kotlinxHtml = { group = "org.jetbrains.kotlinx", name = "kotlinx-html-jvm", version.ref = "kotlinxHtml" }
|
||||||
kotlinxSerializationJson = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerialization" }
|
kotlinxSerializationJson = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerialization" }
|
||||||
kotlinxCoroutinesCore = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
|
kotlinxCoroutinesCore = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
|
||||||
|
#noinspection UnusedVersionCatalogEntry
|
||||||
log4j12Api = { group = "org.apache.logging.log4j", name = "log4j-1.2-api", version.ref = "log4j" }
|
log4j12Api = { group = "org.apache.logging.log4j", name = "log4j-1.2-api", version.ref = "log4j" }
|
||||||
msgpack = { group = "org.msgpack", name = "msgpack-core", version.ref = "msgpack" }
|
msgpack = { group = "org.msgpack", name = "msgpack-core", version.ref = "msgpack" }
|
||||||
|
#noinspection UnusedVersionCatalogEntry
|
||||||
nuValidator = { group = "nu.validator", name = "validator", version.ref = "nuValidator" }
|
nuValidator = { group = "nu.validator", name = "validator", version.ref = "nuValidator" }
|
||||||
# to be replaced with https://github.com/usethesource/capsule or https://github.com/lacuna/bifurcan
|
# to be replaced with https://github.com/usethesource/capsule or https://github.com/lacuna/bifurcan
|
||||||
paguro = { group = "org.organicdesign", name = "Paguro", version.ref = "paguro" }
|
paguro = { group = "org.organicdesign", name = "Paguro", version.ref = "paguro" }
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
package org.pkl.codegen.java
|
package org.pkl.codegen.java
|
||||||
|
|
||||||
import com.palantir.javapoet.*
|
import com.palantir.javapoet.*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -595,10 +595,7 @@ class JavaCodeGeneratorTest {
|
|||||||
assertAll(
|
assertAll(
|
||||||
"toString() returns Pkl name",
|
"toString() returns Pkl name",
|
||||||
javaClass.enumConstants.zip(cases) { enumConstant, (pklName, _) ->
|
javaClass.enumConstants.zip(cases) { enumConstant, (pklName, _) ->
|
||||||
{
|
{ assertThat(enumConstant.toString()).isEqualTo(pklName) }
|
||||||
assertThat(enumConstant.toString()).isEqualTo(pklName)
|
|
||||||
Unit
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -2264,7 +2261,7 @@ class JavaCodeGeneratorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun Map<String, String>.validateContents(
|
private fun Map<String, String>.validateContents(
|
||||||
vararg assertions: kotlin.Pair<String, List<String>>
|
@Suppress("RemoveRedundantQualifierName") vararg assertions: kotlin.Pair<String, List<String>>
|
||||||
) {
|
) {
|
||||||
val files = toMutableMap()
|
val files = toMutableMap()
|
||||||
|
|
||||||
@@ -2289,7 +2286,7 @@ class JavaCodeGeneratorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun JavaCodeGeneratorOptions.generateFiles(
|
private fun JavaCodeGeneratorOptions.generateFiles(
|
||||||
vararg pklModules: kotlin.Pair<String, String>
|
@Suppress("RemoveRedundantQualifierName") vararg pklModules: kotlin.Pair<String, String>
|
||||||
): Map<String, String> =
|
): Map<String, String> =
|
||||||
generateFiles(*pklModules.map { (name, text) -> PklModule(name, text) }.toTypedArray())
|
generateFiles(*pklModules.map { (name, text) -> PklModule(name, text) }.toTypedArray())
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
package org.pkl.codegen.kotlin
|
package org.pkl.codegen.kotlin
|
||||||
|
|
||||||
import com.squareup.kotlinpoet.*
|
import com.squareup.kotlinpoet.*
|
||||||
@@ -66,6 +68,7 @@ class KotlinCodeGenerator(
|
|||||||
private val STRING = String::class.asClassName()
|
private val STRING = String::class.asClassName()
|
||||||
private val ANY_NULL = ANY.copy(nullable = true)
|
private val ANY_NULL = ANY.copy(nullable = true)
|
||||||
private val NOTHING = Nothing::class.asClassName()
|
private val NOTHING = Nothing::class.asClassName()
|
||||||
|
@Suppress("RemoveRedundantQualifierName")
|
||||||
private val KOTLIN_PAIR = kotlin.Pair::class.asClassName()
|
private val KOTLIN_PAIR = kotlin.Pair::class.asClassName()
|
||||||
private val COLLECTION = Collection::class.asClassName()
|
private val COLLECTION = Collection::class.asClassName()
|
||||||
private val LIST = List::class.asClassName()
|
private val LIST = List::class.asClassName()
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -2054,7 +2054,7 @@ class KotlinCodeGeneratorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun Map<String, String>.validateContents(
|
private fun Map<String, String>.validateContents(
|
||||||
vararg assertions: kotlin.Pair<String, List<String>>
|
@Suppress("RemoveRedundantQualifierName") vararg assertions: kotlin.Pair<String, List<String>>
|
||||||
) {
|
) {
|
||||||
val files = toMutableMap()
|
val files = toMutableMap()
|
||||||
|
|
||||||
@@ -2079,7 +2079,7 @@ class KotlinCodeGeneratorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun KotlinCodeGeneratorOptions.generateFiles(
|
private fun KotlinCodeGeneratorOptions.generateFiles(
|
||||||
vararg pklModules: kotlin.Pair<String, String>
|
@Suppress("RemoveRedundantQualifierName") vararg pklModules: kotlin.Pair<String, String>
|
||||||
): Map<String, String> =
|
): Map<String, String> =
|
||||||
generateFiles(*pklModules.map { (name, text) -> PklModule(name, text) }.toTypedArray())
|
generateFiles(*pklModules.map { (name, text) -> PklModule(name, text) }.toTypedArray())
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -23,11 +23,11 @@ import org.pkl.core.SecurityManagers
|
|||||||
|
|
||||||
class CliCommandTest {
|
class CliCommandTest {
|
||||||
|
|
||||||
class CliTest(private val options: CliBaseOptions) : CliCommand(options) {
|
class CliTest(options: CliBaseOptions) : CliCommand(options) {
|
||||||
override fun doRun() = Unit
|
override fun doRun() = Unit
|
||||||
|
|
||||||
val _allowedResources = allowedResources
|
val myAllowedResources = allowedResources
|
||||||
val _allowedModules = allowedModules
|
val myAllowedModules = allowedModules
|
||||||
}
|
}
|
||||||
|
|
||||||
private val cmd =
|
private val cmd =
|
||||||
@@ -57,12 +57,12 @@ class CliCommandTest {
|
|||||||
)
|
)
|
||||||
val opts = cmd.baseOptions.baseOptions(emptyList(), null, true)
|
val opts = cmd.baseOptions.baseOptions(emptyList(), null, true)
|
||||||
val cliTest = CliTest(opts)
|
val cliTest = CliTest(opts)
|
||||||
assertThat(cliTest._allowedModules.map { it.pattern() })
|
assertThat(cliTest.myAllowedModules.map { it.pattern() })
|
||||||
.isEqualTo(
|
.isEqualTo(
|
||||||
SecurityManagers.defaultAllowedModules.map { it.pattern() } +
|
SecurityManagers.defaultAllowedModules.map { it.pattern() } +
|
||||||
listOf("\\Qscheme3:\\E", "\\Qscheme4:\\E", "\\Qscheme+ext:\\E")
|
listOf("\\Qscheme3:\\E", "\\Qscheme4:\\E", "\\Qscheme+ext:\\E")
|
||||||
)
|
)
|
||||||
assertThat(cliTest._allowedResources.map { it.pattern() })
|
assertThat(cliTest.myAllowedResources.map { it.pattern() })
|
||||||
.isEqualTo(
|
.isEqualTo(
|
||||||
SecurityManagers.defaultAllowedResources.map { it.pattern() } +
|
SecurityManagers.defaultAllowedResources.map { it.pattern() } +
|
||||||
listOf("\\Qscheme1:\\E", "\\Qscheme2:\\E", "\\Qscheme+ext:\\E")
|
listOf("\\Qscheme1:\\E", "\\Qscheme2:\\E", "\\Qscheme+ext:\\E")
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -89,6 +89,7 @@ public class JavaTypeTest {
|
|||||||
assertThat(javaType.getType()).isEqualTo(Types.mapOf(String.class, Types.listOf(URI.class)));
|
assertThat(javaType.getType()).isEqualTo(Types.mapOf(String.class, Types.listOf(URI.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"EqualsWithItself", "AssertBetweenInconvertibleTypes"})
|
||||||
@Test
|
@Test
|
||||||
public void sameTypesConstructedInDifferentWaysAreEqual() {
|
public void sameTypesConstructedInDifferentWaysAreEqual() {
|
||||||
var type1 = JavaType.mapOf(JavaType.of(String.class), JavaType.listOf(URI.class));
|
var type1 = JavaType.mapOf(JavaType.of(String.class), JavaType.listOf(URI.class));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -28,46 +28,51 @@ import org.pkl.core.DurationUnit;
|
|||||||
public class ConversionsTest {
|
public class ConversionsTest {
|
||||||
@Test
|
@Test
|
||||||
public void pStringToFile() {
|
public void pStringToFile() {
|
||||||
var file = Conversions.pStringToFile.converter.convert("relative/path", null);
|
var file =
|
||||||
|
Conversions.pStringToFile.converter.convert("relative/path", ValueMapper.preconfigured());
|
||||||
assertThat(file).isEqualTo(new File("relative/path"));
|
assertThat(file).isEqualTo(new File("relative/path"));
|
||||||
|
|
||||||
var file2 = Conversions.pStringToFile.converter.convert("/absolute/path", null);
|
var file2 =
|
||||||
|
Conversions.pStringToFile.converter.convert("/absolute/path", ValueMapper.preconfigured());
|
||||||
assertThat(file2).isEqualTo(new File("/absolute/path"));
|
assertThat(file2).isEqualTo(new File("/absolute/path"));
|
||||||
|
|
||||||
var file3 = Conversions.pStringToFile.converter.convert("", null);
|
var file3 = Conversions.pStringToFile.converter.convert("", ValueMapper.preconfigured());
|
||||||
assertThat(file3).isEqualTo(new File(""));
|
assertThat(file3).isEqualTo(new File(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pStringToPath() {
|
public void pStringToPath() {
|
||||||
var path = Conversions.pStringToPath.converter.convert("relative/path", null);
|
var path =
|
||||||
|
Conversions.pStringToPath.converter.convert("relative/path", ValueMapper.preconfigured());
|
||||||
assertThat(path).isEqualTo(Path.of("relative/path"));
|
assertThat(path).isEqualTo(Path.of("relative/path"));
|
||||||
|
|
||||||
var path2 = Conversions.pStringToPath.converter.convert("/absolute/path", null);
|
var path2 =
|
||||||
|
Conversions.pStringToPath.converter.convert("/absolute/path", ValueMapper.preconfigured());
|
||||||
assertThat(path2).isEqualTo(Path.of("/absolute/path"));
|
assertThat(path2).isEqualTo(Path.of("/absolute/path"));
|
||||||
|
|
||||||
var path3 = Conversions.pStringToPath.converter.convert("", null);
|
var path3 = Conversions.pStringToPath.converter.convert("", ValueMapper.preconfigured());
|
||||||
assertThat(path3).isEqualTo(Path.of(""));
|
assertThat(path3).isEqualTo(Path.of(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pStringToPattern() {
|
public void pStringToPattern() {
|
||||||
var str = "(?i)\\w*";
|
var str = "(?i)\\w*";
|
||||||
var pattern = Conversions.pStringToPattern.converter.convert(str, null);
|
var pattern = Conversions.pStringToPattern.converter.convert(str, ValueMapper.preconfigured());
|
||||||
assertThat(pattern.pattern()).isEqualTo(str);
|
assertThat(pattern.pattern()).isEqualTo(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pRegexToString() {
|
public void pRegexToString() {
|
||||||
var regex = Pattern.compile("(?i)\\w*");
|
var regex = Pattern.compile("(?i)\\w*");
|
||||||
var str = Conversions.pRegexToString.converter.convert(regex, null);
|
var str = Conversions.pRegexToString.converter.convert(regex, ValueMapper.preconfigured());
|
||||||
assertThat(str).isEqualTo("(?i)\\w*");
|
assertThat(str).isEqualTo("(?i)\\w*");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pDurationToDuration() {
|
public void pDurationToDuration() {
|
||||||
var pDuration = new Duration(100, DurationUnit.MINUTES);
|
var pDuration = new Duration(100, DurationUnit.MINUTES);
|
||||||
var duration = Conversions.pDurationToDuration.converter.convert(pDuration, null);
|
var duration =
|
||||||
|
Conversions.pDurationToDuration.converter.convert(pDuration, ValueMapper.preconfigured());
|
||||||
assertThat(duration).isEqualTo(java.time.Duration.of(100, ChronoUnit.MINUTES));
|
assertThat(duration).isEqualTo(java.time.Duration.of(100, ChronoUnit.MINUTES));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -31,7 +31,7 @@ public class PModuleToDataObjectTest {
|
|||||||
|
|
||||||
private static final PModule module =
|
private static final PModule module =
|
||||||
evaluator.evaluate(modulePath("org/pkl/config/java/mapper/PModuleToDataObjectTest.pkl"));
|
evaluator.evaluate(modulePath("org/pkl/config/java/mapper/PModuleToDataObjectTest.pkl"));
|
||||||
PObjectToDataObjectTest.Person pigeon =
|
private final PObjectToDataObjectTest.Person pigeon =
|
||||||
new PObjectToDataObjectTest.Person(
|
new PObjectToDataObjectTest.Person(
|
||||||
"pigeon",
|
"pigeon",
|
||||||
40,
|
40,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -24,6 +24,7 @@ import org.pkl.core.PNull;
|
|||||||
public class PNullToAnyTest {
|
public class PNullToAnyTest {
|
||||||
private static final ValueMapper mapper = ValueMapperBuilder.preconfigured().build();
|
private static final ValueMapper mapper = ValueMapperBuilder.preconfigured().build();
|
||||||
|
|
||||||
|
@SuppressWarnings("DataFlowIssue")
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
// due to Conversions.identities
|
// due to Conversions.identities
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -105,7 +105,8 @@ final class JsonRenderer implements ValueRenderer {
|
|||||||
@Override
|
@Override
|
||||||
public void visitBytes(byte[] value) {
|
public void visitBytes(byte[] value) {
|
||||||
throw new RendererException(
|
throw new RendererException(
|
||||||
String.format("Values of type `Bytes` cannot be rendered as JSON. Value: %s", value));
|
String.format(
|
||||||
|
"Values of type `Bytes` cannot be rendered as JSON. Value: %s", (Object) value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -110,7 +110,8 @@ final class PropertiesRenderer implements ValueRenderer {
|
|||||||
public String convertBytes(byte[] value) {
|
public String convertBytes(byte[] value) {
|
||||||
throw new RendererException(
|
throw new RendererException(
|
||||||
String.format(
|
String.format(
|
||||||
"Values of type `Bytes` cannot be rendered as Properties. Value: %s", value));
|
"Values of type `Bytes` cannot be rendered as Properties. Value: %s",
|
||||||
|
(Object) value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -2449,8 +2449,7 @@ public class AstBuilder extends AbstractAstBuilder<Object> {
|
|||||||
if (dataSizeUnit != null) {
|
if (dataSizeUnit != null) {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
return new ConstantValueNode(
|
return new ConstantValueNode(
|
||||||
sourceSection,
|
sourceSection, new VmDataSize(intLiteralNode.executeInt(null), dataSizeUnit));
|
||||||
new VmDataSize(((IntLiteralNode) receiver).executeInt(null), dataSizeUnit));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2465,8 +2464,7 @@ public class AstBuilder extends AbstractAstBuilder<Object> {
|
|||||||
if (dataSizeUnit != null) {
|
if (dataSizeUnit != null) {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
return new ConstantValueNode(
|
return new ConstantValueNode(
|
||||||
sourceSection,
|
sourceSection, new VmDataSize(floatLiteralNode.executeFloat(null), dataSizeUnit));
|
||||||
new VmDataSize(((FloatLiteralNode) receiver).executeFloat(null), dataSizeUnit));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -100,6 +100,7 @@ public abstract class NotEqualNode extends ExpressionNode {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("JavaExistingMethodCanBeUsed")
|
||||||
protected static boolean isIncompatibleTypes(Object left, Object right) {
|
protected static boolean isIncompatibleTypes(Object left, Object right) {
|
||||||
var leftClass = left.getClass();
|
var leftClass = left.getClass();
|
||||||
var rightClass = right.getClass();
|
var rightClass = right.getClass();
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -67,7 +67,6 @@ public abstract class SpecializedObjectLiteralNode extends ObjectLiteralNode {
|
|||||||
|
|
||||||
// only runs once per VmClass (which often means once per PropertiesLiteralNode)
|
// only runs once per VmClass (which often means once per PropertiesLiteralNode)
|
||||||
// unless an XYZUncached specialization is active
|
// unless an XYZUncached specialization is active
|
||||||
@SuppressWarnings("ExtractMethodRecommender")
|
|
||||||
@TruffleBoundary
|
@TruffleBoundary
|
||||||
@Idempotent
|
@Idempotent
|
||||||
protected boolean checkIsValidTypedAmendment(Object parent) {
|
protected boolean checkIsValidTypedAmendment(Object parent) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -62,7 +62,6 @@ import org.pkl.core.util.ErrorMessages;
|
|||||||
import org.pkl.core.util.GlobResolver;
|
import org.pkl.core.util.GlobResolver;
|
||||||
import org.pkl.core.util.GlobResolver.InvalidGlobPatternException;
|
import org.pkl.core.util.GlobResolver.InvalidGlobPatternException;
|
||||||
import org.pkl.core.util.IoUtils;
|
import org.pkl.core.util.IoUtils;
|
||||||
import org.pkl.core.util.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a list of project directories, prepares artifacts to be published as a package.
|
* Given a list of project directories, prepares artifacts to be published as a package.
|
||||||
@@ -441,7 +440,7 @@ public final class ProjectPackager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable List<ImportsAndReadsParser.Entry> getImportsAndReads(Path pklModulePath) {
|
private List<ImportsAndReadsParser.Entry> getImportsAndReads(Path pklModulePath) {
|
||||||
try {
|
try {
|
||||||
var moduleKey = ModuleKeys.file(pklModulePath);
|
var moduleKey = ModuleKeys.file(pklModulePath);
|
||||||
var resolvedModuleKey = ResolvedModuleKeys.file(moduleKey, moduleKey.getUri(), pklModulePath);
|
var resolvedModuleKey = ResolvedModuleKeys.file(moduleKey, moduleKey.getUri(), pklModulePath);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -63,7 +63,11 @@ final class MinPklVersionChecker {
|
|||||||
if (!Identifier.MIN_PKL_VERSION.toString().equals(prop.getIdentifier().getValue()))
|
if (!Identifier.MIN_PKL_VERSION.toString().equals(prop.getIdentifier().getValue()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var versionText = prop.getExpr().text(source.toCharArray());
|
var versionTextExpr = prop.getExpr();
|
||||||
|
if (versionTextExpr == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var versionText = versionTextExpr.text(source.toCharArray());
|
||||||
|
|
||||||
Version version;
|
Version version;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -37,7 +37,7 @@ public final class VmBytes extends VmValue implements Iterable<Long> {
|
|||||||
private final byte[] bytes;
|
private final byte[] bytes;
|
||||||
private @Nullable VmDataSize size;
|
private @Nullable VmDataSize size;
|
||||||
|
|
||||||
public static VmBytes EMPTY = new VmBytes(new byte[0]);
|
public static final VmBytes EMPTY = new VmBytes(new byte[0]);
|
||||||
|
|
||||||
@TruffleBoundary
|
@TruffleBoundary
|
||||||
public static VmBytes createFromConstantNodes(ExpressionNode[] elements) {
|
public static VmBytes createFromConstantNodes(ExpressionNode[] elements) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -100,7 +100,8 @@ public final class VmDynamic extends VmObject {
|
|||||||
@Override
|
@Override
|
||||||
@TruffleBoundary
|
@TruffleBoundary
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj) return true;
|
if (this == obj) // noinspection Contract
|
||||||
|
return true;
|
||||||
if (!(obj instanceof VmDynamic other)) return false;
|
if (!(obj instanceof VmDynamic other)) return false;
|
||||||
|
|
||||||
// could use shallow force, but deep force is cached
|
// could use shallow force, but deep force is cached
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -94,9 +94,6 @@ public class VmImportAnalyzer {
|
|||||||
} catch (IOException err) {
|
} catch (IOException err) {
|
||||||
throw new VmExceptionBuilder().evalError("ioErrorLoadingModule", moduleKey.getUri()).build();
|
throw new VmExceptionBuilder().evalError("ioErrorLoadingModule", moduleKey.getUri()).build();
|
||||||
}
|
}
|
||||||
if (importsAndReads == null) {
|
|
||||||
return Set.of();
|
|
||||||
}
|
|
||||||
var result = new HashSet<ImportEntry>();
|
var result = new HashSet<ImportEntry>();
|
||||||
for (var entry : importsAndReads) {
|
for (var entry : importsAndReads) {
|
||||||
if (!entry.isModule()) {
|
if (!entry.isModule()) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -119,7 +119,8 @@ public final class VmMapping extends VmListingOrMapping {
|
|||||||
@Override
|
@Override
|
||||||
@TruffleBoundary
|
@TruffleBoundary
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj) return true;
|
if (this == obj) // noinspection Contract
|
||||||
|
return true;
|
||||||
if (!(obj instanceof VmMapping other)) return false;
|
if (!(obj instanceof VmMapping other)) return false;
|
||||||
|
|
||||||
// could use shallow force, but deep force is cached
|
// could use shallow force, but deep force is cached
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -52,14 +52,14 @@ public final class BaseNodes {
|
|||||||
|
|
||||||
public abstract static class NaN extends ExternalPropertyNode {
|
public abstract static class NaN extends ExternalPropertyNode {
|
||||||
@Specialization
|
@Specialization
|
||||||
protected double eval(VmTyped self) {
|
protected double eval(VmTyped ignored) {
|
||||||
return Double.NaN;
|
return Double.NaN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class Infinity extends ExternalPropertyNode {
|
public abstract static class Infinity extends ExternalPropertyNode {
|
||||||
@Specialization
|
@Specialization
|
||||||
protected double eval(VmTyped self) {
|
protected double eval(VmTyped ignored) {
|
||||||
return Double.POSITIVE_INFINITY;
|
return Double.POSITIVE_INFINITY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -27,7 +27,8 @@ public final class DataSizeNodes {
|
|||||||
private DataSizeNodes() {}
|
private DataSizeNodes() {}
|
||||||
|
|
||||||
@ImportStatic(MathUtils.class)
|
@ImportStatic(MathUtils.class)
|
||||||
public abstract static class value extends ExternalPropertyNode {
|
@PklName("value")
|
||||||
|
public abstract static class valueProperty extends ExternalPropertyNode {
|
||||||
@Specialization(guards = "isMathematicalInteger(self.getValue())")
|
@Specialization(guards = "isMathematicalInteger(self.getValue())")
|
||||||
protected long evalInt(VmDataSize self) {
|
protected long evalInt(VmDataSize self) {
|
||||||
return (long) self.getValue();
|
return (long) self.getValue();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -29,7 +29,8 @@ public final class DurationNodes {
|
|||||||
private DurationNodes() {}
|
private DurationNodes() {}
|
||||||
|
|
||||||
@ImportStatic(MathUtils.class)
|
@ImportStatic(MathUtils.class)
|
||||||
public abstract static class value extends ExternalPropertyNode {
|
@PklName("value")
|
||||||
|
public abstract static class valueProperty extends ExternalPropertyNode {
|
||||||
@Specialization(guards = "isMathematicalInteger(self.getValue())")
|
@Specialization(guards = "isMathematicalInteger(self.getValue())")
|
||||||
protected long evalInt(VmDuration self) {
|
protected long evalInt(VmDuration self) {
|
||||||
return (long) self.getValue();
|
return (long) self.getValue();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,6 +18,7 @@ package org.pkl.core.stdlib.base;
|
|||||||
import com.oracle.truffle.api.dsl.Specialization;
|
import com.oracle.truffle.api.dsl.Specialization;
|
||||||
import org.pkl.core.runtime.VmPair;
|
import org.pkl.core.runtime.VmPair;
|
||||||
import org.pkl.core.stdlib.ExternalPropertyNode;
|
import org.pkl.core.stdlib.ExternalPropertyNode;
|
||||||
|
import org.pkl.core.stdlib.PklName;
|
||||||
|
|
||||||
public final class PairNodes {
|
public final class PairNodes {
|
||||||
private PairNodes() {}
|
private PairNodes() {}
|
||||||
@@ -43,7 +44,8 @@ public final class PairNodes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class value extends ExternalPropertyNode {
|
@PklName("value")
|
||||||
|
public abstract static class valueProperty extends ExternalPropertyNode {
|
||||||
@Specialization
|
@Specialization
|
||||||
protected Object eval(VmPair self) {
|
protected Object eval(VmPair self) {
|
||||||
return self.getSecond();
|
return self.getSecond();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -20,7 +20,6 @@ import java.io.Writer;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import org.graalvm.collections.EconomicMap;
|
import org.graalvm.collections.EconomicMap;
|
||||||
import org.pkl.core.TestResults;
|
import org.pkl.core.TestResults;
|
||||||
import org.pkl.core.TestResults.Error;
|
import org.pkl.core.TestResults.Error;
|
||||||
@@ -57,9 +56,8 @@ public final class JUnitReport implements TestReport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void summarize(List<TestResults> allTestResults, Writer writer) throws IOException {
|
public void summarize(List<TestResults> allTestResults, Writer writer) throws IOException {
|
||||||
var totalTests = allTestResults.stream().collect(Collectors.summingLong(r -> r.totalTests()));
|
var totalTests = allTestResults.stream().mapToLong(TestResults::totalTests).sum();
|
||||||
var totalFailures =
|
var totalFailures = allTestResults.stream().mapToLong(TestResults::totalFailures).sum();
|
||||||
allTestResults.stream().collect(Collectors.summingLong(r -> r.totalFailures()));
|
|
||||||
|
|
||||||
assert aggregateSuiteName != null;
|
assert aggregateSuiteName != null;
|
||||||
|
|
||||||
@@ -69,12 +67,11 @@ public final class JUnitReport implements TestReport {
|
|||||||
"tests", totalTests,
|
"tests", totalTests,
|
||||||
"failures", totalFailures);
|
"failures", totalFailures);
|
||||||
|
|
||||||
var tests =
|
var suite =
|
||||||
allTestResults.stream()
|
buildXmlElement(
|
||||||
.map(r -> buildSuite(r))
|
"testsuites",
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
attrs,
|
||||||
|
allTestResults.stream().map(this::buildSuite).toArray(VmDynamic[]::new));
|
||||||
var suite = buildXmlElement("testsuites", attrs, tests.toArray(new VmDynamic[0]));
|
|
||||||
|
|
||||||
writer.append(renderXML(" ", "1.0", suite));
|
writer.append(renderXML(" ", "1.0", suite));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -362,7 +362,7 @@ public final class Json {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object put(String key, Object value) {
|
public @Nullable Object put(String key, Object value) {
|
||||||
return delegate.put(key, value);
|
return delegate.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -17,14 +17,11 @@ package org.pkl.core.parser
|
|||||||
|
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.pkl.core.Evaluator
|
|
||||||
import org.pkl.parser.Parser
|
import org.pkl.parser.Parser
|
||||||
|
|
||||||
// tests type argument and parameter parsing with trailing commas that cannot be tested with
|
// tests type argument and parameter parsing with trailing commas that cannot be tested with
|
||||||
// snippets because these constructs are currently only allowed in the stdlib
|
// snippets because these constructs are currently only allowed in the stdlib
|
||||||
class TrailingCommasTest {
|
class TrailingCommasTest {
|
||||||
private val evaluator = Evaluator.preconfigured()
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `class type parameter lists parse correctly`() {
|
fun `class type parameter lists parse correctly`() {
|
||||||
val module =
|
val module =
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -27,15 +27,7 @@ internal class ClassPageGenerator(
|
|||||||
pageScope: ClassScope,
|
pageScope: ClassScope,
|
||||||
isTestMode: Boolean,
|
isTestMode: Boolean,
|
||||||
consoleOut: OutputStream,
|
consoleOut: OutputStream,
|
||||||
) :
|
) : ModuleOrClassPageGenerator<ClassScope>(docsiteInfo, clazz, pageScope, isTestMode, consoleOut) {
|
||||||
ModuleOrClassPageGenerator<ClassScope>(
|
|
||||||
docsiteInfo,
|
|
||||||
docModule,
|
|
||||||
clazz,
|
|
||||||
pageScope,
|
|
||||||
isTestMode,
|
|
||||||
consoleOut,
|
|
||||||
) {
|
|
||||||
override val html: HTML.() -> Unit = {
|
override val html: HTML.() -> Unit = {
|
||||||
renderHtmlHead()
|
renderHtmlHead()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -25,8 +25,3 @@ internal object HtmlConstants {
|
|||||||
/** The `known-usages` element ID. */
|
/** The `known-usages` element ID. */
|
||||||
const val KNOWN_USAGES: String = "known-usages"
|
const val KNOWN_USAGES: String = "known-usages"
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object CssConstants {
|
|
||||||
/** The `current-version` CSS class. */
|
|
||||||
const val CURRENT_VERSION: String = "current-version"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -21,7 +21,6 @@ import kotlinx.html.*
|
|||||||
internal abstract class MainOrPackagePageGenerator<S>(
|
internal abstract class MainOrPackagePageGenerator<S>(
|
||||||
docsiteInfo: DocsiteInfo,
|
docsiteInfo: DocsiteInfo,
|
||||||
pageScope: S,
|
pageScope: S,
|
||||||
private val siteScope: SiteScope,
|
|
||||||
consoleOut: OutputStream,
|
consoleOut: OutputStream,
|
||||||
) : PageGenerator<S>(docsiteInfo, pageScope, consoleOut) where S : PageScope {
|
) : PageGenerator<S>(docsiteInfo, pageScope, consoleOut) where S : PageScope {
|
||||||
protected fun UL.renderModuleOrPackage(
|
protected fun UL.renderModuleOrPackage(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -23,7 +23,7 @@ internal class MainPageGenerator(
|
|||||||
private val packagesData: List<PackageData>,
|
private val packagesData: List<PackageData>,
|
||||||
pageScope: SiteScope,
|
pageScope: SiteScope,
|
||||||
consoleOut: OutputStream,
|
consoleOut: OutputStream,
|
||||||
) : MainOrPackagePageGenerator<SiteScope>(docsiteInfo, pageScope, pageScope, consoleOut) {
|
) : MainOrPackagePageGenerator<SiteScope>(docsiteInfo, pageScope, consoleOut) {
|
||||||
override val html: HTML.() -> Unit = {
|
override val html: HTML.() -> Unit = {
|
||||||
renderHtmlHead()
|
renderHtmlHead()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
package org.pkl.doc
|
package org.pkl.doc
|
||||||
|
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
import java.io.StringWriter
|
|
||||||
import kotlinx.html.*
|
import kotlinx.html.*
|
||||||
import org.pkl.core.Member
|
import org.pkl.core.Member
|
||||||
import org.pkl.core.PClass
|
import org.pkl.core.PClass
|
||||||
@@ -24,11 +23,9 @@ import org.pkl.core.PClass.ClassMember
|
|||||||
import org.pkl.core.PClass.Method
|
import org.pkl.core.PClass.Method
|
||||||
import org.pkl.core.TypeParameter
|
import org.pkl.core.TypeParameter
|
||||||
import org.pkl.core.TypeParameter.Variance
|
import org.pkl.core.TypeParameter.Variance
|
||||||
import org.pkl.core.ValueRenderers
|
|
||||||
|
|
||||||
internal abstract class ModuleOrClassPageGenerator<S>(
|
internal abstract class ModuleOrClassPageGenerator<S>(
|
||||||
docsiteInfo: DocsiteInfo,
|
docsiteInfo: DocsiteInfo,
|
||||||
private val docModule: DocModule,
|
|
||||||
protected val clazz: PClass,
|
protected val clazz: PClass,
|
||||||
scope: S,
|
scope: S,
|
||||||
private val isTestMode: Boolean,
|
private val isTestMode: Boolean,
|
||||||
@@ -141,12 +138,6 @@ internal abstract class ModuleOrClassPageGenerator<S>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderExportedValue(value: Any): String {
|
|
||||||
val writer = StringWriter()
|
|
||||||
ValueRenderers.pcf(writer, " ", false, false).renderValue(value)
|
|
||||||
return writer.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
protected fun HtmlBlockTag.renderMethods() {
|
protected fun HtmlBlockTag.renderMethods() {
|
||||||
if (!clazz.hasListedMethod) return
|
if (!clazz.hasListedMethod) return
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -28,7 +28,6 @@ internal class ModulePageGenerator(
|
|||||||
) :
|
) :
|
||||||
ModuleOrClassPageGenerator<ModuleScope>(
|
ModuleOrClassPageGenerator<ModuleScope>(
|
||||||
docsiteInfo,
|
docsiteInfo,
|
||||||
docModule,
|
|
||||||
docModule.schema.moduleClass,
|
docModule.schema.moduleClass,
|
||||||
pageScope,
|
pageScope,
|
||||||
isTestMode,
|
isTestMode,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -23,7 +23,7 @@ internal class PackagePageGenerator(
|
|||||||
private val docPackage: DocPackage,
|
private val docPackage: DocPackage,
|
||||||
pageScope: PackageScope,
|
pageScope: PackageScope,
|
||||||
consoleOut: OutputStream,
|
consoleOut: OutputStream,
|
||||||
) : MainOrPackagePageGenerator<PackageScope>(docsiteInfo, pageScope, pageScope.parent, consoleOut) {
|
) : MainOrPackagePageGenerator<PackageScope>(docsiteInfo, pageScope, consoleOut) {
|
||||||
override val html: HTML.() -> Unit = {
|
override val html: HTML.() -> Unit = {
|
||||||
renderHtmlHead()
|
renderHtmlHead()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -112,7 +112,7 @@ internal val String.uriEncodedComponent
|
|||||||
* Follows `encodeURI` from ECMAScript.
|
* Follows `encodeURI` from ECMAScript.
|
||||||
*/
|
*/
|
||||||
internal val String.uriEncoded
|
internal val String.uriEncoded
|
||||||
get(): String = replace(Regex("([^;/?:@&=+\$,#]+)")) { it.value.uriEncodedComponent }
|
get(): String = replace(Regex("([^;/?:@&=+$,#]+)")) { it.value.uriEncodedComponent }
|
||||||
|
|
||||||
fun getModulePath(moduleName: String, packagePrefix: String): String =
|
fun getModulePath(moduleName: String, packagePrefix: String): String =
|
||||||
moduleName.substring(packagePrefix.length).replace('.', '/')
|
moduleName.substring(packagePrefix.length).replace('.', '/')
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -32,7 +32,7 @@ class DocGeneratorTest {
|
|||||||
fun `uses virtual thread executor on JDK 21`() {
|
fun `uses virtual thread executor on JDK 21`() {
|
||||||
// On older JDKs, we get a ThreadPoolExecutor.
|
// On older JDKs, we get a ThreadPoolExecutor.
|
||||||
// not sure if there's a better assertion to make here.
|
// not sure if there's a better assertion to make here.
|
||||||
assertThat(DocGenerator.Companion.executor.javaClass.canonicalName)
|
assertThat(DocGenerator.executor.javaClass.canonicalName)
|
||||||
.isEqualTo("java.util.concurrent.ThreadPerTaskExecutor")
|
.isEqualTo("java.util.concurrent.ThreadPerTaskExecutor")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -85,17 +85,6 @@ class DocGeneratorTestHelper {
|
|||||||
|
|
||||||
internal val cacheDir: Path by lazy { tempDir.resolve("cache") }
|
internal val cacheDir: Path by lazy { tempDir.resolve("cache") }
|
||||||
|
|
||||||
internal val sourceModules =
|
|
||||||
listOf(
|
|
||||||
docsiteModule,
|
|
||||||
package1PackageModule,
|
|
||||||
package2PackageModule,
|
|
||||||
URI("package://localhost:0/birds@0.5.0"),
|
|
||||||
URI("package://localhost:0/fruit@1.1.0"),
|
|
||||||
URI("package://localhost:0/unlisted@1.0.0"),
|
|
||||||
URI("package://localhost:0/deprecated@1.0.0"),
|
|
||||||
) + package1InputModules + package2InputModules
|
|
||||||
|
|
||||||
internal val expectedRelativeOutputFiles: List<String> by lazy {
|
internal val expectedRelativeOutputFiles: List<String> by lazy {
|
||||||
expectedOutputFiles.map { path ->
|
expectedOutputFiles.map { path ->
|
||||||
IoUtils.toNormalizedPathString(expectedOutputDir.relativize(path)).let { str ->
|
IoUtils.toNormalizedPathString(expectedOutputDir.relativize(path)).let { str ->
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 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.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.pkl.doc
|
|
||||||
|
|
||||||
import com.google.common.jimfs.Configuration
|
|
||||||
import com.google.common.jimfs.Jimfs
|
|
||||||
import java.net.URI
|
|
||||||
import java.nio.file.FileSystem
|
|
||||||
import java.nio.file.Path
|
|
||||||
import kotlin.io.path.createDirectories
|
|
||||||
import kotlin.io.path.exists
|
|
||||||
import org.pkl.commons.test.FileTestUtils
|
|
||||||
import org.pkl.commons.test.listFilesRecursively
|
|
||||||
import org.pkl.core.util.IoUtils
|
|
||||||
|
|
||||||
class TestUtils {
|
|
||||||
val tempFileSystem: FileSystem by lazy { Jimfs.newFileSystem(Configuration.unix()) }
|
|
||||||
|
|
||||||
val tmpOutputDir by lazy { tempFileSystem.getPath("/work/output").apply { createDirectories() } }
|
|
||||||
|
|
||||||
val projectDir = FileTestUtils.rootProjectDir.resolve("pkl-doc")
|
|
||||||
|
|
||||||
val inputDir: Path by lazy {
|
|
||||||
projectDir.resolve("src/test/files/DocGeneratorTest/input").apply { assert(exists()) }
|
|
||||||
}
|
|
||||||
|
|
||||||
val docsiteModule: URI by lazy {
|
|
||||||
inputDir.resolve("docsite-info.pkl").apply { assert(exists()) }.toUri()
|
|
||||||
}
|
|
||||||
|
|
||||||
internal val package1PackageModule: URI by lazy {
|
|
||||||
inputDir.resolve("com.package1/doc-package-info.pkl").apply { assert(exists()) }.toUri()
|
|
||||||
}
|
|
||||||
|
|
||||||
val package2PackageModule: URI by lazy {
|
|
||||||
inputDir.resolve("com.package2/doc-package-info.pkl").apply { assert(exists()) }.toUri()
|
|
||||||
}
|
|
||||||
|
|
||||||
internal val package1InputModules: List<URI> by lazy {
|
|
||||||
inputDir
|
|
||||||
.resolve("com.package1")
|
|
||||||
.listFilesRecursively()
|
|
||||||
.filter { it.fileName.toString() != "doc-package-info.pkl" }
|
|
||||||
.map { it.toUri() }
|
|
||||||
}
|
|
||||||
|
|
||||||
val package2InputModules: List<URI> by lazy {
|
|
||||||
inputDir
|
|
||||||
.resolve("com.package2")
|
|
||||||
.listFilesRecursively()
|
|
||||||
.filter { it.fileName.toString() != "doc-package-info.pkl" }
|
|
||||||
.map { it.toUri() }
|
|
||||||
}
|
|
||||||
|
|
||||||
val expectedOutputDir: Path by lazy {
|
|
||||||
projectDir.resolve("src/test/files/DocGeneratorTest/output").createDirectories()
|
|
||||||
}
|
|
||||||
|
|
||||||
val expectedOutputFiles: List<Path> by lazy { expectedOutputDir.listFilesRecursively() }
|
|
||||||
|
|
||||||
val actualOutputDir: Path by lazy { tempFileSystem.getPath("/work/DocGeneratorTest") }
|
|
||||||
|
|
||||||
val actualOutputFiles: List<Path> by lazy { actualOutputDir.listFilesRecursively() }
|
|
||||||
|
|
||||||
val expectedRelativeOutputFiles: List<String> by lazy {
|
|
||||||
expectedOutputFiles.map { path ->
|
|
||||||
IoUtils.toNormalizedPathString(expectedOutputDir.relativize(path)).let { str ->
|
|
||||||
// Git will by default clone symlinks as shortcuts on Windows, and shortcuts have a
|
|
||||||
// `.lnk` extension.
|
|
||||||
if (IoUtils.isWindows() && str.endsWith(".lnk")) str.dropLast(4) else str
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val actualRelativeOutputFiles: List<String> by lazy {
|
|
||||||
actualOutputFiles.map { IoUtils.toNormalizedPathString(actualOutputDir.relativize(it)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
val binaryFileExtensions = setOf("woff2", "png", "svg")
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -32,7 +32,9 @@ public class Annotation extends AbstractNode {
|
|||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Type) children.get(0);
|
var ret = (Type) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable ObjectBody getBody() {
|
public @Nullable ObjectBody getBody() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -54,12 +54,16 @@ public final class Class extends AbstractNode {
|
|||||||
|
|
||||||
public Keyword getClassKeyword() {
|
public Keyword getClassKeyword() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Keyword) children.get(keywordOffset);
|
var ret = (Keyword) children.get(keywordOffset);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Identifier getName() {
|
public Identifier getName() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Identifier) children.get(keywordOffset + 1);
|
var ret = (Identifier) children.get(keywordOffset + 1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable TypeParameterList getTypeParameterList() {
|
public @Nullable TypeParameterList getTypeParameterList() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -57,7 +57,9 @@ public class ClassMethod extends AbstractNode {
|
|||||||
|
|
||||||
public Identifier getName() {
|
public Identifier getName() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Identifier) children.get(nameOffset);
|
var ret = (Identifier) children.get(nameOffset);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable TypeParameterList getTypeParameterList() {
|
public @Nullable TypeParameterList getTypeParameterList() {
|
||||||
@@ -67,7 +69,9 @@ public class ClassMethod extends AbstractNode {
|
|||||||
|
|
||||||
public ParameterList getParameterList() {
|
public ParameterList getParameterList() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (ParameterList) children.get(nameOffset + 2);
|
var ret = (ParameterList) children.get(nameOffset + 2);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable TypeAnnotation getTypeAnnotation() {
|
public @Nullable TypeAnnotation getTypeAnnotation() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -54,7 +54,9 @@ public final class ClassProperty extends AbstractNode {
|
|||||||
|
|
||||||
public Identifier getName() {
|
public Identifier getName() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Identifier) children.get(nameOffset);
|
var ret = (Identifier) children.get(nameOffset);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable TypeAnnotation getTypeAnnotation() {
|
public @Nullable TypeAnnotation getTypeAnnotation() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,7 +18,6 @@ package org.pkl.parser.syntax;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.pkl.parser.ParserVisitor;
|
import org.pkl.parser.ParserVisitor;
|
||||||
import org.pkl.parser.Span;
|
import org.pkl.parser.Span;
|
||||||
import org.pkl.parser.util.Nullable;
|
|
||||||
|
|
||||||
public final class DocComment extends AbstractNode {
|
public final class DocComment extends AbstractNode {
|
||||||
private final List<Span> spans;
|
private final List<Span> spans;
|
||||||
@@ -38,7 +37,7 @@ public final class DocComment extends AbstractNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> @Nullable T accept(ParserVisitor<? extends T> visitor) {
|
public <T> T accept(ParserVisitor<? extends T> visitor) {
|
||||||
return visitor.visitDocComment(this);
|
return visitor.visitDocComment(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -22,6 +22,7 @@ import org.pkl.parser.ParserVisitor;
|
|||||||
import org.pkl.parser.Span;
|
import org.pkl.parser.Span;
|
||||||
import org.pkl.parser.util.Nullable;
|
import org.pkl.parser.util.Nullable;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public abstract sealed class Expr extends AbstractNode {
|
public abstract sealed class Expr extends AbstractNode {
|
||||||
|
|
||||||
public Expr(Span span, @Nullable List<? extends @Nullable Node> children) {
|
public Expr(Span span, @Nullable List<? extends @Nullable Node> children) {
|
||||||
@@ -200,7 +201,9 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +219,9 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +240,9 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public StringConstant getImportStr() {
|
public StringConstant getImportStr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (StringConstant) children.get(0);
|
var ret = (StringConstant) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGlob() {
|
public boolean isGlob() {
|
||||||
@@ -258,7 +265,9 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReadType getReadType() {
|
public ReadType getReadType() {
|
||||||
@@ -285,7 +294,9 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Identifier getIdentifier() {
|
public Identifier getIdentifier() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Identifier) children.get(0);
|
var ret = (Identifier) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable ArgumentList getArgumentList() {
|
public @Nullable ArgumentList getArgumentList() {
|
||||||
@@ -314,12 +325,16 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Identifier getIdentifier() {
|
public Identifier getIdentifier() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Identifier) children.get(1);
|
var ret = (Identifier) children.get(1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNullable() {
|
public boolean isNullable() {
|
||||||
@@ -344,7 +359,9 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Identifier getIdentifier() {
|
public Identifier getIdentifier() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Identifier) children.get(0);
|
var ret = (Identifier) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable ArgumentList getArgumentList() {
|
public @Nullable ArgumentList getArgumentList() {
|
||||||
@@ -365,7 +382,9 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getArg() {
|
public Expr getArg() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,12 +400,16 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Expr getArg() {
|
public Expr getArg() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(1);
|
var ret = (Expr) children.get(1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,17 +425,23 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getCond() {
|
public Expr getCond() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Expr getThen() {
|
public Expr getThen() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(1);
|
var ret = (Expr) children.get(1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Expr getEls() {
|
public Expr getEls() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(2);
|
var ret = (Expr) children.get(2);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,17 +457,23 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Parameter getParameter() {
|
public Parameter getParameter() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Parameter) children.get(0);
|
var ret = (Parameter) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Expr getBindingExpr() {
|
public Expr getBindingExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(1);
|
var ret = (Expr) children.get(1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(2);
|
var ret = (Expr) children.get(2);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,12 +489,16 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public ParameterList getParameterList() {
|
public ParameterList getParameterList() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (ParameterList) children.get(0);
|
var ret = (ParameterList) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(1);
|
var ret = (Expr) children.get(1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +514,9 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,7 +537,9 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public ObjectBody getBody() {
|
public ObjectBody getBody() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (ObjectBody) children.get(1);
|
var ret = (ObjectBody) children.get(1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Span newSpan() {
|
public Span newSpan() {
|
||||||
@@ -516,12 +559,16 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectBody getBody() {
|
public ObjectBody getBody() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (ObjectBody) children.get(1);
|
var ret = (ObjectBody) children.get(1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,7 +584,9 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,7 +602,9 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,7 +620,9 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,12 +641,16 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getLeft() {
|
public Expr getLeft() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Expr getRight() {
|
public Expr getRight() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(1);
|
var ret = (Expr) children.get(1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Operator getOp() {
|
public Operator getOp() {
|
||||||
@@ -608,12 +665,12 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
@SuppressWarnings("ConstantValue")
|
@SuppressWarnings("ConstantValue")
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
BinaryOperatorExpr binaryOp = (BinaryOperatorExpr) o;
|
BinaryOperatorExpr binaryOp = (BinaryOperatorExpr) o;
|
||||||
return Objects.deepEquals(children, binaryOp.children)
|
return Objects.deepEquals(children, binaryOp.children)
|
||||||
&& op == binaryOp.op
|
&& op == binaryOp.op
|
||||||
@@ -638,12 +695,16 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Type) children.get(1);
|
var ret = (Type) children.get(1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,12 +720,16 @@ public abstract sealed class Expr extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Type) children.get(1);
|
var ret = (Type) children.get(1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -36,7 +36,9 @@ public class ExtendsOrAmendsClause extends AbstractNode {
|
|||||||
|
|
||||||
public StringConstant getUrl() {
|
public StringConstant getUrl() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (StringConstant) children.get(0);
|
var ret = (StringConstant) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
@@ -58,12 +60,12 @@ public class ExtendsOrAmendsClause extends AbstractNode {
|
|||||||
@SuppressWarnings("ConstantValue")
|
@SuppressWarnings("ConstantValue")
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!super.equals(o)) {
|
if (!super.equals(o)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -56,12 +56,12 @@ public final class Identifier extends AbstractNode {
|
|||||||
@SuppressWarnings("ConstantValue")
|
@SuppressWarnings("ConstantValue")
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Identifier identifier = (Identifier) o;
|
Identifier identifier = (Identifier) o;
|
||||||
return Objects.equals(value, identifier.value) && Objects.equals(span, identifier.span);
|
return Objects.equals(value, identifier.value) && Objects.equals(span, identifier.span);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -37,7 +37,9 @@ public final class ImportClause extends AbstractNode {
|
|||||||
|
|
||||||
public StringConstant getImportStr() {
|
public StringConstant getImportStr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (StringConstant) children.get(0);
|
var ret = (StringConstant) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGlob() {
|
public boolean isGlob() {
|
||||||
@@ -57,12 +59,12 @@ public final class ImportClause extends AbstractNode {
|
|||||||
@SuppressWarnings("ConstantValue")
|
@SuppressWarnings("ConstantValue")
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!super.equals(o)) {
|
if (!super.equals(o)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -44,12 +44,12 @@ public final class Modifier extends AbstractNode {
|
|||||||
@SuppressWarnings("ConstantValue")
|
@SuppressWarnings("ConstantValue")
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Modifier modifier = (Modifier) o;
|
Modifier modifier = (Modifier) o;
|
||||||
return value == modifier.value && Objects.equals(span, modifier.span);
|
return value == modifier.value && Objects.equals(span, modifier.span);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -83,6 +83,8 @@ public final class ModuleDecl extends AbstractNode {
|
|||||||
if (extendsOrAmends != null) {
|
if (extendsOrAmends != null) {
|
||||||
return start.endWith(extendsOrAmends.span());
|
return start.endWith(extendsOrAmends.span());
|
||||||
}
|
}
|
||||||
return start.endWith(children.get(nameOffset + 1).span());
|
var end = children.get(nameOffset + 1);
|
||||||
|
assert end != null;
|
||||||
|
return start.endWith(end.span());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -22,6 +22,7 @@ import org.pkl.parser.ParserVisitor;
|
|||||||
import org.pkl.parser.Span;
|
import org.pkl.parser.Span;
|
||||||
import org.pkl.parser.util.Nullable;
|
import org.pkl.parser.util.Nullable;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public abstract sealed class ObjectMember extends AbstractNode {
|
public abstract sealed class ObjectMember extends AbstractNode {
|
||||||
|
|
||||||
public ObjectMember(Span span, @Nullable List<? extends @Nullable Node> children) {
|
public ObjectMember(Span span, @Nullable List<? extends @Nullable Node> children) {
|
||||||
@@ -40,7 +41,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +68,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
|
|
||||||
public Identifier getIdentifier() {
|
public Identifier getIdentifier() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Identifier) children.get(identifierOffset);
|
var ret = (Identifier) children.get(identifierOffset);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable TypeAnnotation getTypeAnnotation() {
|
public @Nullable TypeAnnotation getTypeAnnotation() {
|
||||||
@@ -106,12 +111,16 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
|
|
||||||
public Keyword getFunctionKeyword() {
|
public Keyword getFunctionKeyword() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Keyword) children.get(identifierOffset);
|
var ret = (Keyword) children.get(identifierOffset);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Identifier getIdentifier() {
|
public Identifier getIdentifier() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Identifier) children.get(identifierOffset + 1);
|
var ret = (Identifier) children.get(identifierOffset + 1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable TypeParameterList getTypeParameterList() {
|
public @Nullable TypeParameterList getTypeParameterList() {
|
||||||
@@ -121,7 +130,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
|
|
||||||
public ParameterList getParamList() {
|
public ParameterList getParamList() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (ParameterList) children.get(identifierOffset + 3);
|
var ret = (ParameterList) children.get(identifierOffset + 3);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable TypeAnnotation getTypeAnnotation() {
|
public @Nullable TypeAnnotation getTypeAnnotation() {
|
||||||
@@ -131,7 +142,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(identifierOffset + 5);
|
var ret = (Expr) children.get(identifierOffset + 5);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
@@ -147,7 +160,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
Span end;
|
Span end;
|
||||||
var typeAnnotation = children.get(identifierOffset + 4);
|
var typeAnnotation = children.get(identifierOffset + 4);
|
||||||
if (typeAnnotation == null) {
|
if (typeAnnotation == null) {
|
||||||
end = children.get(identifierOffset + 3).span();
|
var stop = children.get(identifierOffset + 3);
|
||||||
|
assert stop != null;
|
||||||
|
end = stop.span();
|
||||||
} else {
|
} else {
|
||||||
end = typeAnnotation.span();
|
end = typeAnnotation.span();
|
||||||
}
|
}
|
||||||
@@ -168,7 +183,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getPred() {
|
public Expr getPred() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable Expr getExpr() {
|
public @Nullable Expr getExpr() {
|
||||||
@@ -195,7 +212,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getKey() {
|
public Expr getKey() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable Expr getValue() {
|
public @Nullable Expr getValue() {
|
||||||
@@ -225,7 +244,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNullable() {
|
public boolean isNullable() {
|
||||||
@@ -247,12 +268,12 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
@SuppressWarnings("ConstantValue")
|
@SuppressWarnings("ConstantValue")
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!super.equals(o)) {
|
if (!super.equals(o)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -279,12 +300,16 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getPredicate() {
|
public Expr getPredicate() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectBody getThenClause() {
|
public ObjectBody getThenClause() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (ObjectBody) children.get(1);
|
var ret = (ObjectBody) children.get(1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable ObjectBody getElseClause() {
|
public @Nullable ObjectBody getElseClause() {
|
||||||
@@ -306,7 +331,9 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
|
|
||||||
public Parameter getP1() {
|
public Parameter getP1() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Parameter) children.get(0);
|
var ret = (Parameter) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable Parameter getP2() {
|
public @Nullable Parameter getP2() {
|
||||||
@@ -316,12 +343,16 @@ public abstract sealed class ObjectMember extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(2);
|
var ret = (Expr) children.get(2);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectBody getBody() {
|
public ObjectBody getBody() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (ObjectBody) children.get(3);
|
var ret = (ObjectBody) children.get(3);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Span forSpan() {
|
public Span forSpan() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -46,7 +46,9 @@ public abstract sealed class Parameter extends AbstractNode {
|
|||||||
|
|
||||||
public Identifier getIdentifier() {
|
public Identifier getIdentifier() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Identifier) children.get(0);
|
var ret = (Identifier) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable TypeAnnotation getTypeAnnotation() {
|
public @Nullable TypeAnnotation getTypeAnnotation() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -45,12 +45,12 @@ public class StringConstant extends AbstractNode {
|
|||||||
@SuppressWarnings("ConstantValue")
|
@SuppressWarnings("ConstantValue")
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!super.equals(o)) {
|
if (!super.equals(o)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -52,12 +52,12 @@ public abstract sealed class StringPart extends AbstractNode {
|
|||||||
@SuppressWarnings("ConstantValue")
|
@SuppressWarnings("ConstantValue")
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!super.equals(o)) {
|
if (!super.equals(o)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,9 @@ public abstract sealed class StringPart extends AbstractNode {
|
|||||||
|
|
||||||
public Expr getExpr() {
|
public Expr getExpr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Expr) children.get(0);
|
var ret = (Expr) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -73,7 +73,9 @@ public abstract sealed class Type extends AbstractNode {
|
|||||||
|
|
||||||
public StringConstant getStr() {
|
public StringConstant getStr() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (StringConstant) children.get(0);
|
var ret = (StringConstant) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +91,9 @@ public abstract sealed class Type extends AbstractNode {
|
|||||||
|
|
||||||
public QualifiedIdentifier getName() {
|
public QualifiedIdentifier getName() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (QualifiedIdentifier) children.get(0);
|
var ret = (QualifiedIdentifier) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable TypeArgumentList getArgs() {
|
public @Nullable TypeArgumentList getArgs() {
|
||||||
@@ -110,7 +114,9 @@ public abstract sealed class Type extends AbstractNode {
|
|||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Type) children.get(0);
|
var ret = (Type) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +132,9 @@ public abstract sealed class Type extends AbstractNode {
|
|||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Type) children.get(0);
|
var ret = (Type) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +150,9 @@ public abstract sealed class Type extends AbstractNode {
|
|||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Type) children.get(0);
|
var ret = (Type) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -190,12 +200,12 @@ public abstract sealed class Type extends AbstractNode {
|
|||||||
@SuppressWarnings("ConstantValue")
|
@SuppressWarnings("ConstantValue")
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!super.equals(o)) {
|
if (!super.equals(o)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -227,7 +237,9 @@ public abstract sealed class Type extends AbstractNode {
|
|||||||
|
|
||||||
public Type getRet() {
|
public Type getRet() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Type) children.get(children.size() - 1);
|
var ret = (Type) children.get(children.size() - 1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -20,6 +20,7 @@ import org.pkl.parser.ParserVisitor;
|
|||||||
import org.pkl.parser.Span;
|
import org.pkl.parser.Span;
|
||||||
import org.pkl.parser.util.Nullable;
|
import org.pkl.parser.util.Nullable;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public final class TypeAlias extends AbstractNode {
|
public final class TypeAlias extends AbstractNode {
|
||||||
private final int modifiersOffset;
|
private final int modifiersOffset;
|
||||||
private final int nameOffset;
|
private final int nameOffset;
|
||||||
@@ -54,12 +55,16 @@ public final class TypeAlias extends AbstractNode {
|
|||||||
|
|
||||||
public Keyword getTypealiasKeyword() {
|
public Keyword getTypealiasKeyword() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Keyword) children.get(nameOffset);
|
var ret = (Keyword) children.get(nameOffset);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Identifier getName() {
|
public Identifier getName() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Identifier) children.get(nameOffset + 1);
|
var ret = (Identifier) children.get(nameOffset + 1);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable TypeParameterList getTypeParameterList() {
|
public @Nullable TypeParameterList getTypeParameterList() {
|
||||||
@@ -69,7 +74,9 @@ public final class TypeAlias extends AbstractNode {
|
|||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Type) children.get(nameOffset + 3);
|
var ret = (Type) children.get(nameOffset + 3);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
@@ -83,7 +90,9 @@ public final class TypeAlias extends AbstractNode {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var end = children.get(nameOffset + 1).span();
|
var endNode = children.get(nameOffset + 1);
|
||||||
|
assert endNode != null;
|
||||||
|
var end = endNode.span();
|
||||||
var tparList = children.get(nameOffset + 2);
|
var tparList = children.get(nameOffset + 2);
|
||||||
if (tparList != null) {
|
if (tparList != null) {
|
||||||
end = tparList.span();
|
end = tparList.span();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -32,6 +32,8 @@ public class TypeAnnotation extends AbstractNode {
|
|||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Type) children.get(0);
|
var ret = (Type) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -40,7 +40,9 @@ public final class TypeParameter extends AbstractNode {
|
|||||||
|
|
||||||
public Identifier getIdentifier() {
|
public Identifier getIdentifier() {
|
||||||
assert children != null;
|
assert children != null;
|
||||||
return (Identifier) children.get(0);
|
var ret = (Identifier) children.get(0);
|
||||||
|
assert ret != null;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -58,12 +60,12 @@ public final class TypeParameter extends AbstractNode {
|
|||||||
@SuppressWarnings("ConstantValue")
|
@SuppressWarnings("ConstantValue")
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!super.equals(o)) {
|
if (!super.equals(o)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -71,19 +71,6 @@ class GenericSexpRenderer(code: String) {
|
|||||||
buf.append(')')
|
buf.append(')')
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderQualifiedAccess(node: Node) {
|
|
||||||
var children = node.children
|
|
||||||
if (children.last().type == NodeType.UNQUALIFIED_ACCESS_EXPR) {
|
|
||||||
children = children.dropLast(1) + collectChildren(children.last())
|
|
||||||
}
|
|
||||||
val toRender = mutableListOf<Node>()
|
|
||||||
for (child in children) {
|
|
||||||
if (child.type in IGNORED_CHILDREN || child.type == NodeType.OPERATOR) continue
|
|
||||||
toRender += child
|
|
||||||
}
|
|
||||||
doRender(name(node), toRender)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderDefaultUnionType(node: Node) {
|
private fun renderDefaultUnionType(node: Node) {
|
||||||
buf.append(tab)
|
buf.append(tab)
|
||||||
buf.append("(defaultUnionType\n")
|
buf.append("(defaultUnionType\n")
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -1092,7 +1092,7 @@ class SexpRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private fun sortModuleEntries(mod: org.pkl.parser.syntax.Module): List<Node> {
|
private fun sortModuleEntries(mod: Module): List<Node> {
|
||||||
val res = mutableListOf<Node>()
|
val res = mutableListOf<Node>()
|
||||||
res += mod.classes
|
res += mod.classes
|
||||||
res += mod.typeAliases
|
res += mod.typeAliases
|
||||||
|
|||||||
Reference in New Issue
Block a user