From 28b128f86f3db657fe5a81eec0b4ad69a0fd7bcc Mon Sep 17 00:00:00 2001 From: Daniel Chao Date: Mon, 17 Feb 2025 07:36:43 -0800 Subject: [PATCH] Run spotless formatting (#958) When we updated spotless's Java and Kotlin formatter, we changed the underlying formatting rules. However, due to spotless ratcheting, these formatting changes don't get applied unless a file gets touched in a commit. To avoid future PRs introducing lines of change that aren't related to the intention of the PR, this is a one-time format of all files. --- buildSrc/src/main/kotlin/MergeSourcesJars.kt | 4 +- .../org/pkl/cli/CliPackageDownloader.kt | 4 +- .../kotlin/org/pkl/cli/CliProjectPackager.kt | 6 +- .../kotlin/org/pkl/cli/CliProjectResolver.kt | 8 +- .../src/main/kotlin/org/pkl/cli/CliRepl.kt | 10 +- .../main/kotlin/org/pkl/cli/CliTestRunner.kt | 4 +- .../src/main/kotlin/org/pkl/cli/repl/Repl.kt | 4 +- .../org/pkl/cli/CliImportAnalyzerTest.kt | 4 +- .../org/pkl/cli/CliProjectPackagerTest.kt | 88 ++++----- .../org/pkl/cli/CliProjectResolverTest.kt | 44 ++--- .../java/CliJavaCodeGeneratorOptions.kt | 6 +- .../codegen/java/CliJavaCodeGeneratorTest.kt | 40 ++--- .../pkl/codegen/java/InMemoryJavaCompiler.kt | 4 +- .../pkl/codegen/java/JavaCodeGeneratorTest.kt | 84 ++++----- .../kotlin/CliKotlinCodeGeneratorOptions.kt | 6 +- .../kotlin/CliKotlinCodeGeneratorTest.kt | 34 ++-- .../org/pkl/commons/cli/CliException.kt | 6 +- .../commons/cli/commands/OptionExtensions.kt | 6 +- .../commons/cli/commands/ProjectOptions.kt | 8 +- .../pkl/commons/cli/commands/TestOptions.kt | 4 +- pkl-commons-test/pkl-commons-test.gradle.kts | 6 +- .../kotlin/org/pkl/commons/NameMapperTest.kt | 11 +- .../config/kotlin/mapper/KotlinConversions.kt | 4 +- .../config/kotlin/mapper/PPairToKotlinPair.kt | 6 +- .../config/kotlin/KotlinObjectMappingTest.kt | 4 +- .../kotlin/mapper/PPairToKotlinPairTest.kt | 6 +- .../core/generator/MemberRegistryGenerator.kt | 6 +- .../org/pkl/core/util/CodeGeneratorUtils.java | 38 ++-- .../java/org/pkl/core/util/GlobResolver.java | 4 +- .../main/java/org/pkl/core/util/IoUtils.java | 168 +++++++++--------- .../org/pkl/core/util/json/JsonWriter.java | 4 +- .../org/pkl/core/util/yaml/Yaml12Emitter.java | 46 ++--- .../org/pkl/core/util/yaml/YamlEmitter.java | 80 ++++----- .../kotlin/org/pkl/core/EvaluateTestsTest.kt | 28 +-- .../test/kotlin/org/pkl/core/PModuleTest.kt | 4 +- .../test/kotlin/org/pkl/core/PObjectTest.kt | 6 +- .../kotlin/org/pkl/core/PcfRendererTest.kt | 4 +- .../org/pkl/core/PropertiesRendererTest.kt | 4 +- .../kotlin/org/pkl/core/ReplServerTest.kt | 8 +- .../org/pkl/core/SecurityManagersTest.kt | 12 +- .../externalreader/ExternalReaderRuntime.kt | 18 +- .../pkl/core/http/RequestCapturingClient.kt | 4 +- .../messaging/BaseMessagePackCodecTest.kt | 6 +- .../pkl/core/module/ServiceProviderTest.kt | 4 +- .../core/packages/DependencyMetadataTest.kt | 14 +- .../org/pkl/core/project/ProjectDepsTest.kt | 8 +- .../org/pkl/core/project/ProjectTest.kt | 8 +- .../org/pkl/core/stdlib/PathSpecParserTest.kt | 8 +- .../org/pkl/core/stdlib/ReflectModuleTest.kt | 4 +- .../truffle/LongVsDoubleSpecializationTest.kt | 20 ++- .../org/pkl/core/util/GlobResolverTest.kt | 14 +- .../org/pkl/core/util/ImportGraphUtilsTest.kt | 16 +- .../kotlin/org/pkl/doc/ClassPageGenerator.kt | 8 +- .../kotlin/org/pkl/doc/CliDocGenerator.kt | 8 +- .../org/pkl/doc/CliDocGeneratorOptions.kt | 4 +- .../src/main/kotlin/org/pkl/doc/DocScope.kt | 53 +++--- .../main/kotlin/org/pkl/doc/DocsiteInfo.kt | 4 +- .../main/kotlin/org/pkl/doc/HtmlGenerator.kt | 6 +- .../org/pkl/doc/MainOrPackagePageGenerator.kt | 8 +- .../org/pkl/doc/ModuleOrClassPageGenerator.kt | 9 +- .../test/kotlin/org/pkl/doc/DocScopeTest.kt | 8 +- .../src/test/kotlin/org/pkl/doc/SearchTest.kt | 26 +-- .../org/pkl/executor/EmbeddedExecutorTest.kt | 32 ++-- .../org/pkl/gradle/AnalyzeImportsTest.kt | 8 +- .../kotlin/org/pkl/gradle/EvaluatorsTest.kt | 80 +++++---- .../org/pkl/gradle/PkldocGeneratorsTest.kt | 12 +- .../org/pkl/gradle/ProjectPackageTest.kt | 12 +- .../org/pkl/gradle/ProjectResolveTest.kt | 6 +- .../test/kotlin/org/pkl/gradle/TestsTest.kt | 10 +- .../kotlin/org/pkl/server/BinaryEvaluator.kt | 6 +- .../kotlin/org/pkl/server/ClientLogger.kt | 4 +- .../org/pkl/server/ClientModuleKeyFactory.kt | 4 +- .../src/main/kotlin/org/pkl/server/Server.kt | 26 +-- .../pkl/server/ServerMessagePackDecoder.kt | 12 +- .../kotlin/org/pkl/server/ServerMessages.kt | 20 +-- .../kotlin/org/pkl/server/JvmServerTest.kt | 8 +- .../kotlin/org/pkl/server/NativeServerTest.kt | 4 +- .../pkl/server/ServerMessagePackCodecTest.kt | 32 ++-- stdlib/stdlib.gradle.kts | 4 +- 79 files changed, 679 insertions(+), 682 deletions(-) diff --git a/buildSrc/src/main/kotlin/MergeSourcesJars.kt b/buildSrc/src/main/kotlin/MergeSourcesJars.kt index 9305732c..6cb6f3d8 100644 --- a/buildSrc/src/main/kotlin/MergeSourcesJars.kt +++ b/buildSrc/src/main/kotlin/MergeSourcesJars.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,7 +111,7 @@ open class MergeSourcesJars : DefaultTask() { relocatedPkgs: Map, details: FileVisitDetails, sourceText: String, - importPattern: Pattern + importPattern: Pattern, ): String { val matcher = importPattern.matcher(sourceText) val buffer = StringBuffer() diff --git a/pkl-cli/src/main/kotlin/org/pkl/cli/CliPackageDownloader.kt b/pkl-cli/src/main/kotlin/org/pkl/cli/CliPackageDownloader.kt index 872fdd44..6afb21bd 100644 --- a/pkl-cli/src/main/kotlin/org/pkl/cli/CliPackageDownloader.kt +++ b/pkl-cli/src/main/kotlin/org/pkl/cli/CliPackageDownloader.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import org.pkl.core.packages.PackageUri class CliPackageDownloader( baseOptions: CliBaseOptions, private val packageUris: List, - private val noTransitive: Boolean + private val noTransitive: Boolean, ) : CliCommand(baseOptions) { override fun doRun() { diff --git a/pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectPackager.kt b/pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectPackager.kt index d227c9df..f5a4fdc2 100644 --- a/pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectPackager.kt +++ b/pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectPackager.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ class CliProjectPackager( private val outputPath: String, private val skipPublishCheck: Boolean, private val consoleWriter: Writer = System.out.writer(), - private val errWriter: Writer = System.err.writer() + private val errWriter: Writer = System.err.writer(), ) : CliProjectCommand(baseOptions, projectDirs) { private fun runApiTests(project: Project) { @@ -85,7 +85,7 @@ class CliProjectPackager( securityManager, httpClient, skipPublishCheck, - consoleWriter + consoleWriter, ) .createPackages() } diff --git a/pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectResolver.kt b/pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectResolver.kt index 1d3596c7..5040bb88 100644 --- a/pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectResolver.kt +++ b/pkl-cli/src/main/kotlin/org/pkl/cli/CliProjectResolver.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ class CliProjectResolver( baseOptions: CliBaseOptions, projectDirs: List, private val consoleWriter: Writer = System.out.writer(), - private val errWriter: Writer = System.err.writer() + private val errWriter: Writer = System.err.writer(), ) : CliProjectCommand(baseOptions, projectDirs) { override fun doRun() { for (projectFile in normalizedProjectFiles) { @@ -38,10 +38,10 @@ class CliProjectResolver( allowedModules, allowedResources, SecurityManagers.defaultTrustLevels, - rootDir + rootDir, ), httpClient, - moduleCacheDir + moduleCacheDir, ) val dependencies = ProjectDependenciesResolver(project, packageResolver, errWriter).resolve() val depsFile = diff --git a/pkl-cli/src/main/kotlin/org/pkl/cli/CliRepl.kt b/pkl-cli/src/main/kotlin/org/pkl/cli/CliRepl.kt index 6bbe50fc..4be32b15 100644 --- a/pkl-cli/src/main/kotlin/org/pkl/cli/CliRepl.kt +++ b/pkl-cli/src/main/kotlin/org/pkl/cli/CliRepl.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,13 +34,13 @@ internal class CliRepl(private val options: CliEvaluatorOptions) : CliCommand(op allowedModules, allowedResources, SecurityManagers.defaultTrustLevels, - rootDir + rootDir, ), httpClient, Loggers.stdErr(), listOf( ModuleKeyFactories.standardLibrary, - ModuleKeyFactories.modulePath(modulePathResolver) + ModuleKeyFactories.modulePath(modulePathResolver), ) + ModuleKeyFactories.fromServiceProviders() + listOf( @@ -48,7 +48,7 @@ internal class CliRepl(private val options: CliEvaluatorOptions) : CliCommand(op ModuleKeyFactories.http, ModuleKeyFactories.pkg, ModuleKeyFactories.projectpackage, - ModuleKeyFactories.genericUrl + ModuleKeyFactories.genericUrl, ), listOf( ResourceReaders.environmentVariable(), @@ -58,7 +58,7 @@ internal class CliRepl(private val options: CliEvaluatorOptions) : CliCommand(op ResourceReaders.http(), ResourceReaders.https(), ResourceReaders.pkg(), - ResourceReaders.projectpackage() + ResourceReaders.projectpackage(), ), environmentVariables, externalProperties, diff --git a/pkl-cli/src/main/kotlin/org/pkl/cli/CliTestRunner.kt b/pkl-cli/src/main/kotlin/org/pkl/cli/CliTestRunner.kt index 15dfff84..605a15e2 100644 --- a/pkl-cli/src/main/kotlin/org/pkl/cli/CliTestRunner.kt +++ b/pkl-cli/src/main/kotlin/org/pkl/cli/CliTestRunner.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ constructor( private val options: CliBaseOptions, private val testOptions: CliTestOptions, private val consoleWriter: Writer = System.out.writer(), - private val errWriter: Writer = System.err.writer() + private val errWriter: Writer = System.err.writer(), ) : CliCommand(options) { override fun doRun() { diff --git a/pkl-cli/src/main/kotlin/org/pkl/cli/repl/Repl.kt b/pkl-cli/src/main/kotlin/org/pkl/cli/repl/Repl.kt index d16855df..d0869db6 100644 --- a/pkl-cli/src/main/kotlin/org/pkl/cli/repl/Repl.kt +++ b/pkl-cli/src/main/kotlin/org/pkl/cli/repl/Repl.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ internal class Repl(workingDir: Path, private val server: ReplServer) { option(Option.DISABLE_EVENT_EXPANSION, true) variable( org.jline.reader.LineReader.HISTORY_FILE, - (IoUtils.getPklHomeDir().resolve("repl-history")) + (IoUtils.getPklHomeDir().resolve("repl-history")), ) } .build() diff --git a/pkl-cli/src/test/kotlin/org/pkl/cli/CliImportAnalyzerTest.kt b/pkl-cli/src/test/kotlin/org/pkl/cli/CliImportAnalyzerTest.kt index 34f19c9e..dee26b57 100644 --- a/pkl-cli/src/test/kotlin/org/pkl/cli/CliImportAnalyzerTest.kt +++ b/pkl-cli/src/test/kotlin/org/pkl/cli/CliImportAnalyzerTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ class CliImportAnalyzerTest { val analyzer = CliImportAnalyzer( CliImportAnalyzerOptions(baseOptions, outputFormat = OutputFormat.JSON.toString()), - StringBuilderWriter(sb) + StringBuilderWriter(sb), ) analyzer.run() assertThat(sb.toString()) diff --git a/pkl-cli/src/test/kotlin/org/pkl/cli/CliProjectPackagerTest.kt b/pkl-cli/src/test/kotlin/org/pkl/cli/CliProjectPackagerTest.kt index 5c730cbe..11106bc5 100644 --- a/pkl-cli/src/test/kotlin/org/pkl/cli/CliProjectPackagerTest.kt +++ b/pkl-cli/src/test/kotlin/org/pkl/cli/CliProjectPackagerTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -115,7 +115,7 @@ class CliProjectPackagerTest { } } """ - .trimIndent() + .trimIndent(), ) tempDir.writeFile( "PklProject", @@ -130,7 +130,7 @@ class CliProjectPackagerTest { apiTests { "myTest.pkl" } } """ - .trimIndent() + .trimIndent(), ) val buffer = StringWriter() val packager = @@ -140,7 +140,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = true, - consoleWriter = buffer + consoleWriter = buffer, ) val err = assertThrows { packager.run() } assertThat(err).hasMessageContaining("because its API tests are failing") @@ -187,7 +187,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = true, - consoleWriter = buffer + consoleWriter = buffer, ) packager.run() } @@ -286,7 +286,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out", skipPublishCheck = true, - consoleWriter = buffer + consoleWriter = buffer, ) packager.run() } @@ -301,7 +301,7 @@ class CliProjectPackagerTest { name: String """ - .trimIndent() + .trimIndent(), ) val fooTxt = @@ -312,7 +312,7 @@ class CliProjectPackagerTest { bar baz """ - .trimIndent() + .trimIndent(), ) tempDir @@ -337,7 +337,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = true, - consoleWriter = StringWriter() + consoleWriter = StringWriter(), ) packager.run() val expectedMetadata = tempDir.resolve(".out/mypackage@1.0.0/mypackage@1.0.0") @@ -411,7 +411,7 @@ class CliProjectPackagerTest { } } """ - .trimIndent() + .trimIndent(), ) CliProjectPackager( CliBaseOptions(workingDir = tempDir), @@ -419,7 +419,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = true, - consoleWriter = StringWriter() + consoleWriter = StringWriter(), ) .run() val expectedArchive = tempDir.resolve(".out/mypackage@1.0.0/mypackage@1.0.0.zip") @@ -432,7 +432,7 @@ class CliProjectPackagerTest { "/input", "/input/foo", "/input/foo/bar.txt", - "/main.pkl" + "/main.pkl", ) ) } @@ -460,7 +460,7 @@ class CliProjectPackagerTest { ["project2"] = import("../project2/PklProject") } """ - .trimIndent() + .trimIndent(), ) projectDir.writeFile( "PklProject.deps.json", @@ -483,7 +483,7 @@ class CliProjectPackagerTest { } } """ - .trimIndent() + .trimIndent(), ) project2Dir.writeFile( @@ -498,7 +498,7 @@ class CliProjectPackagerTest { packageZipUrl = "https://foo.com/project2.zip" } """ - .trimIndent() + .trimIndent(), ) project2Dir.writeFile( "PklProject.deps.json", @@ -508,7 +508,7 @@ class CliProjectPackagerTest { "resolvedDependencies": {} } """ - .trimIndent() + .trimIndent(), ) CliProjectPackager( @@ -517,7 +517,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = true, - consoleWriter = StringWriter() + consoleWriter = StringWriter(), ) .run() val expectedMetadata = tempDir.resolve(".out/mypackage@1.0.0/mypackage@1.0.0") @@ -598,7 +598,7 @@ class CliProjectPackagerTest { ["project2"] = import("../project2/PklProject") } """ - .trimIndent() + .trimIndent(), ) projectDir.writeFile( "PklProject.deps.json", @@ -621,7 +621,7 @@ class CliProjectPackagerTest { } } """ - .trimIndent() + .trimIndent(), ) project2Dir.writeFile( @@ -636,7 +636,7 @@ class CliProjectPackagerTest { packageZipUrl = "https://foo.com/project2.zip" } """ - .trimIndent() + .trimIndent(), ) project2Dir.writeFile( "PklProject.deps.json", @@ -646,7 +646,7 @@ class CliProjectPackagerTest { "resolvedDependencies": {} } """ - .trimIndent() + .trimIndent(), ) assertThatCode { CliProjectPackager( @@ -655,7 +655,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = true, - consoleWriter = StringWriter() + consoleWriter = StringWriter(), ) .run() } @@ -671,7 +671,7 @@ class CliProjectPackagerTest { res = foo """ - .trimIndent() + .trimIndent(), ) tempDir.writeFile( "PklProject", @@ -685,7 +685,7 @@ class CliProjectPackagerTest { packageZipUrl = "https://foo.com" } """ - .trimIndent() + .trimIndent(), ) val e = assertThrows { @@ -695,7 +695,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = true, - consoleWriter = StringWriter() + consoleWriter = StringWriter(), ) .run() } @@ -725,7 +725,7 @@ class CliProjectPackagerTest { res = foo """ - .trimIndent() + .trimIndent(), ) tempDir.writeFile( "PklProject", @@ -739,7 +739,7 @@ class CliProjectPackagerTest { packageZipUrl = "https://foo.com" } """ - .trimIndent() + .trimIndent(), ) val e = assertThrows { @@ -749,7 +749,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = true, - consoleWriter = StringWriter() + consoleWriter = StringWriter(), ) .run() } @@ -771,7 +771,7 @@ class CliProjectPackagerTest { """ res = read("$tempDir/foo.pkl") """ - .trimIndent() + .trimIndent(), ) tempDir.writeFile( "PklProject", @@ -785,7 +785,7 @@ class CliProjectPackagerTest { packageZipUrl = "https://foo.com" } """ - .trimIndent() + .trimIndent(), ) val e = assertThrows { @@ -795,7 +795,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = true, - consoleWriter = StringWriter() + consoleWriter = StringWriter(), ) .run() } @@ -816,7 +816,7 @@ class CliProjectPackagerTest { """ import "baz.pkl" """ - .trimIndent() + .trimIndent(), ) tempDir.writeFile( "PklProject", @@ -830,7 +830,7 @@ class CliProjectPackagerTest { packageZipUrl = "https://foo.com" } """ - .trimIndent() + .trimIndent(), ) CliProjectPackager( CliBaseOptions(workingDir = tempDir), @@ -838,7 +838,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = true, - consoleWriter = StringWriter() + consoleWriter = StringWriter(), ) .run() } @@ -858,7 +858,7 @@ class CliProjectPackagerTest { packageZipUrl = "https://foo.com" } """ - .trimIndent() + .trimIndent(), ) tempDir.writeFile("project2/main2.pkl", "res = 2") tempDir.writeFile( @@ -873,7 +873,7 @@ class CliProjectPackagerTest { packageZipUrl = "https://foo.com" } """ - .trimIndent() + .trimIndent(), ) val out = StringWriter() CliProjectPackager( @@ -882,7 +882,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = true, - consoleWriter = out + consoleWriter = out, ) .run() val sep = File.separatorChar @@ -923,7 +923,7 @@ class CliProjectPackagerTest { packageZipUrl = "https://foo.com" } """ - .trimIndent() + .trimIndent(), ) val e = assertThrows { @@ -931,13 +931,13 @@ class CliProjectPackagerTest { CliBaseOptions( workingDir = tempDir, caCertificates = listOf(FileTestUtils.selfSignedCertificate), - testPort = packageServer.port + testPort = packageServer.port, ), listOf(tempDir.resolve("project")), CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = false, - consoleWriter = StringWriter() + consoleWriter = StringWriter(), ) .run() } @@ -968,20 +968,20 @@ class CliProjectPackagerTest { packageZipUrl = "https://foo.com" } """ - .trimIndent() + .trimIndent(), ) val out = StringWriter() CliProjectPackager( CliBaseOptions( workingDir = tempDir, caCertificates = listOf(FileTestUtils.selfSignedCertificate), - testPort = packageServer.port + testPort = packageServer.port, ), listOf(tempDir.resolve("project")), CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = false, - consoleWriter = out + consoleWriter = out, ) .run() val sep = File.separatorChar @@ -1025,7 +1025,7 @@ class CliProjectPackagerTest { CliTestOptions(), ".out/%{name}@%{version}", skipPublishCheck = true, - consoleWriter = StringWriter() + consoleWriter = StringWriter(), ) packager.run() val expectedMetadata = tempDir.resolve(".out/mypackage@1.0.0/mypackage@1.0.0") diff --git a/pkl-cli/src/test/kotlin/org/pkl/cli/CliProjectResolverTest.kt b/pkl-cli/src/test/kotlin/org/pkl/cli/CliProjectResolverTest.kt index cda4d46d..451016c3 100644 --- a/pkl-cli/src/test/kotlin/org/pkl/cli/CliProjectResolverTest.kt +++ b/pkl-cli/src/test/kotlin/org/pkl/cli/CliProjectResolverTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ class CliProjectResolverTest { CliBaseOptions(workingDir = tempDir, noCache = true), emptyList(), consoleWriter = StringWriter(), - errWriter = StringWriter() + errWriter = StringWriter(), ) val err = assertThrows { packager.run() } assertThat(err).hasMessageStartingWith("No project visible to the working directory.") @@ -60,7 +60,7 @@ class CliProjectResolverTest { CliBaseOptions(noCache = true), listOf(tempDir), consoleWriter = StringWriter(), - errWriter = StringWriter() + errWriter = StringWriter(), ) val err = assertThrows { packager.run() } assertThat(err).hasMessageStartingWith("Directory $tempDir does not contain a PklProject file.") @@ -79,18 +79,18 @@ class CliProjectResolverTest { } } """ - .trimIndent() + .trimIndent(), ) CliProjectResolver( CliBaseOptions( workingDir = tempDir, caCertificates = listOf(FileTestUtils.selfSignedCertificate), testPort = packageServer.port, - noCache = true + noCache = true, ), listOf(tempDir), consoleWriter = StringWriter(), - errWriter = StringWriter() + errWriter = StringWriter(), ) .run() val expectedOutput = tempDir.resolve("PklProject.deps.json") @@ -134,18 +134,18 @@ class CliProjectResolverTest { } } """ - .trimIndent() + .trimIndent(), ) CliProjectResolver( CliBaseOptions( workingDir = tempDir, caCertificates = listOf(FileTestUtils.selfSignedCertificate), testPort = packageServer.port, - noCache = true + noCache = true, ), emptyList(), consoleWriter = StringWriter(), - errWriter = StringWriter() + errWriter = StringWriter(), ) .run() val expectedOutput = tempDir.resolve("PklProject.deps.json") @@ -191,7 +191,7 @@ class CliProjectResolverTest { ["project2"] = import("../project2/PklProject") } """ - .trimIndent() + .trimIndent(), ) projectDir.writeFile( "../project2/PklProject", @@ -212,7 +212,7 @@ class CliProjectResolverTest { ["project3"] = import("../project3/PklProject") } """ - .trimIndent() + .trimIndent(), ) projectDir.writeFile( @@ -233,17 +233,17 @@ class CliProjectResolverTest { } } """ - .trimIndent() + .trimIndent(), ) CliProjectResolver( CliBaseOptions( caCertificates = listOf(FileTestUtils.selfSignedCertificate), testPort = packageServer.port, - noCache = true + noCache = true, ), listOf(projectDir), consoleWriter = StringWriter(), - errWriter = StringWriter() + errWriter = StringWriter(), ) .run() val expectedOutput = projectDir.resolve("PklProject.deps.json") @@ -299,7 +299,7 @@ class CliProjectResolverTest { ["fruit"] = import("../fruit/PklProject") } """ - .trimIndent() + .trimIndent(), ) projectDir.writeFile( "../fruit/PklProject", @@ -313,7 +313,7 @@ class CliProjectResolverTest { packageZipUrl = "https://foo.com/fruit.zip" } """ - .trimIndent() + .trimIndent(), ) val consoleOut = StringWriter() val errOut = StringWriter() @@ -321,11 +321,11 @@ class CliProjectResolverTest { CliBaseOptions( caCertificates = listOf(FileTestUtils.selfSignedCertificate), testPort = packageServer.port, - noCache = true + noCache = true, ), listOf(projectDir), consoleWriter = consoleOut, - errWriter = errOut + errWriter = errOut, ) .run() val expectedOutput = projectDir.resolve("PklProject.deps.json") @@ -373,7 +373,7 @@ class CliProjectResolverTest { } } """ - .trimIndent() + .trimIndent(), ) tempDir.writeFile( @@ -387,7 +387,7 @@ class CliProjectResolverTest { } } """ - .trimIndent() + .trimIndent(), ) val consoleOut = StringWriter() @@ -396,11 +396,11 @@ class CliProjectResolverTest { CliBaseOptions( caCertificates = listOf(FileTestUtils.selfSignedCertificate), testPort = packageServer.port, - noCache = true + noCache = true, ), listOf(tempDir.resolve("project1"), tempDir.resolve("project2")), consoleWriter = consoleOut, - errWriter = errOut + errWriter = errOut, ) .run() val sep = File.separatorChar diff --git a/pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/CliJavaCodeGeneratorOptions.kt b/pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/CliJavaCodeGeneratorOptions.kt index cc977559..5735486e 100644 --- a/pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/CliJavaCodeGeneratorOptions.kt +++ b/pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/CliJavaCodeGeneratorOptions.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ data class CliJavaCodeGeneratorOptions( * Pkl module names, you can define a rename mapping, where the key is a prefix of the original * Pkl module name, and the value is the desired replacement. */ - val renames: Map = emptyMap() + val renames: Map = emptyMap(), ) { @Suppress("DeprecatedCallableAddReplaceWith") @Deprecated("deprecated without replacement") @@ -88,6 +88,6 @@ data class CliJavaCodeGeneratorOptions( paramsAnnotation, nonNullAnnotation, implementSerializable, - renames + renames, ) } diff --git a/pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/CliJavaCodeGeneratorTest.kt b/pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/CliJavaCodeGeneratorTest.kt index 4d5febda..d2f4fca0 100644 --- a/pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/CliJavaCodeGeneratorTest.kt +++ b/pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/CliJavaCodeGeneratorTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ class CliJavaCodeGeneratorTest { name: String age: Int } - """ + """, ) val module2 = @@ -53,7 +53,7 @@ class CliJavaCodeGeneratorTest { extends "mod1.pkl" parrot: Person - """ + """, ) val module1File = module1.writeToDisk(tempDir.resolve("org/mod1.pkl")) @@ -64,7 +64,7 @@ class CliJavaCodeGeneratorTest { CliJavaCodeGenerator( CliJavaCodeGeneratorOptions( CliBaseOptions(listOf(module1File.toUri(), module2File.toUri())), - outputDir + outputDir, ) ) @@ -82,7 +82,7 @@ class CliJavaCodeGeneratorTest { |public class Mod1 { | public final @NonNull Person pigeon; """, - module1JavaFile.readString() + module1JavaFile.readString(), ) val module2JavaFile = javaDir.resolve("org/Mod2.java") @@ -91,7 +91,7 @@ class CliJavaCodeGeneratorTest { |public final class Mod2 extends Mod1 { | public final Mod1. @NonNull Person parrot; """, - module2JavaFile.readString() + module2JavaFile.readString(), ) val resourcesDir = outputDir.resolve("resources/META-INF/org/pkl/config/java/mapper/classes/") @@ -101,18 +101,18 @@ class CliJavaCodeGeneratorTest { // use two assertions because java.util.Properties doesn't guarantee order assertContains( """org.pkl.config.java.mapper.org.mod1\#Person=org.Mod1${dollar}Person""", - module1PropertiesString + module1PropertiesString, ) assertContains( """org.pkl.config.java.mapper.org.mod1\#ModuleClass=org.Mod1""", - module1PropertiesString + module1PropertiesString, ) val module2PropertiesFile = resourcesDir.resolve("org.mod2.properties") assertContains( """org.pkl.config.java.mapper.org.mod2\#ModuleClass=org.Mod2""", - module2PropertiesFile.readString() + module2PropertiesFile.readString(), ) } @@ -127,7 +127,7 @@ class CliJavaCodeGeneratorTest { class Person { name: String } - """ + """, ) val module2 = @@ -144,7 +144,7 @@ class CliJavaCodeGeneratorTest { class Person { age: Int } - """ + """, ) val module1PklFile = module1.writeToDisk(tempDir.resolve("org/mod1.pkl")) @@ -155,7 +155,7 @@ class CliJavaCodeGeneratorTest { CliJavaCodeGenerator( CliJavaCodeGeneratorOptions( CliBaseOptions(listOf(module1PklFile.toUri(), module2PklFile.toUri())), - outputDir + outputDir, ) ) @@ -169,7 +169,7 @@ class CliJavaCodeGeneratorTest { | | public final @NonNull Person person2; """, - module2JavaFile.readString() + module2JavaFile.readString(), ) } @@ -184,7 +184,7 @@ class CliJavaCodeGeneratorTest { class Person { name: String } - """ + """, ) val module2 = @@ -199,7 +199,7 @@ class CliJavaCodeGeneratorTest { owner: Module1.Person name: String } - """ + """, ) val module3 = @@ -213,7 +213,7 @@ class CliJavaCodeGeneratorTest { class Supergroup { owner: Module2.Group } - """ + """, ) val module1PklFile = module1.writeToDisk(tempDir.resolve("org/foo/Module1.pkl")) @@ -226,7 +226,7 @@ class CliJavaCodeGeneratorTest { CliJavaCodeGeneratorOptions( CliBaseOptions(listOf(module1PklFile, module2PklFile, module3PklFile).map { it.toUri() }), outputDir, - renames = mapOf("org.foo" to "com.foo.x", "org.baz" to "com.baz.a.b") + renames = mapOf("org.foo" to "com.foo.x", "org.baz" to "com.baz.a.b"), ) ) @@ -243,7 +243,7 @@ class CliJavaCodeGeneratorTest { | public static final class Person { | public final @NonNull String name; """, - it + it, ) } @@ -260,7 +260,7 @@ class CliJavaCodeGeneratorTest { | public static final class Group { | public final Module1. @NonNull Person owner; """, - it + it, ) } @@ -277,7 +277,7 @@ class CliJavaCodeGeneratorTest { | public static final class Supergroup { | public final Module2. @NonNull Group owner; """, - it + it, ) } } diff --git a/pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/InMemoryJavaCompiler.kt b/pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/InMemoryJavaCompiler.kt index e80d07e6..4b42eafe 100644 --- a/pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/InMemoryJavaCompiler.kt +++ b/pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/InMemoryJavaCompiler.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ private class InMemoryFileManager(delegate: JavaFileManager) : location: JavaFileManager.Location, className: String, kind: JavaFileObject.Kind, - sibling: FileObject + sibling: FileObject, ): JavaFileObject { return WritableBinaryFileObject(className, kind).also { outputFiles[className] = it } diff --git a/pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/JavaCodeGeneratorTest.kt b/pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/JavaCodeGeneratorTest.kt index a744293b..5d4fffc6 100644 --- a/pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/JavaCodeGeneratorTest.kt +++ b/pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/JavaCodeGeneratorTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -104,7 +104,7 @@ class JavaCodeGeneratorTest { private fun generateJavaCode( pklCode: String, - options: JavaCodeGeneratorOptions = JavaCodeGeneratorOptions() + options: JavaCodeGeneratorOptions = JavaCodeGeneratorOptions(), ): JavaSourceCode { val module = Evaluator.preconfigured().evaluateSchema(text(pklCode)) val generator = JavaCodeGenerator(module, options) @@ -219,7 +219,7 @@ class JavaCodeGeneratorTest { } """ .trimIndent(), - JavaCodeGeneratorOptions(generateJavadoc = true) + JavaCodeGeneratorOptions(generateJavadoc = true), ) assertThat(javaCode) .contains( @@ -258,7 +258,7 @@ class JavaCodeGeneratorTest { } """ .trimIndent(), - JavaCodeGeneratorOptions(generateGetters = true, generateJavadoc = true) + JavaCodeGeneratorOptions(generateGetters = true, generateJavadoc = true), ) assertThat(javaCode) .contains( @@ -305,7 +305,7 @@ class JavaCodeGeneratorTest { } """ .trimIndent(), - JavaCodeGeneratorOptions(generateJavadoc = true) + JavaCodeGeneratorOptions(generateJavadoc = true), ) assertThat(javaCode) .contains( @@ -332,7 +332,7 @@ class JavaCodeGeneratorTest { propertyInDeprecatedModuleClass : Int = 42 """ .trimIndent(), - JavaCodeGeneratorOptions(generateJavadoc = generateJavadoc) + JavaCodeGeneratorOptions(generateJavadoc = generateJavadoc), ) assertThat(javaCode) @@ -372,7 +372,7 @@ class JavaCodeGeneratorTest { """ .trimIndent(), // no message, so no Javadoc, regardless of flag - JavaCodeGeneratorOptions(generateJavadoc = generateJavadoc) + JavaCodeGeneratorOptions(generateJavadoc = generateJavadoc), ) assertThat(javaCode) @@ -407,7 +407,7 @@ class JavaCodeGeneratorTest { } """ .trimIndent(), - JavaCodeGeneratorOptions(generateGetters = true) + JavaCodeGeneratorOptions(generateGetters = true), ) assertThat(javaCode) @@ -496,7 +496,7 @@ class JavaCodeGeneratorTest { @Deprecated { message = "property is deprecated" } deprecatedProperty: Int """, - JavaCodeGeneratorOptions(generateJavadoc = true) + JavaCodeGeneratorOptions(generateJavadoc = true), ) assertThat(javaCode) @@ -564,7 +564,7 @@ class JavaCodeGeneratorTest { "digit-1" to "DIGIT_1", "42" to "_42", "àœü" to "ÀŒÜ", - "日本-つくば" to "日本_つくば" + "日本-つくば" to "日本_つくば", ) val javaCode = generateJavaCode( @@ -586,7 +586,7 @@ class JavaCodeGeneratorTest { assertThat(field.name).isEqualTo(kotlinName) Unit } - } + }, ) assertAll( @@ -596,7 +596,7 @@ class JavaCodeGeneratorTest { assertThat(enumConstant.toString()).isEqualTo(pklName) Unit } - } + }, ) } @@ -718,7 +718,7 @@ class JavaCodeGeneratorTest { } """ .trimIndent(), - JavaCodeGeneratorOptions(generateGetters = true) + JavaCodeGeneratorOptions(generateGetters = true), ) assertThat(javaCode) @@ -872,7 +872,7 @@ class JavaCodeGeneratorTest { } """ .trimIndent(), - JavaCodeGeneratorOptions(generateGetters = true) + JavaCodeGeneratorOptions(generateGetters = true), ) assertThat(javaCode).compilesSuccessfully().isEqualToResourceFile("GenerateGetters.jva") @@ -985,7 +985,7 @@ class JavaCodeGeneratorTest { } """ .trimIndent(), - JavaCodeGeneratorOptions(generateJavadoc = true) + JavaCodeGeneratorOptions(generateJavadoc = true), ) assertThat(javaCode).compilesSuccessfully().isEqualToResourceFile("Javadoc.jva") @@ -1009,7 +1009,7 @@ class JavaCodeGeneratorTest { } """ .trimIndent(), - JavaCodeGeneratorOptions(generateGetters = true, generateJavadoc = true) + JavaCodeGeneratorOptions(generateGetters = true, generateJavadoc = true), ) assertThat(javaCode) @@ -1151,7 +1151,7 @@ class JavaCodeGeneratorTest { foo: String """ .trimIndent(), - JavaCodeGeneratorOptions(nonNullAnnotation = "com.example.Annotations\$NonNull") + JavaCodeGeneratorOptions(nonNullAnnotation = "com.example.Annotations\$NonNull"), ) assertThat(javaCode) @@ -1455,7 +1455,7 @@ class JavaCodeGeneratorTest { name: String """ .trimIndent(), - JavaCodeGeneratorOptions(paramsAnnotation = "org.project.MyAnnotation") + JavaCodeGeneratorOptions(paramsAnnotation = "org.project.MyAnnotation"), ) assertThat(javaCode) @@ -1473,7 +1473,7 @@ class JavaCodeGeneratorTest { name: String """ .trimIndent(), - JavaCodeGeneratorOptions(paramsAnnotation = null) + JavaCodeGeneratorOptions(paramsAnnotation = null), ) assertThat(javaCode).contains("public Mod(@NonNull String name)") @@ -1494,7 +1494,7 @@ class JavaCodeGeneratorTest { } """ .trimIndent(), - JavaCodeGeneratorOptions(generateSpringBootConfig = true) + JavaCodeGeneratorOptions(generateSpringBootConfig = true), ) assertThat(javaCode) @@ -1548,7 +1548,7 @@ class JavaCodeGeneratorTest { pigeon: Person """ - .trimIndent() + .trimIndent(), ) val client = @@ -1563,7 +1563,7 @@ class JavaCodeGeneratorTest { parrot: library.Person """ - .trimIndent() + .trimIndent(), ) val javaSourceFiles = generateFiles(library, client) @@ -1595,7 +1595,7 @@ class JavaCodeGeneratorTest { pigeon: Person """ - .trimIndent() + .trimIndent(), ) val derived = @@ -1610,7 +1610,7 @@ class JavaCodeGeneratorTest { person1: Person person2: Person2 """ - .trimIndent() + .trimIndent(), ) val javaSourceFiles = generateFiles(base, derived) @@ -1646,7 +1646,7 @@ class JavaCodeGeneratorTest { typealias Version = "LATEST"|String """ - .trimIndent() + .trimIndent(), ) val derived = @@ -1659,7 +1659,7 @@ class JavaCodeGeneratorTest { v: Version = "1.2.3" """ - .trimIndent() + .trimIndent(), ) val javaSourceFiles = generateFiles(base, derived) @@ -1697,7 +1697,7 @@ class JavaCodeGeneratorTest { prop: Int } """ - .trimIndent() + .trimIndent(), ) val generated = generateFiles(pklModule) val expectedPropertyFile = @@ -1730,7 +1730,7 @@ class JavaCodeGeneratorTest { prop: Int } """ - .trimIndent() + .trimIndent(), ) val generated = generateFiles(pklModule) val expectedPropertyFile = @@ -1782,7 +1782,7 @@ class JavaCodeGeneratorTest { typealias Direction = "north"|"east"|"south"|"west" """ .trimIndent(), - JavaCodeGeneratorOptions(implementSerializable = true) + JavaCodeGeneratorOptions(implementSerializable = true), ) assertThat(javaCode) @@ -1821,7 +1821,7 @@ class JavaCodeGeneratorTest { smallStruct, Pattern.compile("(i?)\\w*"), smallStruct, - enumValue + enumValue, ) fun confirmSerDe(instance: Any) { @@ -1863,7 +1863,7 @@ class JavaCodeGeneratorTest { abstract class Foo { str: String } """ .trimIndent(), - JavaCodeGeneratorOptions(implementSerializable = true) + JavaCodeGeneratorOptions(implementSerializable = true), ) assertThat(javaCode).doesNotContain("Serializable") @@ -1874,7 +1874,7 @@ class JavaCodeGeneratorTest { module my.mod """ .trimIndent(), - JavaCodeGeneratorOptions(implementSerializable = true) + JavaCodeGeneratorOptions(implementSerializable = true), ) assertThat(javaCode).doesNotContain("Serializable") @@ -1891,7 +1891,7 @@ class JavaCodeGeneratorTest { class Address { city: String } """ .trimIndent(), - JavaCodeGeneratorOptions(implementSerializable = true) + JavaCodeGeneratorOptions(implementSerializable = true), ) assertThat(javaCode) @@ -1977,7 +1977,7 @@ class JavaCodeGeneratorTest { } """ .trimIndent(), - JavaCodeGeneratorOptions(generateGetters = true) + JavaCodeGeneratorOptions(generateGetters = true), ) assertThat(javaCode) @@ -2021,7 +2021,7 @@ class JavaCodeGeneratorTest { bar: Int = 123 """ - .trimIndent() + .trimIndent(), ) .toMutableMap() @@ -2064,7 +2064,7 @@ class JavaCodeGeneratorTest { baz: String """ - .trimIndent() + .trimIndent(), ) files.validateContents( @@ -2090,7 +2090,7 @@ class JavaCodeGeneratorTest { mapOf( "org.foo." to "com.foo.x.", "org.bar.Module2" to "org.bar.RenamedModule", - "org.baz." to "com.baz.a.b." + "org.baz." to "com.baz.a.b.", ) ) .generateFiles( @@ -2125,7 +2125,7 @@ class JavaCodeGeneratorTest { owner: Module2.Group } """ - .trimIndent() + .trimIndent(), ) files.validateContents( @@ -2141,7 +2141,7 @@ class JavaCodeGeneratorTest { "package org.bar;", "import com.foo.x.Module1;", "public final class RenamedModule {", - "public final Module1. @NonNull Person owner;" + "public final Module1. @NonNull Person owner;", ), "$MAPPER_PREFIX/org.bar.Module2.properties" to listOf( @@ -2154,7 +2154,7 @@ class JavaCodeGeneratorTest { "package com.baz.a.b;", "import org.bar.RenamedModule;", "public final class Module3 {", - "public final RenamedModule. @NonNull Group owner;" + "public final RenamedModule. @NonNull Group owner;", ), "$MAPPER_PREFIX/org.baz.Module3.properties" to listOf( @@ -2184,7 +2184,7 @@ class JavaCodeGeneratorTest { bar: Int = 123 """ - .trimIndent() + .trimIndent(), ) files.validateContents( @@ -2312,7 +2312,7 @@ class JavaCodeGeneratorTest { Pattern.compile("(i?)\\w*"), other, other, - enumValue + enumValue, ) return other to propertyTypes diff --git a/pkl-codegen-kotlin/src/main/kotlin/org/pkl/codegen/kotlin/CliKotlinCodeGeneratorOptions.kt b/pkl-codegen-kotlin/src/main/kotlin/org/pkl/codegen/kotlin/CliKotlinCodeGeneratorOptions.kt index f4ae6b52..762ae84c 100644 --- a/pkl-codegen-kotlin/src/main/kotlin/org/pkl/codegen/kotlin/CliKotlinCodeGeneratorOptions.kt +++ b/pkl-codegen-kotlin/src/main/kotlin/org/pkl/codegen/kotlin/CliKotlinCodeGeneratorOptions.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ data class CliKotlinCodeGeneratorOptions( * from Pkl module names, you can define a rename mapping, where the key is a prefix of the * original Pkl module name, and the value is the desired replacement. */ - val renames: Map = emptyMap() + val renames: Map = emptyMap(), ) { @Suppress("DeprecatedCallableAddReplaceWith") @Deprecated("deprecated without replacement") @@ -57,6 +57,6 @@ data class CliKotlinCodeGeneratorOptions( generateKdoc, generateSpringBootConfig, implementSerializable, - renames + renames, ) } diff --git a/pkl-codegen-kotlin/src/test/kotlin/org/pkl/codegen/kotlin/CliKotlinCodeGeneratorTest.kt b/pkl-codegen-kotlin/src/test/kotlin/org/pkl/codegen/kotlin/CliKotlinCodeGeneratorTest.kt index f2a593e7..a9c53808 100644 --- a/pkl-codegen-kotlin/src/test/kotlin/org/pkl/codegen/kotlin/CliKotlinCodeGeneratorTest.kt +++ b/pkl-codegen-kotlin/src/test/kotlin/org/pkl/codegen/kotlin/CliKotlinCodeGeneratorTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ class CliKotlinCodeGeneratorTest { name: String age: Int } - """ + """, ) val module2 = @@ -49,7 +49,7 @@ class CliKotlinCodeGeneratorTest { extends "mod1.pkl" parrot: Person - """ + """, ) val module1File = module1.writeToDisk(tempDir.resolve("org/mod1.pkl")) @@ -60,7 +60,7 @@ class CliKotlinCodeGeneratorTest { CliKotlinCodeGenerator( CliKotlinCodeGeneratorOptions( CliBaseOptions(listOf(module1File.toUri(), module2File.toUri())), - outputDir + outputDir, ) ) @@ -79,7 +79,7 @@ class CliKotlinCodeGeneratorTest { ) { """ .trimIndent(), - module1KotlinFile.readString() + module1KotlinFile.readString(), ) assertContains( @@ -90,7 +90,7 @@ class CliKotlinCodeGeneratorTest { ) : Mod1(pigeon) { """ .trimIndent(), - module2KotlinFile.readString() + module2KotlinFile.readString(), ) } @@ -105,7 +105,7 @@ class CliKotlinCodeGeneratorTest { class Person { name: String } - """ + """, ) val module2 = @@ -122,7 +122,7 @@ class CliKotlinCodeGeneratorTest { class Person { age: Int } - """ + """, ) val module1PklFile = module1.writeToDisk(tempDir.resolve("org/mod1.pkl")) @@ -133,7 +133,7 @@ class CliKotlinCodeGeneratorTest { CliKotlinCodeGenerator( CliKotlinCodeGeneratorOptions( CliBaseOptions(listOf(module1PklFile.toUri(), module2PklFile.toUri())), - outputDir + outputDir, ) ) @@ -148,7 +148,7 @@ class CliKotlinCodeGeneratorTest { ) """ .trimIndent(), - module2KotlinFile.readString() + module2KotlinFile.readString(), ) } @@ -163,7 +163,7 @@ class CliKotlinCodeGeneratorTest { class Person { name: String } - """ + """, ) val module2 = @@ -178,7 +178,7 @@ class CliKotlinCodeGeneratorTest { owner: Module1.Person name: String } - """ + """, ) val module3 = @@ -192,7 +192,7 @@ class CliKotlinCodeGeneratorTest { class Supergroup { owner: Module2.Group } - """ + """, ) val module1PklFile = module1.writeToDisk(tempDir.resolve("org/foo/Module1.pkl")) @@ -205,7 +205,7 @@ class CliKotlinCodeGeneratorTest { CliKotlinCodeGeneratorOptions( CliBaseOptions(listOf(module1PklFile, module2PklFile, module3PklFile).map { it.toUri() }), outputDir, - renames = mapOf("org.foo" to "com.foo.x", "org.baz" to "com.baz.a.b") + renames = mapOf("org.foo" to "com.foo.x", "org.baz" to "com.baz.a.b"), ) ) @@ -223,7 +223,7 @@ class CliKotlinCodeGeneratorTest { | val name: String | ) """, - it + it, ) } @@ -242,7 +242,7 @@ class CliKotlinCodeGeneratorTest { | val name: String | ) """, - it + it, ) } @@ -260,7 +260,7 @@ class CliKotlinCodeGeneratorTest { | val owner: Module2.Group | ) """, - it + it, ) } } diff --git a/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/CliException.kt b/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/CliException.kt index 6d41d662..cec55b28 100644 --- a/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/CliException.kt +++ b/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/CliException.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ open class CliException( message: String, /** The process exit code to use. */ - val exitCode: Int = 1 + val exitCode: Int = 1, ) : RuntimeException(message) { override fun toString(): String = message!! @@ -39,7 +39,7 @@ class CliBugException( private val theCause: Exception, /** The process exit code to use. */ - exitCode: Int = 1 + exitCode: Int = 1, ) : CliException("An unexpected error has occurred. Would you mind filing a bug report?", exitCode) { diff --git a/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/commands/OptionExtensions.kt b/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/commands/OptionExtensions.kt index da88671d..1f0a21e4 100644 --- a/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/commands/OptionExtensions.kt +++ b/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/commands/OptionExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ fun NullableOption.single(): NullableOption */ fun NullableOption.splitAll( separator: String = ",", - default: List = emptyList() + default: List = emptyList(), ): OptionWithValues, List, ValueT> { return copy( transformValue = transformValue, @@ -44,6 +44,6 @@ fun NullableOption.splitAll( transformAll = { it.flatten().ifEmpty { default } }, validator = {}, nvalues = 1, - valueSplit = Regex.fromLiteral(separator) + valueSplit = Regex.fromLiteral(separator), ) } diff --git a/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/commands/ProjectOptions.kt b/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/commands/ProjectOptions.kt index 4c39eee0..ffef154e 100644 --- a/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/commands/ProjectOptions.kt +++ b/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/commands/ProjectOptions.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ class ProjectOptions : OptionGroup() { names = arrayOf("--project-dir"), metavar = "", help = - "The project directory to use for this command. By default, searches up from the working directory for a PklProject file." + "The project directory to use for this command. By default, searches up from the working directory for a PklProject file.", ) .single() .path() @@ -39,7 +39,7 @@ class ProjectOptions : OptionGroup() { val omitProjectSettings: Boolean by option( names = arrayOf("--omit-project-settings"), - help = "Ignores evaluator settings set in the PklProject file." + help = "Ignores evaluator settings set in the PklProject file.", ) .single() .flag(default = false) @@ -47,7 +47,7 @@ class ProjectOptions : OptionGroup() { val noProject: Boolean by option( names = arrayOf("--no-project"), - help = "Disables loading settings and dependencies from the PklProject file." + help = "Disables loading settings and dependencies from the PklProject file.", ) .single() .flag(default = false) diff --git a/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/commands/TestOptions.kt b/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/commands/TestOptions.kt index da735fac..ea934bac 100644 --- a/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/commands/TestOptions.kt +++ b/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/commands/TestOptions.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ class TestOptions : OptionGroup() { option( names = arrayOf("--junit-reports"), metavar = "", - help = "Directory where to store JUnit reports." + help = "Directory where to store JUnit reports.", ) .path() diff --git a/pkl-commons-test/pkl-commons-test.gradle.kts b/pkl-commons-test/pkl-commons-test.gradle.kts index 8e6c7e4b..7c51898b 100644 --- a/pkl-commons-test/pkl-commons-test.gradle.kts +++ b/pkl-commons-test/pkl-commons-test.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -107,7 +107,7 @@ val generateKeys by "-storepass", "password", "-dname", - "CN=localhost" + "CN=localhost", ) workingDir(keystoreDir) doFirst { @@ -134,7 +134,7 @@ val exportCerts by keystoreName, "-rfc", "-file", - certsFileName + certsFileName, ) workingDir(keystoreDir) doFirst { diff --git a/pkl-commons/src/test/kotlin/org/pkl/commons/NameMapperTest.kt b/pkl-commons/src/test/kotlin/org/pkl/commons/NameMapperTest.kt index 6cd92bf4..fd4a61f3 100644 --- a/pkl-commons/src/test/kotlin/org/pkl/commons/NameMapperTest.kt +++ b/pkl-commons/src/test/kotlin/org/pkl/commons/NameMapperTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,14 +43,7 @@ class NameMapperTest { @Test fun `no implicit uppercased classname if explicitly renamed`() { - val mapper = - NameMapper( - mapOf( - "foo.bar" to "bar.bar", - "foo.c" to "foo.z", - "com.foo." to "x", - ) - ) + val mapper = NameMapper(mapOf("foo.bar" to "bar.bar", "foo.c" to "foo.z", "com.foo." to "x")) assertThat(mapper.map("foo.bar")).isEqualTo("bar" to "bar") assertThat(mapper.map("foo.bar")).isEqualTo("bar" to "bar") assertThat(mapper.map("foo.cow")).isEqualTo("foo" to "zow") diff --git a/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/mapper/KotlinConversions.kt b/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/mapper/KotlinConversions.kt index a8225dca..a04ab6e2 100644 --- a/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/mapper/KotlinConversions.kt +++ b/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/mapper/KotlinConversions.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,7 +84,7 @@ object KotlinConversions { pIntToUShort, pIntToUByte, pStringToKotlinRegex, - pRegexToKotlinRegex + pRegexToKotlinRegex, ) ) } diff --git a/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/mapper/PPairToKotlinPair.kt b/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/mapper/PPairToKotlinPair.kt index 5b043bee..cf93536a 100644 --- a/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/mapper/PPairToKotlinPair.kt +++ b/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/mapper/PPairToKotlinPair.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ internal class PPairToKotlinPair : ConverterFactory { private class ConverterImpl( private val firstTargetType: Type, - private val secondTargetType: Type + private val secondTargetType: Type, ) : Converter, Pair> { private var firstCachedType = PClassInfo.Unavailable @@ -68,7 +68,7 @@ internal class PPairToKotlinPair : ConverterFactory { return Pair( firstCachedConverter!!.convert(first, valueMapper), - secondCachedConverter!!.convert(second, valueMapper) + secondCachedConverter!!.convert(second, valueMapper), ) } } diff --git a/pkl-config-kotlin/src/test/kotlin/org/pkl/config/kotlin/KotlinObjectMappingTest.kt b/pkl-config-kotlin/src/test/kotlin/org/pkl/config/kotlin/KotlinObjectMappingTest.kt index 76a99e00..8a69a8d4 100644 --- a/pkl-config-kotlin/src/test/kotlin/org/pkl/config/kotlin/KotlinObjectMappingTest.kt +++ b/pkl-config-kotlin/src/test/kotlin/org/pkl/config/kotlin/KotlinObjectMappingTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ class KotlinObjectMappingTest { // Map & Mapping with structured keys val intListingStringMapping: Map, String>, val intSetListStringMapping: Map>, String>, - val thisOneGoesToEleven: Map>, Map, Map>> + val thisOneGoesToEleven: Map>, Map, Map>>, ) @Test diff --git a/pkl-config-kotlin/src/test/kotlin/org/pkl/config/kotlin/mapper/PPairToKotlinPairTest.kt b/pkl-config-kotlin/src/test/kotlin/org/pkl/config/kotlin/mapper/PPairToKotlinPairTest.kt index 00d64dfd..a68356bf 100644 --- a/pkl-config-kotlin/src/test/kotlin/org/pkl/config/kotlin/mapper/PPairToKotlinPairTest.kt +++ b/pkl-config-kotlin/src/test/kotlin/org/pkl/config/kotlin/mapper/PPairToKotlinPairTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ class PPairToKotlinPairTest { val mapped: Pair = mapper.map( ex1, - Types.parameterizedType(Pair::class.java, Integer::class.java, Duration::class.java) + Types.parameterizedType(Pair::class.java, Integer::class.java, Duration::class.java), ) assertThat(mapped).isEqualTo(Pair(1, Duration(3.0, DurationUnit.SECONDS))) } @@ -60,7 +60,7 @@ class PPairToKotlinPairTest { val mapped: Pair = mapper.map( ex2, - Types.parameterizedType(Pair::class.java, PObject::class.java, PObject::class.java) + Types.parameterizedType(Pair::class.java, PObject::class.java, PObject::class.java), ) assertThat(mapped.first.properties).containsOnly(entry("name", "pigeon"), entry("age", 40L)) diff --git a/pkl-core/src/generator/kotlin/org/pkl/core/generator/MemberRegistryGenerator.kt b/pkl-core/src/generator/kotlin/org/pkl/core/generator/MemberRegistryGenerator.kt index d565727f..01d969e9 100644 --- a/pkl-core/src/generator/kotlin/org/pkl/core/generator/MemberRegistryGenerator.kt +++ b/pkl-core/src/generator/kotlin/org/pkl/core/generator/MemberRegistryGenerator.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,7 +80,7 @@ class MemberRegistryGenerator : AbstractProcessor() { if (it.enclosingElement.kind == ElementKind.PACKAGE) "" else it.enclosingElement.simpleName.toString() }, - { it.simpleName.toString() } + { it.simpleName.toString() }, ) ) .groupBy { processingEnv.elementUtils.getPackageOf(it) } @@ -126,7 +126,7 @@ class MemberRegistryGenerator : AbstractProcessor() { registryClassConstructor.addStatement( "register(\$S, \$T::create)", pklMemberNameQualified, - nodeClass + nodeClass, ) } diff --git a/pkl-core/src/main/java/org/pkl/core/util/CodeGeneratorUtils.java b/pkl-core/src/main/java/org/pkl/core/util/CodeGeneratorUtils.java index 1a5962e7..05761ac2 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/CodeGeneratorUtils.java +++ b/pkl-core/src/main/java/org/pkl/core/util/CodeGeneratorUtils.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -118,14 +118,14 @@ public final class CodeGeneratorUtils { */ private static boolean isValidIdentifierPart(int codePoint, int category) { return switch (category) { - // NOT Character.CURRENCY_SYMBOL, which is valid in Java, but invalid in Kotlin + // NOT Character.CURRENCY_SYMBOL, which is valid in Java, but invalid in Kotlin case Character.LOWERCASE_LETTER, - Character.UPPERCASE_LETTER, - Character.MODIFIER_LETTER, - Character.OTHER_LETTER, - Character.TITLECASE_LETTER, - Character.LETTER_NUMBER, - Character.DECIMAL_DIGIT_NUMBER -> + Character.UPPERCASE_LETTER, + Character.MODIFIER_LETTER, + Character.OTHER_LETTER, + Character.TITLECASE_LETTER, + Character.LETTER_NUMBER, + Character.DECIMAL_DIGIT_NUMBER -> true; default -> codePoint == UNDERSCORE; }; @@ -133,18 +133,18 @@ public final class CodeGeneratorUtils { private static boolean isPunctuationOrSpacing(int category) { return switch (category) { - // Punctuation + // Punctuation case Character.CONNECTOR_PUNCTUATION, // Pc - Character.DASH_PUNCTUATION, // Pd - Character.START_PUNCTUATION, // Ps - Character.END_PUNCTUATION, // Pe - Character.INITIAL_QUOTE_PUNCTUATION, // Pi - Character.FINAL_QUOTE_PUNCTUATION, // Pf - Character.OTHER_PUNCTUATION, // Po - // Spacing - Character.SPACE_SEPARATOR, // Zs - Character.LINE_SEPARATOR, // Zl - Character.PARAGRAPH_SEPARATOR -> // Zp + Character.DASH_PUNCTUATION, // Pd + Character.START_PUNCTUATION, // Ps + Character.END_PUNCTUATION, // Pe + Character.INITIAL_QUOTE_PUNCTUATION, // Pi + Character.FINAL_QUOTE_PUNCTUATION, // Pf + Character.OTHER_PUNCTUATION, // Po + // Spacing + Character.SPACE_SEPARATOR, // Zs + Character.LINE_SEPARATOR, // Zl + Character.PARAGRAPH_SEPARATOR -> // Zp true; default -> false; }; diff --git a/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java b/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java index 4e7cefd4..eedcb559 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java +++ b/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -227,7 +227,7 @@ public final class GlobResolver { sb.append("!"); } - // no special meaning in glob patterns but have special meaning in regex. + // no special meaning in glob patterns but have special meaning in regex. case '.', '(', '%', '^', '$', '|' -> sb.append("\\").append(current); default -> sb.append(current); } diff --git a/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java b/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java index 6f1809e8..d1065454 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java +++ b/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -611,27 +611,27 @@ public final class IoUtils { public static boolean isHexDigit(char ch) { return switch (ch) { case '0', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - 'A', - 'B', - 'C', - 'D', - 'E', - 'F', - 'a', - 'b', - 'c', - 'd', - 'e', - 'f' -> + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + 'A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'a', + 'b', + 'c', + 'd', + 'e', + 'f' -> true; default -> false; }; @@ -640,28 +640,28 @@ public final class IoUtils { public static boolean isHexDigitOrUnderscore(char ch) { return switch (ch) { case '0', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - 'A', - 'B', - 'C', - 'D', - 'E', - 'F', - 'a', - 'b', - 'c', - 'd', - 'e', - 'f', - '_' -> + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + 'A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + '_' -> true; default -> false; }; @@ -751,46 +751,46 @@ public final class IoUtils { public static boolean isReservedWindowsFilenameChar(char character) { return switch (character) { case 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - '<', - '>', - ':', - '"', - '\\', - '/', - '|', - '?', - '*' -> + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + '<', + '>', + ':', + '"', + '\\', + '/', + '|', + '?', + '*' -> true; default -> false; }; diff --git a/pkl-core/src/main/java/org/pkl/core/util/json/JsonWriter.java b/pkl-core/src/main/java/org/pkl/core/util/json/JsonWriter.java index 3b56890e..70b69e17 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/json/JsonWriter.java +++ b/pkl-core/src/main/java/org/pkl/core/util/json/JsonWriter.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -563,7 +563,7 @@ public final class JsonWriter implements Closeable, Flushable { if (!lenient) { throw new IllegalStateException("JSON must have only one top-level value."); } - // fall-through + // fall-through case EMPTY_DOCUMENT: // first in document replaceTop(NONEMPTY_DOCUMENT); break; diff --git a/pkl-core/src/main/java/org/pkl/core/util/yaml/Yaml12Emitter.java b/pkl-core/src/main/java/org/pkl/core/util/yaml/Yaml12Emitter.java index e8f79e81..2b48598a 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/yaml/Yaml12Emitter.java +++ b/pkl-core/src/main/java/org/pkl/core/util/yaml/Yaml12Emitter.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,28 +29,28 @@ public final class Yaml12Emitter extends YamlEmitter { return switch (str) { case "", - "~", - "null", - "Null", - "NULL", - ".nan", - ".NaN", - ".NAN", - ".inf", - ".Inf", - ".INF", - "+.inf", - "+.Inf", - "+.INF", - "-.inf", - "-.Inf", - "-.INF", - "true", - "True", - "TRUE", - "false", - "False", - "FALSE" -> + "~", + "null", + "Null", + "NULL", + ".nan", + ".NaN", + ".NAN", + ".inf", + ".Inf", + ".INF", + "+.inf", + "+.Inf", + "+.INF", + "-.inf", + "-.Inf", + "-.INF", + "true", + "True", + "TRUE", + "false", + "False", + "FALSE" -> true; default -> false; }; diff --git a/pkl-core/src/main/java/org/pkl/core/util/yaml/YamlEmitter.java b/pkl-core/src/main/java/org/pkl/core/util/yaml/YamlEmitter.java index 2def7014..cd0387cf 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/yaml/YamlEmitter.java +++ b/pkl-core/src/main/java/org/pkl/core/util/yaml/YamlEmitter.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -137,7 +137,7 @@ public abstract class YamlEmitter { needsQuoting = needsQuoting || i == (length - 1) || (i + 1 < length) && str.charAt(i + 1) == ' '; } - // number chars + // number chars case '0', '1', '2', @@ -228,44 +228,44 @@ public abstract class YamlEmitter { return switch (str) { case "", - "~", - "null", - "Null", - "NULL", - ".nan", - ".NaN", - ".NAN", - ".inf", - ".Inf", - ".INF", - "+.inf", - "+.Inf", - "+.INF", - "-.inf", - "-.Inf", - "-.INF", - "true", - "True", - "TRUE", - "false", - "False", - "FALSE", - "on", - "On", - "ON", - "off", - "Off", - "OFF", - "y", - "Y", - "yes", - "Yes", - "YES", - "n", - "N", - "no", - "No", - "NO" -> + "~", + "null", + "Null", + "NULL", + ".nan", + ".NaN", + ".NAN", + ".inf", + ".Inf", + ".INF", + "+.inf", + "+.Inf", + "+.INF", + "-.inf", + "-.Inf", + "-.INF", + "true", + "True", + "TRUE", + "false", + "False", + "FALSE", + "on", + "On", + "ON", + "off", + "Off", + "OFF", + "y", + "Y", + "yes", + "Yes", + "YES", + "n", + "N", + "no", + "No", + "NO" -> true; default -> false; }; diff --git a/pkl-core/src/test/kotlin/org/pkl/core/EvaluateTestsTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/EvaluateTestsTest.kt index 83e42816..924e5977 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/EvaluateTestsTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/EvaluateTestsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ class EvaluateTestsTest { """ .trimIndent() ), - true + true, ) assertThat(results.moduleName).isEqualTo("text") @@ -75,7 +75,7 @@ class EvaluateTestsTest { """ .trimIndent() ), - true + true, ) assertThat(results.totalTests()).isEqualTo(1) @@ -111,7 +111,7 @@ class EvaluateTestsTest { """ .trimIndent() ), - true + true, ) assertThat(results.totalTests()).isEqualTo(1) @@ -157,7 +157,7 @@ class EvaluateTestsTest { } } """ - .trimIndent() + .trimIndent(), ) Files.writeString( @@ -172,7 +172,7 @@ class EvaluateTestsTest { } } """ - .trimIndent() + .trimIndent(), ) val results = evaluator.evaluateTest(path(file), false) @@ -207,7 +207,7 @@ class EvaluateTestsTest { } } """ - .trimIndent() + .trimIndent(), ) Files.writeString( @@ -222,7 +222,7 @@ class EvaluateTestsTest { } } """ - .trimIndent() + .trimIndent(), ) val results = evaluator.evaluateTest(path(file), false) @@ -260,7 +260,7 @@ class EvaluateTestsTest { } } """ - .trimIndent() + .trimIndent(), ) Files.writeString( @@ -275,7 +275,7 @@ class EvaluateTestsTest { } } """ - .trimIndent() + .trimIndent(), ) val results = evaluator.evaluateTest(path(file), false) @@ -314,7 +314,7 @@ class EvaluateTestsTest { } } """ - .trimIndent() + .trimIndent(), ) Files.writeString( @@ -329,7 +329,7 @@ class EvaluateTestsTest { } } """ - .trimIndent() + .trimIndent(), ) val results = evaluator.evaluateTest(path(file), false) @@ -377,7 +377,7 @@ class EvaluateTestsTest { } } """ - .trimIndent() + .trimIndent(), ) evaluator.evaluateTest(path(file), false) val expectedFile = file.parent.resolve(file.fileName.toString() + "-expected.pcf") @@ -411,7 +411,7 @@ class EvaluateTestsTest { } } """ - .trimIndent() + .trimIndent(), ) createExpected(file) .writeString( diff --git a/pkl-core/src/test/kotlin/org/pkl/core/PModuleTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/PModuleTest.kt index 019b0bcf..4c8a662c 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/PModuleTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/PModuleTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -128,7 +128,7 @@ class PModuleTest { moduleUri, moduleName, classInfo, - mapOf("name" to "Pigeon", "age" to 42, "other" to true) + mapOf("name" to "Pigeon", "age" to 42, "other" to true), ) assertThat(pigeon2).isNotEqualTo(pigeon) diff --git a/pkl-core/src/test/kotlin/org/pkl/core/PObjectTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/PObjectTest.kt index 9373d718..2d21715c 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/PObjectTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/PObjectTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -106,7 +106,7 @@ class PObjectTest { val pigeon2 = PObject( PClassInfo.get("test", "Person", URI("repl:test")), - mapOf("name" to "Pigeon", "age" to 21) + mapOf("name" to "Pigeon", "age" to 21), ) assertThat(pigeon2).isNotEqualTo(pigeon) @@ -127,7 +127,7 @@ class PObjectTest { val pigeon2 = PObject( PClassInfo.get("test", "Person", URI("repl:test")), - mapOf("name" to "Pigeon", "age" to 42, "other" to true) + mapOf("name" to "Pigeon", "age" to 42, "other" to true), ) assertThat(pigeon2).isNotEqualTo(pigeon) diff --git a/pkl-core/src/test/kotlin/org/pkl/core/PcfRendererTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/PcfRendererTest.kt index 7d800c22..79a9c090 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/PcfRendererTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/PcfRendererTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ class PcfRendererTest { grault = Map("garply", null, "waldo", 42, "pigeon", null) } """ - .trimIndent() + .trimIndent(), ) val module = diff --git a/pkl-core/src/test/kotlin/org/pkl/core/PropertiesRendererTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/PropertiesRendererTest.kt index 589a83db..2206ed93 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/PropertiesRendererTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/PropertiesRendererTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ class PropertiesRendererTest { "new Mapping {}", "Set()", "new PropertiesRenderer {}", - "new Dynamic {}" + "new Dynamic {}", ) unsupportedValues.forEach { diff --git a/pkl-core/src/test/kotlin/org/pkl/core/ReplServerTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/ReplServerTest.kt index 11b0c9c1..6eef3089 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/ReplServerTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/ReplServerTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ class ReplServerTest { listOf( ModuleKeyFactories.standardLibrary, ModuleKeyFactories.classPath(this::class.java.classLoader), - ModuleKeyFactories.file + ModuleKeyFactories.file, ), listOf(ResourceReaders.environmentVariable(), ResourceReaders.externalProperty()), mapOf("NAME1" to "value1", "NAME2" to "value2"), @@ -72,7 +72,7 @@ class ReplServerTest { "length()", "getClass()", "toString()", - "toTyped(" + "toTyped(", ) ) } @@ -121,7 +121,7 @@ class ReplServerTest { "getPropertyOrNull(", "hasProperty(", "relativePathTo(", - "toString()" + "toString()", ) ) } diff --git a/pkl-core/src/test/kotlin/org/pkl/core/SecurityManagersTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/SecurityManagersTest.kt index 19a6d745..3869b76f 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/SecurityManagersTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/SecurityManagersTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ class SecurityManagersTest { listOf(Pattern.compile("test:foo/bar")), listOf(Pattern.compile("env:FOO_BAR")), { uri -> if (uri.scheme == "one") 1 else if (uri.scheme == "two") 2 else 0 }, - null + null, ) @Test @@ -142,7 +142,7 @@ class SecurityManagersTest { listOf(Pattern.compile("file")), listOf(Pattern.compile("file")), SecurityManagers.defaultTrustLevels, - rootDir + rootDir, ) val path = rootDir.resolve("baz.pkl") @@ -163,7 +163,7 @@ class SecurityManagersTest { listOf(Pattern.compile("file")), listOf(Pattern.compile("file")), SecurityManagers.defaultTrustLevels, - rootDir + rootDir, ) manager.checkResolveModule(Path.of("/foo/bar/baz.pkl").toUri()) @@ -185,7 +185,7 @@ class SecurityManagersTest { listOf(Pattern.compile("file")), listOf(Pattern.compile("file")), SecurityManagers.defaultTrustLevels, - rootDir + rootDir, ) val path = rootDir.resolve("../baz.pkl") @@ -210,7 +210,7 @@ class SecurityManagersTest { listOf(Pattern.compile("file")), listOf(Pattern.compile("file")), SecurityManagers.defaultTrustLevels, - rootDir + rootDir, ) assertThrows { diff --git a/pkl-core/src/test/kotlin/org/pkl/core/externalreader/ExternalReaderRuntime.kt b/pkl-core/src/test/kotlin/org/pkl/core/externalreader/ExternalReaderRuntime.kt index 95b7dba3..d1c6e6e3 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/externalreader/ExternalReaderRuntime.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/externalreader/ExternalReaderRuntime.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.pkl.core.util.Nullable class ExternalReaderRuntime( private val moduleReaders: List, private val resourceReaders: List, - private val transport: MessageTransport + private val transport: MessageTransport, ) { /** Close the runtime and its transport. */ fun close() { @@ -96,7 +96,7 @@ class ExternalReaderRuntime( req.requestId, req.evaluatorId, null, - "No module reader found for scheme " + req.uri.scheme + "No module reader found for scheme " + req.uri.scheme, ) ) return@start @@ -107,7 +107,7 @@ class ExternalReaderRuntime( req.requestId, req.evaluatorId, reader.listElements(req.uri), - null + null, ) ) } catch (e: Exception) { @@ -125,7 +125,7 @@ class ExternalReaderRuntime( req.requestId, req.evaluatorId, null, - "No resource reader found for scheme " + req.uri.scheme + "No resource reader found for scheme " + req.uri.scheme, ) ) return@start @@ -136,7 +136,7 @@ class ExternalReaderRuntime( req.requestId, req.evaluatorId, reader.listElements(req.uri), - null + null, ) ) } catch (e: Exception) { @@ -154,7 +154,7 @@ class ExternalReaderRuntime( req.requestId, req.evaluatorId, null, - "No module reader found for scheme " + req.uri.scheme + "No module reader found for scheme " + req.uri.scheme, ) ) return@start @@ -176,7 +176,7 @@ class ExternalReaderRuntime( req.requestId, req.evaluatorId, byteArrayOf(), - "No resource reader found for scheme " + req.uri.scheme + "No resource reader found for scheme " + req.uri.scheme, ) ) return@start @@ -193,7 +193,7 @@ class ExternalReaderRuntime( } else -> throw ProtocolException("Unexpected incoming request message: $msg") } - } + }, ) } } diff --git a/pkl-core/src/test/kotlin/org/pkl/core/http/RequestCapturingClient.kt b/pkl-core/src/test/kotlin/org/pkl/core/http/RequestCapturingClient.kt index 75b2c044..3606207d 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/http/RequestCapturingClient.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/http/RequestCapturingClient.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ class RequestCapturingClient : HttpClient { override fun send( request: HttpRequest, - responseBodyHandler: HttpResponse.BodyHandler + responseBodyHandler: HttpResponse.BodyHandler, ): HttpResponse { this.request = request return FakeHttpResponse() diff --git a/pkl-core/src/test/kotlin/org/pkl/core/messaging/BaseMessagePackCodecTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/messaging/BaseMessagePackCodecTest.kt index db95893c..ba886b0c 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/messaging/BaseMessagePackCodecTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/messaging/BaseMessagePackCodecTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ class BaseMessagePackCodecTest { 123, 234, listOf(PathElement("foo", true), PathElement("bar", false)), - null + null, ) ) roundtrip(ListModulesResponse(123, 234, null, "Something dun went wrong")) @@ -92,7 +92,7 @@ class BaseMessagePackCodecTest { 3851, 3019, listOf(PathElement("foo", true), PathElement("bar", false)), - null + null, ) ) roundtrip(ListResourcesResponse(3851, 3019, null, "something went wrong")) diff --git a/pkl-core/src/test/kotlin/org/pkl/core/module/ServiceProviderTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/module/ServiceProviderTest.kt index 77913538..8cdb9b48 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/module/ServiceProviderTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/module/ServiceProviderTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ class ServiceProviderTest { uri, "testFactoryTest", PClassInfo.forModuleClass("testFactoryTest", uri), - mapOf("name" to "Pigeon", "age" to 40L) + mapOf("name" to "Pigeon", "age" to 40L), ) ) } diff --git a/pkl-core/src/test/kotlin/org/pkl/core/packages/DependencyMetadataTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/packages/DependencyMetadataTest.kt index 6d4999b2..a496698b 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/packages/DependencyMetadataTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/packages/DependencyMetadataTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,8 +35,8 @@ class DependencyMetadataTest { "foo" to Dependency.RemoteDependency( PackageUri("package://example.com/foo@0.5.3"), - Checksums("abc123") - ), + Checksums("abc123"), + ) ), "https://example.com/my/source/0.5.3/blob%{path}#L%{line}-L%{endLine}", URI("https://example.com/my/source"), @@ -62,9 +62,9 @@ class DependencyMetadataTest { "map" to mapOf(true to "t", false to "f"), "dataSize" to DataSize(1.5, DataSizeUnit.GIGABYTES), "duration" to Duration(2.9, DurationUnit.HOURS), - "pair" to Pair(1L, "1") - ) - ) + "pair" to Pair(1L, "1"), + ), + ), ), ) private val dependencyMetadataStr = @@ -204,7 +204,7 @@ class DependencyMetadataTest { listOf( PObject( PClassInfo.get("myModule", "MyAnnotation", URI("pkl:fake")), - mapOf("pattern" to Regex(".*").toPattern()) + mapOf("pattern" to Regex(".*").toPattern()), ) ), ) diff --git a/pkl-core/src/test/kotlin/org/pkl/core/project/ProjectDepsTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/project/ProjectDepsTest.kt index 447077e5..a6342142 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/project/ProjectDepsTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/project/ProjectDepsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,13 +54,13 @@ class ProjectDepsTest { CanonicalPackageUri.of("package://localhost:0/birds@0"), Dependency.RemoteDependency( PackageUri.create("package://localhost:0/birds@0.5.0"), - Checksums("abc123") + Checksums("abc123"), ), CanonicalPackageUri.of("package://localhost:0/fruit@1"), Dependency.LocalDependency( PackageUri.create("package://localhost:0/fruit@1.1.0"), - Path.of("../fruit") - ) + Path.of("../fruit"), + ), ) ProjectDeps(projectDepsMap) } diff --git a/pkl-core/src/test/kotlin/org/pkl/core/project/ProjectTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/project/ProjectTest.kt index 51b0c235..b8fc92ca 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/project/ProjectTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/project/ProjectTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ class ProjectTest { .trimIndent(), URI("https://example.com/my/issues"), listOf(Path.of("apiTest1.pkl"), Path.of("apiTest2.pkl")), - listOf("PklProject", "PklProject.deps.json", ".**", "*.exe") + listOf("PklProject", "PklProject.deps.json", ".**", "*.exe"), ) val expectedSettings = PklEvaluatorSettings( @@ -73,13 +73,13 @@ class ProjectTest { path, null, null, - null + null, ) val expectedAnnotations = listOf( PObject( PClassInfo.Deprecated, - mapOf("since" to "1.2", "message" to "do not use", "replaceWith" to "somethingElse") + mapOf("since" to "1.2", "message" to "do not use", "replaceWith" to "somethingElse"), ), PObject(PClassInfo.Unlisted, mapOf()), PObject(PClassInfo.ModuleInfo, mapOf("minPklVersion" to "0.26.0")), diff --git a/pkl-core/src/test/kotlin/org/pkl/core/stdlib/PathSpecParserTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/stdlib/PathSpecParserTest.kt index 0063a5f0..241beba1 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/stdlib/PathSpecParserTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/stdlib/PathSpecParserTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ class PathSpecParserTest { Identifier.get("prop3"), Identifier.get("prop2"), Identifier.get("prop1"), - TOP_LEVEL_VALUE + TOP_LEVEL_VALUE, ) ) @@ -98,7 +98,7 @@ class PathSpecParserTest { "key2", WILDCARD_PROPERTY, "key1", - Identifier.get("prop1") + Identifier.get("prop1"), ) ) @@ -111,7 +111,7 @@ class PathSpecParserTest { WILDCARD_PROPERTY, "key1", Identifier.get("prop1"), - TOP_LEVEL_VALUE + TOP_LEVEL_VALUE, ) ) } diff --git a/pkl-core/src/test/kotlin/org/pkl/core/stdlib/ReflectModuleTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/stdlib/ReflectModuleTest.kt index 7b13740d..7550555d 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/stdlib/ReflectModuleTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/stdlib/ReflectModuleTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ class ReflectModuleTest { "pkl:shell", "pkl:test", "pkl:xml", - "pkl:yaml" + "pkl:yaml", ] ) @ParameterizedTest(name = "can reflect on {0} module") diff --git a/pkl-core/src/test/kotlin/org/pkl/core/truffle/LongVsDoubleSpecializationTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/truffle/LongVsDoubleSpecializationTest.kt index a68ed9a5..a23e44a7 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/truffle/LongVsDoubleSpecializationTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/truffle/LongVsDoubleSpecializationTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,9 +35,11 @@ class LongVsDoubleSpecializationTest { fun addition() { val result = evaluator.evaluate( - ModuleSource.text(""" + ModuleSource.text( + """ x1 = Pair(1.0 + 2.0, 1 + 2).second - """) + """ + ) ) assertThat(result.properties["x1"]).isEqualTo(3L) @@ -47,9 +49,11 @@ class LongVsDoubleSpecializationTest { fun subtraction() { val result = evaluator.evaluate( - ModuleSource.text(""" + ModuleSource.text( + """ x1 = Pair(1.0 - 2.0, 1 - 2).second - """) + """ + ) ) assertThat(result.properties["x1"]).isEqualTo(-1L) @@ -59,9 +63,11 @@ class LongVsDoubleSpecializationTest { fun multiplication() { val result = evaluator.evaluate( - ModuleSource.text(""" + ModuleSource.text( + """ x1 = Pair(1.0 * 2.0, 1 * 2).second - """) + """ + ) ) assertThat(result.properties["x1"]).isEqualTo(2L) diff --git a/pkl-core/src/test/kotlin/org/pkl/core/util/GlobResolverTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/util/GlobResolverTest.kt index bd7010f9..241591bb 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/util/GlobResolverTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/util/GlobResolverTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ class GlobResolverTest { "baz.pkl", "buzzy...baz.pkl", "ted_lasso.min.pkl", - "ted_lasso.pkl.min.pkl" + "ted_lasso.pkl.min.pkl", ] ) fun `glob match`(input: String) { @@ -68,7 +68,7 @@ class GlobResolverTest { "pkl", // crosses directory boundaries "/bar/baz.pkl", - "/baz.pkl" + "/baz.pkl", ] ) fun `glob non-match`(input: String) { @@ -95,13 +95,7 @@ class GlobResolverTest { } @ParameterizedTest - @ValueSource( - strings = - [ - "/foo.pkl/bar/baz.pkl", - "//fo///ba.pkl", - ] - ) + @ValueSource(strings = ["/foo.pkl/bar/baz.pkl", "//fo///ba.pkl"]) fun `globstar match 2`(input: String) { val pattern = GlobResolver.toRegexPattern("/**/*.pkl") assertTrue(pattern.matcher(input).matches()) diff --git a/pkl-core/src/test/kotlin/org/pkl/core/util/ImportGraphUtilsTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/util/ImportGraphUtilsTest.kt index fffcb58b..a85c84dd 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/util/ImportGraphUtilsTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/util/ImportGraphUtilsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,10 +29,10 @@ class ImportGraphUtilsTest { ImportGraph( mapOf( fooUri to setOf(ImportGraph.Import(barUri)), - barUri to setOf(ImportGraph.Import(fooUri)) + barUri to setOf(ImportGraph.Import(fooUri)), ), // resolved URIs is not important - mapOf() + mapOf(), ) val cycles = ImportGraphUtils.findImportCycles(graph) assertThat(cycles).isEqualTo(listOf(listOf(fooUri, barUri))) @@ -50,10 +50,10 @@ class ImportGraphUtilsTest { fooUri to setOf(ImportGraph.Import(barUri)), barUri to setOf(ImportGraph.Import(fooUri)), bizUri to setOf(ImportGraph.Import(quxUri)), - quxUri to setOf(ImportGraph.Import(bizUri)) + quxUri to setOf(ImportGraph.Import(bizUri)), ), // resolved URIs is not important - mapOf() + mapOf(), ) val cycles = ImportGraphUtils.findImportCycles(graph) assertThat(cycles).isEqualTo(listOf(listOf(fooUri, barUri), listOf(bizUri, quxUri))) @@ -71,10 +71,10 @@ class ImportGraphUtilsTest { barUri to setOf(ImportGraph.Import(fooUri)), fooUri to setOf(ImportGraph.Import(bizUri)), bizUri to setOf(ImportGraph.Import(quxUri)), - quxUri to setOf() + quxUri to setOf(), ), // resolved URIs is not important - mapOf() + mapOf(), ) val cycles = ImportGraphUtils.findImportCycles(graph) assertThat(cycles).isEmpty() @@ -87,7 +87,7 @@ class ImportGraphUtilsTest { ImportGraph( mapOf(fooUri to setOf(ImportGraph.Import(fooUri))), // resolved URIs is not important - mapOf() + mapOf(), ) val cycles = ImportGraphUtils.findImportCycles(graph) assertThat(cycles).isEqualTo(listOf(listOf(fooUri))) diff --git a/pkl-doc/src/main/kotlin/org/pkl/doc/ClassPageGenerator.kt b/pkl-doc/src/main/kotlin/org/pkl/doc/ClassPageGenerator.kt index 2c448dd1..bfd8f2ed 100644 --- a/pkl-doc/src/main/kotlin/org/pkl/doc/ClassPageGenerator.kt +++ b/pkl-doc/src/main/kotlin/org/pkl/doc/ClassPageGenerator.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ internal class ClassPageGenerator( docModule: DocModule, clazz: PClass, pageScope: ClassScope, - isTestMode: Boolean + isTestMode: Boolean, ) : ModuleOrClassPageGenerator(docsiteInfo, docModule, clazz, pageScope, isTestMode) { override val html: HTML.() -> Unit = { renderHtmlHead() @@ -71,13 +71,13 @@ internal class ClassPageGenerator( id = HtmlConstants.KNOWN_VERSIONS classes = runtimeDataClasses }, - ) + ), ) renderMemberGroupLinks( Triple("Overview", "#_overview", memberDocs.isExpandable), Triple("Properties", "#_properties", clazz.hasListedProperty), - Triple("Methods", "#_methods", clazz.hasListedMethod) + Triple("Methods", "#_methods", clazz.hasListedMethod), ) renderAnchor("_overview") diff --git a/pkl-doc/src/main/kotlin/org/pkl/doc/CliDocGenerator.kt b/pkl-doc/src/main/kotlin/org/pkl/doc/CliDocGenerator.kt index 41ce50ff..34d07c07 100644 --- a/pkl-doc/src/main/kotlin/org/pkl/doc/CliDocGenerator.kt +++ b/pkl-doc/src/main/kotlin/org/pkl/doc/CliDocGenerator.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ class CliDocGenerator(private val options: CliDocGeneratorOptions) : CliCommand( PklInfo.current() .packageIndex .getPackagePage("pkl", Release.current().version().toString()) - ) + ), ) private fun DependencyMetadata.getPackageDependencies(): List { @@ -78,7 +78,7 @@ class CliDocGenerator(private val options: CliDocGeneratorOptions) : CliCommand( version = metadata.version.toString(), sourceCode = metadata.sourceCode, sourceCodeUrlScheme = metadata.sourceCodeUrlScheme, - documentation = metadata.documentation + documentation = metadata.documentation, ) add(packageDependency) } @@ -269,7 +269,7 @@ class CliDocGenerator(private val options: CliDocGeneratorOptions) : CliCommand( importedModules::getValue, versionComparator, options.normalizedOutputDir, - options.isTestMode + options.isTestMode, ) .run() } catch (e: DocGeneratorException) { diff --git a/pkl-doc/src/main/kotlin/org/pkl/doc/CliDocGeneratorOptions.kt b/pkl-doc/src/main/kotlin/org/pkl/doc/CliDocGeneratorOptions.kt index a79af105..5367cd7d 100644 --- a/pkl-doc/src/main/kotlin/org/pkl/doc/CliDocGeneratorOptions.kt +++ b/pkl-doc/src/main/kotlin/org/pkl/doc/CliDocGeneratorOptions.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ constructor( * Generates source URLs with fixed line numbers `#L123-L456` to avoid churn in expected output * files (e.g., when stdlib line numbers change). */ - val isTestMode: Boolean = false + val isTestMode: Boolean = false, ) { /** [outputDir] after undergoing normalization. */ val normalizedOutputDir: Path = base.normalizedWorkingDir.resolveSafely(outputDir) diff --git a/pkl-doc/src/main/kotlin/org/pkl/doc/DocScope.kt b/pkl-doc/src/main/kotlin/org/pkl/doc/DocScope.kt index a99ae9ab..8a79fbd2 100644 --- a/pkl-doc/src/main/kotlin/org/pkl/doc/DocScope.kt +++ b/pkl-doc/src/main/kotlin/org/pkl/doc/DocScope.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -125,7 +125,7 @@ internal class SiteScope( docPackages: List, private val overviewImports: Map, private val importResolver: (URI) -> ModuleSchema, - outputDir: Path + outputDir: Path, ) : PageScope() { private val pklVersion = Release.current().version().withBuild(null).toString() @@ -139,7 +139,7 @@ internal class SiteScope( docPackage.docModules.map { it.schema }, pklBaseModule, docPackage.docPackageInfo.overviewImports, - this + this, ) } } @@ -162,7 +162,7 @@ internal class SiteScope( name: String, version: String, sourceCodeUrlScheme: String?, - sourceCode: URI? + sourceCode: URI?, ): PackageScope = PackageScope( DocPackageInfo( @@ -175,12 +175,12 @@ internal class SiteScope( importUri = "", issueTracker = null, overview = null, - uri = null + uri = null, ), emptyList(), pklBaseModule, emptyMap(), - this + this, ) override fun getMethod(name: String): MethodScope? = null @@ -196,7 +196,7 @@ internal class SiteScope( name.startsWith("pkl.") -> { val packagePage = packageScopes["pkl"]?.url // link to locally generated stdlib docs if available - ?: PklInfo.current().packageIndex.getPackagePage("pkl", pklVersion).toUri() + ?: PklInfo.current().packageIndex.getPackagePage("pkl", pklVersion).toUri() packagePage.resolve(name.substring(4) + "/") } // doesn't make much sense to search in [packageScopes] @@ -227,8 +227,7 @@ internal class SiteScope( overviewImports[name]?.let { uri -> val mod = resolveImport(uri) resolveModuleNameToDocUrl(mod.moduleName)?.let { url -> ModuleScope(mod, url, null) } - } - ?: pklBaseScope.getProperty(name) + } ?: pklBaseScope.getProperty(name) } internal class PackageScope( @@ -236,7 +235,7 @@ internal class PackageScope( modules: List, pklBaseModule: ModuleSchema, private val overviewImports: Map, - override val parent: SiteScope + override val parent: SiteScope, ) : PageScope() { val name = docPackageInfo.name @@ -305,8 +304,7 @@ internal class PackageScope( overviewImports[name]?.let { uri -> val mod = resolveImport(uri) resolveModuleNameToDocUrl(mod.moduleName)?.let { url -> ModuleScope(mod, url, null) } - } - ?: getPklBaseProperty(name) + } ?: getPklBaseProperty(name) override fun equals(other: Any?): Boolean = other is PackageScope && docPackageInfo.name == other.docPackageInfo.name @@ -318,7 +316,7 @@ internal class PackageScope( internal class ModuleScope( val module: ModuleSchema, override val url: URI, - override val parent: PackageScope? + override val parent: PackageScope?, ) : PageScope() { val name: String get() = module.moduleName @@ -335,7 +333,7 @@ internal class ModuleScope( override fun getProperty(name: String): DocScope? = module.moduleClass.allProperties[name]?.let { PropertyScope(it, this) } ?: module.allClasses[name]?.let { ClassScope(it, url, this) } - ?: module.allTypeAliases[name]?.let { TypeAliasScope(it, url, this) } + ?: module.allTypeAliases[name]?.let { TypeAliasScope(it, url, this) } private fun resolveImport(uri: URI): ModuleSchema = parent!!.resolveImport(uri) @@ -358,7 +356,8 @@ internal class ModuleScope( override fun resolveMethod(name: String): MethodScope? = module.moduleClass.methods[name]?.let { MethodScope(it, this) } - ?: parent!!.getPklBaseMethod(name) ?: getMethod(name) + ?: parent!!.getPklBaseMethod(name) + ?: getMethod(name) override fun resolveVariable(name: String): DocScope? = name.takeIf { it == "module" }?.let { this } @@ -366,11 +365,12 @@ internal class ModuleScope( val mod = resolveImport(uri) resolveModuleNameToDocUrl(mod.moduleName)?.let { url -> ModuleScope(mod, url, null) } } - ?: module.moduleClass.properties[name]?.let { PropertyScope(it, this) } + ?: module.moduleClass.properties[name]?.let { PropertyScope(it, this) } // inherited classes/type aliases are in scope when resolving types -> search `all` ?: module.allClasses[name]?.let { ClassScope(it, url, this) } - ?: module.allTypeAliases[name]?.let { TypeAliasScope(it, url, this) } - ?: parent!!.getPklBaseProperty(name) ?: getProperty(name) + ?: module.allTypeAliases[name]?.let { TypeAliasScope(it, url, this) } + ?: parent!!.getPklBaseProperty(name) + ?: getProperty(name) override fun equals(other: Any?): Boolean = other is ModuleScope && module == other.module @@ -380,7 +380,7 @@ internal class ModuleScope( internal class ClassScope( val clazz: PClass, private val parentUrl: URI, - override val parent: ModuleScope? + override val parent: ModuleScope?, ) : PageScope() { override val url: URI by lazy { // `isModuleClass` distinction is relevant when this scope is a link target @@ -406,12 +406,14 @@ internal class ClassScope( override fun resolveMethod(name: String): MethodScope? = clazz.methods[name]?.let { MethodScope(it, this) } - ?: parent!!.resolveMethod(name) ?: getMethod(name) + ?: parent!!.resolveMethod(name) + ?: getMethod(name) override fun resolveVariable(name: String): DocScope? = clazz.typeParameters.find { it.name == name }?.let { ParameterScope(name, this) } - ?: clazz.properties[name]?.let { PropertyScope(it, this) } ?: parent!!.resolveVariable(name) - ?: clazz.allProperties[name]?.let { PropertyScope(it, this) } + ?: clazz.properties[name]?.let { PropertyScope(it, this) } + ?: parent!!.resolveVariable(name) + ?: clazz.allProperties[name]?.let { PropertyScope(it, this) } override fun equals(other: Any?): Boolean = other is ClassScope && clazz == other.clazz @@ -421,7 +423,7 @@ internal class ClassScope( internal class TypeAliasScope( val typeAlias: TypeAlias, private val parentDocUrl: URI, - override val parent: ModuleScope? + override val parent: ModuleScope?, ) : DocScope() { override val url: URI get() = parentDocUrl.resolve("#${typeAlias.simpleName}") @@ -468,7 +470,8 @@ internal class MethodScope(val method: PClass.Method, override val parent: DocSc override fun resolveVariable(name: String): DocScope? = method.typeParameters.find { it.name == name }?.let { ParameterScope(name, this) } - ?: method.parameters[name]?.let { ParameterScope(name, this) } ?: parent.resolveVariable(name) + ?: method.parameters[name]?.let { ParameterScope(name, this) } + ?: parent.resolveVariable(name) override fun equals(other: Any?): Boolean = other is MethodScope && method == other.method @@ -477,7 +480,7 @@ internal class MethodScope(val method: PClass.Method, override val parent: DocSc internal class PropertyScope( val property: PClass.Property, - override val parent: DocScope // ModuleScope|ClassScope + override val parent: DocScope, // ModuleScope|ClassScope ) : DocScope() { override val url: URI get() = parent.url.resolve("#${property.simpleName}") diff --git a/pkl-doc/src/main/kotlin/org/pkl/doc/DocsiteInfo.kt b/pkl-doc/src/main/kotlin/org/pkl/doc/DocsiteInfo.kt index ee6d5b4d..0faeec0f 100644 --- a/pkl-doc/src/main/kotlin/org/pkl/doc/DocsiteInfo.kt +++ b/pkl-doc/src/main/kotlin/org/pkl/doc/DocsiteInfo.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ data class DocsiteInfo( val overview: String?, /** Imports used to resolve Pkldoc links in [overview]. */ - val overviewImports: Map + val overviewImports: Map, ) { companion object { @Suppress("UNCHECKED_CAST") diff --git a/pkl-doc/src/main/kotlin/org/pkl/doc/HtmlGenerator.kt b/pkl-doc/src/main/kotlin/org/pkl/doc/HtmlGenerator.kt index 9204e12b..89ea7635 100644 --- a/pkl-doc/src/main/kotlin/org/pkl/doc/HtmlGenerator.kt +++ b/pkl-doc/src/main/kotlin/org/pkl/doc/HtmlGenerator.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ internal class HtmlGenerator( docPackages: List, importResolver: (URI) -> ModuleSchema, private val outputDir: Path, - private val isTestMode: Boolean + private val isTestMode: Boolean, ) { private val siteScope = SiteScope(docPackages, docsiteInfo.overviewImports, importResolver, outputDir) @@ -50,7 +50,7 @@ internal class HtmlGenerator( docModule, clazz, ClassScope(clazz, moduleScope.url, moduleScope), - isTestMode + isTestMode, ) .run() } diff --git a/pkl-doc/src/main/kotlin/org/pkl/doc/MainOrPackagePageGenerator.kt b/pkl-doc/src/main/kotlin/org/pkl/doc/MainOrPackagePageGenerator.kt index 49a5adbd..3ec05b2a 100644 --- a/pkl-doc/src/main/kotlin/org/pkl/doc/MainOrPackagePageGenerator.kt +++ b/pkl-doc/src/main/kotlin/org/pkl/doc/MainOrPackagePageGenerator.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,12 @@ import kotlinx.html.* internal abstract class MainOrPackagePageGenerator( docsiteInfo: DocsiteInfo, pageScope: S, - private val siteScope: SiteScope + private val siteScope: SiteScope, ) : PageGenerator(docsiteInfo, pageScope) where S : PageScope { protected fun UL.renderModuleOrPackage( name: String, moduleOrPackageScope: DocScope, - memberDocs: MemberDocs + memberDocs: MemberDocs, ) { li { renderAnchor(name) @@ -47,7 +47,7 @@ internal abstract class MainOrPackagePageGenerator( renderModifiers( setOf(), - if (moduleOrPackageScope is PackageScope) "package" else "module" + if (moduleOrPackageScope is PackageScope) "package" else "module", ) } } diff --git a/pkl-doc/src/main/kotlin/org/pkl/doc/ModuleOrClassPageGenerator.kt b/pkl-doc/src/main/kotlin/org/pkl/doc/ModuleOrClassPageGenerator.kt index bc278f2b..65c89c39 100644 --- a/pkl-doc/src/main/kotlin/org/pkl/doc/ModuleOrClassPageGenerator.kt +++ b/pkl-doc/src/main/kotlin/org/pkl/doc/ModuleOrClassPageGenerator.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ internal abstract class ModuleOrClassPageGenerator( private val docModule: DocModule, protected val clazz: PClass, scope: S, - private val isTestMode: Boolean + private val isTestMode: Boolean, ) : PageGenerator(docsiteInfo, scope) where S : PageScope { protected fun HtmlBlockTag.renderProperties() { if (!clazz.hasListedProperty) return @@ -279,9 +279,8 @@ internal abstract class ModuleOrClassPageGenerator( val moduleSourceUrl = pageScope.resolveModuleNameToSourceUrl( member.moduleName, - Member.SourceLocation(startLine, endLine) - ) - ?: return + Member.SourceLocation(startLine, endLine), + ) ?: return a { classes = setOf("member-source-link") href = moduleSourceUrl.toString() diff --git a/pkl-doc/src/test/kotlin/org/pkl/doc/DocScopeTest.kt b/pkl-doc/src/test/kotlin/org/pkl/doc/DocScopeTest.kt index e8c605c4..e2b5dbae 100644 --- a/pkl-doc/src/test/kotlin/org/pkl/doc/DocScopeTest.kt +++ b/pkl-doc/src/test/kotlin/org/pkl/doc/DocScopeTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ class DocScopeTest { "sourceCode".toUri(), "https://example.com/mypackage/blob/1.2.3%{path}#L%{line}-L%{endLine}", "issueTracker".toUri(), - overview = "overview docs" + overview = "overview docs", ) private val module: ModuleSchema by lazy { @@ -87,7 +87,7 @@ class DocScopeTest { listOf(DocPackage(docPackageInfo, mutableListOf(module))), mapOf(), { evaluator.evaluateSchema(uri(it)) }, - "/output/dir".toPath() + "/output/dir".toPath(), ) } @@ -122,7 +122,7 @@ class DocScopeTest { classScope, typeAliasScope, classPropertyScope, - classMethodScope + classMethodScope, ) @JvmStatic diff --git a/pkl-doc/src/test/kotlin/org/pkl/doc/SearchTest.kt b/pkl-doc/src/test/kotlin/org/pkl/doc/SearchTest.kt index 6f063ff6..62b8e425 100644 --- a/pkl-doc/src/test/kotlin/org/pkl/doc/SearchTest.kt +++ b/pkl-doc/src/test/kotlin/org/pkl/doc/SearchTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,10 +45,10 @@ class SearchTest { base = CliBaseOptions( sourceModules = listOf(packageModule) + inputModules, - settings = URI("pkl:settings") + settings = URI("pkl:settings"), ), outputDir = pkldocDir, - true + true, ) ) .run() @@ -145,8 +145,8 @@ class SearchTest { "com.package1.modulePropertyComments", "com.package1.modulePropertyModifiers", "com.package1.modulePropertyTypeAnnotations", - "com.package1.modulePropertyTypeReferences" - ) + "com.package1.modulePropertyTypeReferences", + ), ) } @@ -159,8 +159,8 @@ class SearchTest { "com.package1.classMethodTypeReferences", "com.package1.classPropertyTypeReferences", "com.package1.moduleMethodTypeReferences", - "com.package1.modulePropertyTypeReferences" - ) + "com.package1.modulePropertyTypeReferences", + ), ) } @@ -172,8 +172,8 @@ class SearchTest { "prpertyWithExpandableComment", "AnnotatedClssWithExpandableComment", "ClassWithAnnotatedProperty", - "mthodWithExpandableComment" - ) + "mthodWithExpandableComment", + ), ) } @@ -195,8 +195,8 @@ class SearchTest { "com.package1.modulePropertyTypeAnnotations", "com.package1.modulePropertyCommentInheritance", "com.package1.docExampleSubject1", - "com.package1.docExampleSubject2" - ) + "com.package1.docExampleSubject2", + ), ) } @@ -208,8 +208,8 @@ class SearchTest { "com.package1.classInheritance", "city", // disregard "com.package1.moduleMethodCommentInheritance", - "com.package1.modulePropertyCommentInheritance" - ) + "com.package1.modulePropertyCommentInheritance", + ), ) } diff --git a/pkl-executor/src/test/kotlin/org/pkl/executor/EmbeddedExecutorTest.kt b/pkl-executor/src/test/kotlin/org/pkl/executor/EmbeddedExecutorTest.kt index 317faa9f..4e3b4e26 100644 --- a/pkl-executor/src/test/kotlin/org/pkl/executor/EmbeddedExecutorTest.kt +++ b/pkl-executor/src/test/kotlin/org/pkl/executor/EmbeddedExecutorTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ class EmbeddedExecutorTest { class TestExecutor( private val executor: Executor, private val spiOptionsVersion: Int, - private val name: String + private val name: String, ) { fun evaluatePath(modulePath: Path, optionSpec: ExecutorOptions.Builder.() -> Unit): String { val options = @@ -66,7 +66,7 @@ class EmbeddedExecutorTest { TestExecutor(executor2_1.value, 1, "SpiOptions1, Executor2, Distribution1"), TestExecutor(executor2_1.value, 2, "SpiOptions2, Executor2, Distribution1"), TestExecutor(executor2_2.value, 1, "SpiOptions1, Executor2, Distribution2"), - TestExecutor(executor2_2.value, 2, "SpiOptions2, Executor2, Distribution2") + TestExecutor(executor2_2.value, 2, "SpiOptions2, Executor2, Distribution2"), ) } @@ -239,7 +239,7 @@ class EmbeddedExecutorTest { @MethodSource("getAllTestExecutors") fun `evaluate a module that is missing a ModuleInfo annotation`( executor: TestExecutor, - @TempDir tempDir: Path + @TempDir tempDir: Path, ) { val pklFile = tempDir.resolve("test.pkl") pklFile @@ -270,7 +270,7 @@ class EmbeddedExecutorTest { @MethodSource("getAllTestExecutors") fun `evaluate a module that requests an incompatible Pkl version`( executor: TestExecutor, - @TempDir tempDir: Path + @TempDir tempDir: Path, ) { val pklFile = tempDir.resolve("test.pkl") pklFile @@ -302,7 +302,7 @@ class EmbeddedExecutorTest { @MethodSource("getAllTestExecutors") fun `evaluate a module that reads environment variables and external properties`( executor: TestExecutor, - @TempDir tempDir: Path + @TempDir tempDir: Path, ) { val pklFile = tempDir.resolve("test.pkl") pklFile @@ -328,17 +328,21 @@ class EmbeddedExecutorTest { } assertThat(result.trim()) - .isEqualTo(""" + .isEqualTo( + """ x = "ENV_VAR" y = "property" - """.trimIndent().trim()) + """ + .trimIndent() + .trim() + ) } @ParameterizedTest @MethodSource("getAllTestExecutors") fun `evaluate a module that depends on another module`( executor: TestExecutor, - @TempDir tempDir: Path + @TempDir tempDir: Path, ) { val pklFile = tempDir.resolve("test.pkl") pklFile @@ -376,11 +380,15 @@ class EmbeddedExecutorTest { } assertThat(result.trim()) - .isEqualTo(""" + .isEqualTo( + """ foo { bar = 42 } - """.trimIndent().trim()) + """ + .trimIndent() + .trim() + ) } @ParameterizedTest @@ -419,7 +427,7 @@ class EmbeddedExecutorTest { @MethodSource("getAllTestExecutors") fun `evaluate a module whose project evaluation fails`( executor: TestExecutor, - @TempDir tempDir: Path + @TempDir tempDir: Path, ) { // the toRealPath is important here or the failure reason can change // this happens on macOS where /tmp is a symlink to /private/tmp diff --git a/pkl-gradle/src/test/kotlin/org/pkl/gradle/AnalyzeImportsTest.kt b/pkl-gradle/src/test/kotlin/org/pkl/gradle/AnalyzeImportsTest.kt index 555bab65..f4c8205d 100644 --- a/pkl-gradle/src/test/kotlin/org/pkl/gradle/AnalyzeImportsTest.kt +++ b/pkl-gradle/src/test/kotlin/org/pkl/gradle/AnalyzeImportsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ class AnalyzeImportsTest : AbstractTest() { } } """ - .trimIndent() + .trimIndent(), ) val result = runTask("analyzeMyImports") assertThat(result.output).contains("imports {") @@ -66,7 +66,7 @@ class AnalyzeImportsTest : AbstractTest() { } } """ - .trimIndent() + .trimIndent(), ) runTask("analyzeMyImports") assertThat(testProjectDir.resolve("myFile.pcf")).exists() @@ -93,7 +93,7 @@ class AnalyzeImportsTest : AbstractTest() { } } """ - .trimIndent() + .trimIndent(), ) val result = runTask("analyzeMyImports") assertThat(result.output) diff --git a/pkl-gradle/src/test/kotlin/org/pkl/gradle/EvaluatorsTest.kt b/pkl-gradle/src/test/kotlin/org/pkl/gradle/EvaluatorsTest.kt index 76ef174f..1a0ce241 100644 --- a/pkl-gradle/src/test/kotlin/org/pkl/gradle/EvaluatorsTest.kt +++ b/pkl-gradle/src/test/kotlin/org/pkl/gradle/EvaluatorsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ class EvaluatorsTest : AbstractTest() { age = 30 } """ - .trimIndent() + .trimIndent(), ) } @@ -62,7 +62,7 @@ class EvaluatorsTest : AbstractTest() { name: Pigeon age: 30 """ - .trimIndent() + .trimIndent(), ) } @@ -85,7 +85,7 @@ class EvaluatorsTest : AbstractTest() { } } """ - .trimIndent() + .trimIndent(), ) } @@ -115,7 +115,7 @@ class EvaluatorsTest : AbstractTest() { """ - .trimIndent() + .trimIndent(), ) } @@ -126,7 +126,7 @@ class EvaluatorsTest : AbstractTest() { """ externalProperties = [prop1: "value1", prop2: "value2"] """ - .trimIndent() + .trimIndent(), ) writePklFile( @@ -148,7 +148,7 @@ class EvaluatorsTest : AbstractTest() { prop2 = "value2" other = null """ - .trimIndent() + .trimIndent(), ) } @@ -175,7 +175,7 @@ class EvaluatorsTest : AbstractTest() { prop2 = null prop3 = null """ - .trimIndent() + .trimIndent(), ) } @@ -186,7 +186,7 @@ class EvaluatorsTest : AbstractTest() { """ environmentVariables = [VAR1: "value1", VAR2: "value2"] """ - .trimIndent() + .trimIndent(), ) writePklFile( @@ -208,7 +208,7 @@ class EvaluatorsTest : AbstractTest() { prop2 = "value2" other = null """ - .trimIndent() + .trimIndent(), ) } @@ -228,7 +228,7 @@ class EvaluatorsTest : AbstractTest() { } } } - """ + """, ) val result = runTask("evalTest", true) @@ -244,7 +244,7 @@ class EvaluatorsTest : AbstractTest() { name = "Pigeon" age = 20 + 10 } - """ + """, ) writeFile( @@ -264,7 +264,7 @@ class EvaluatorsTest : AbstractTest() { } } } - """ + """, ) runTask("evalTest") @@ -278,7 +278,7 @@ class EvaluatorsTest : AbstractTest() { age = 30 } """ - .trimIndent() + .trimIndent(), ) } @@ -300,7 +300,7 @@ class EvaluatorsTest : AbstractTest() { } } } - """ + """, ) val result = runTask("evalTest", expectFailure = true) @@ -314,9 +314,12 @@ class EvaluatorsTest : AbstractTest() { @Test fun `evaluation timeout`() { // Gradle 4.10 doesn't automatically import Duration - writeBuildFile("pcf", """ + writeBuildFile( + "pcf", + """ evalTimeout = java.time.Duration.ofMillis(100) - """) + """, + ) writePklFile( """ @@ -349,7 +352,7 @@ class EvaluatorsTest : AbstractTest() { } } } - """ + """, ) writeFile("test1.pkl", "foo = 1") @@ -363,7 +366,7 @@ class EvaluatorsTest : AbstractTest() { // hello bar = 2 """ - .trimIndent() + .trimIndent(), ) } @@ -378,7 +381,7 @@ class EvaluatorsTest : AbstractTest() { text = reflect.Module(module).uri } """ - .trimIndent() + .trimIndent(), ) runTask("evalTest") @@ -395,7 +398,7 @@ class EvaluatorsTest : AbstractTest() { """ multipleFileOutputDir = layout.projectDirectory.dir("my-output") """ - .trimIndent() + .trimIndent(), ) writeFile( "test.pkl", @@ -411,7 +414,7 @@ class EvaluatorsTest : AbstractTest() { } } """ - .trimIndent() + .trimIndent(), ) runTask("evalTest") checkFileContents(testProjectDir.resolve("my-output/output-1.txt"), "My output 1") @@ -426,7 +429,7 @@ class EvaluatorsTest : AbstractTest() { expression = "metadata.name" outputFile = layout.projectDirectory.file("output.txt") """ - .trimIndent() + .trimIndent(), ) writeFile( "test.pkl", @@ -435,7 +438,7 @@ class EvaluatorsTest : AbstractTest() { name = "Uni" } """ - .trimIndent() + .trimIndent(), ) runTask("evalTest") checkFileContents(testProjectDir.resolve("output.txt"), "Uni") @@ -448,7 +451,7 @@ class EvaluatorsTest : AbstractTest() { """ moduleCacheDir = file("${tempDir.toUri()}") """ - .trimIndent() + .trimIndent(), ) writeFile( "test.pkl", @@ -457,7 +460,7 @@ class EvaluatorsTest : AbstractTest() { res = new Bird { name = "Wally"; favoriteFruit { name = "bananas" } } """ - .trimIndent() + .trimIndent(), ) PackageServer.populateCacheDir(tempDir) runTask("evalTest") @@ -483,7 +486,7 @@ class EvaluatorsTest : AbstractTest() { packageZipUrl = "https://localhost:0/\(name)@\(version).zip" } """ - .trimIndent() + .trimIndent(), ) writeFile( @@ -498,7 +501,7 @@ class EvaluatorsTest : AbstractTest() { packageZipUrl = "https://localhost:0/\(name)@\(version).zip" } """ - .trimIndent() + .trimIndent(), ) writeFile( @@ -515,7 +518,7 @@ class EvaluatorsTest : AbstractTest() { } } """ - .trimIndent() + .trimIndent(), ) writeFile( @@ -526,7 +529,7 @@ class EvaluatorsTest : AbstractTest() { "resolvedDependencies": {} } """ - .trimIndent() + .trimIndent(), ) writeFile( @@ -536,7 +539,7 @@ class EvaluatorsTest : AbstractTest() { bar: String = import("@proj2/baz.pkl").qux """ - .trimIndent() + .trimIndent(), ) writeFile( @@ -544,7 +547,7 @@ class EvaluatorsTest : AbstractTest() { """ qux: String = "Contents of @proj2/qux" """ - .trimIndent() + .trimIndent(), ) runTask("evalTest") @@ -595,7 +598,7 @@ class EvaluatorsTest : AbstractTest() { } } """ - .trimIndent() + .trimIndent(), ) val result1 = runTask("printEvalFiles") @@ -741,7 +744,7 @@ class EvaluatorsTest : AbstractTest() { } } """ - .trimIndent() + .trimIndent(), ) val result1 = runTask("printEvalDirs") @@ -875,7 +878,7 @@ class EvaluatorsTest : AbstractTest() { """ transitiveModules.from(files("shared2.pkl")) """ - .trimIndent() + .trimIndent(), ) val result1 = runTask("evalTest") assertThat(result1.task(":evalTest")!!.outcome).isEqualTo(TaskOutcome.SUCCESS) @@ -901,7 +904,7 @@ class EvaluatorsTest : AbstractTest() { outputFormat: String, additionalContents: String = "", sourceModules: List = listOf("test.pkl"), - additionalBuildScript: String = "" + additionalBuildScript: String = "", ) { writeFile( "build.gradle", @@ -922,12 +925,13 @@ class EvaluatorsTest : AbstractTest() { } $additionalBuildScript - """ + """, ) } private fun writePklFile( - contents: String = """ + contents: String = + """ person { name = "Pigeon" age = 20 + 10 diff --git a/pkl-gradle/src/test/kotlin/org/pkl/gradle/PkldocGeneratorsTest.kt b/pkl-gradle/src/test/kotlin/org/pkl/gradle/PkldocGeneratorsTest.kt index 20fd136b..297da7c8 100644 --- a/pkl-gradle/src/test/kotlin/org/pkl/gradle/PkldocGeneratorsTest.kt +++ b/pkl-gradle/src/test/kotlin/org/pkl/gradle/PkldocGeneratorsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ class PkldocGeneratorsTest : AbstractTest() { } } } - """ + """, ) writeFile( "doc-package-info.pkl", @@ -57,7 +57,7 @@ class PkldocGeneratorsTest : AbstractTest() { sourceCode = "sources.apple.com/" issueTracker = "issues.apple.com" """ - .trimIndent() + .trimIndent(), ) writeFile( "person.pkl", @@ -76,7 +76,7 @@ class PkldocGeneratorsTest : AbstractTest() { other = 42 """ - .trimIndent() + .trimIndent(), ) runTask("pkldoc") @@ -124,7 +124,7 @@ class PkldocGeneratorsTest : AbstractTest() { } } } - """ + """, ) runTask("pkldoc") @@ -150,7 +150,7 @@ class PkldocGeneratorsTest : AbstractTest() { } } """ - .trimIndent() + .trimIndent(), ) val result = runTask("pkldoc", true) diff --git a/pkl-gradle/src/test/kotlin/org/pkl/gradle/ProjectPackageTest.kt b/pkl-gradle/src/test/kotlin/org/pkl/gradle/ProjectPackageTest.kt index c8fadc7d..29ca4fd0 100644 --- a/pkl-gradle/src/test/kotlin/org/pkl/gradle/ProjectPackageTest.kt +++ b/pkl-gradle/src/test/kotlin/org/pkl/gradle/ProjectPackageTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ class ProjectPackageTest : AbstractTest() { } } } - """ + """, ) } @@ -95,7 +95,7 @@ class ProjectPackageTest : AbstractTest() { } } """ - .trimIndent() + .trimIndent(), ) writeFile( "proj1/PklProject.deps.json", @@ -105,7 +105,7 @@ class ProjectPackageTest : AbstractTest() { "dependencies": {} } """ - .trimIndent() + .trimIndent(), ) writeFile( "proj1/foo.pkl", @@ -114,7 +114,7 @@ class ProjectPackageTest : AbstractTest() { bar: String """ - .trimIndent() + .trimIndent(), ) writeFile( "proj1/tests.pkl", @@ -127,7 +127,7 @@ class ProjectPackageTest : AbstractTest() { } } """ - .trimIndent() + .trimIndent(), ) writeFile("foo.txt", "The contents of foo.txt") } diff --git a/pkl-gradle/src/test/kotlin/org/pkl/gradle/ProjectResolveTest.kt b/pkl-gradle/src/test/kotlin/org/pkl/gradle/ProjectResolveTest.kt index 21b08279..5013e94f 100644 --- a/pkl-gradle/src/test/kotlin/org/pkl/gradle/ProjectResolveTest.kt +++ b/pkl-gradle/src/test/kotlin/org/pkl/gradle/ProjectResolveTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ class ProjectResolveTest : AbstractTest() { } } } - """ + """, ) } @@ -65,7 +65,7 @@ class ProjectResolveTest : AbstractTest() { """ amends "pkl:Project" """ - .trimIndent() + .trimIndent(), ) } } diff --git a/pkl-gradle/src/test/kotlin/org/pkl/gradle/TestsTest.kt b/pkl-gradle/src/test/kotlin/org/pkl/gradle/TestsTest.kt index 22fcecd5..9eed758a 100644 --- a/pkl-gradle/src/test/kotlin/org/pkl/gradle/TestsTest.kt +++ b/pkl-gradle/src/test/kotlin/org/pkl/gradle/TestsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -170,7 +170,7 @@ class TestsTest : AbstractTest() { } """ .trimIndent(), - additionalExamples = examples + additionalExamples = examples, ) writeFile("test.pkl-expected.pcf", bigTestExpected) @@ -276,7 +276,7 @@ class TestsTest : AbstractTest() { } """ .trimIndent(), - additionalExamples = examples + additionalExamples = examples, ) writeFile("test.pkl-expected.pcf", bigTestExpected) @@ -411,7 +411,7 @@ class TestsTest : AbstractTest() { } } } - """ + """, ) } @@ -433,7 +433,7 @@ class TestsTest : AbstractTest() { examples { $additionalExamples } - """ + """, ): Path { return writeFile("test.pkl", contents) } diff --git a/pkl-server/src/main/kotlin/org/pkl/server/BinaryEvaluator.kt b/pkl-server/src/main/kotlin/org/pkl/server/BinaryEvaluator.kt index bb2db155..2c95928f 100644 --- a/pkl-server/src/main/kotlin/org/pkl/server/BinaryEvaluator.kt +++ b/pkl-server/src/main/kotlin/org/pkl/server/BinaryEvaluator.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ internal class BinaryEvaluator( timeout: Duration?, moduleCacheDir: Path?, declaredDependencies: DeclaredDependencies?, - outputFormat: String? + outputFormat: String?, ) : EvaluatorImpl( transformer, @@ -53,7 +53,7 @@ internal class BinaryEvaluator( timeout, moduleCacheDir, declaredDependencies, - outputFormat + outputFormat, ) { fun evaluate(moduleSource: ModuleSource, expression: String?): ByteArray { return doEvaluate(moduleSource) { module -> diff --git a/pkl-server/src/main/kotlin/org/pkl/server/ClientLogger.kt b/pkl-server/src/main/kotlin/org/pkl/server/ClientLogger.kt index cf224e0f..d60c84fe 100644 --- a/pkl-server/src/main/kotlin/org/pkl/server/ClientLogger.kt +++ b/pkl-server/src/main/kotlin/org/pkl/server/ClientLogger.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import org.pkl.core.messaging.MessageTransport internal class ClientLogger( private val evaluatorId: Long, - private val transport: MessageTransport + private val transport: MessageTransport, ) : Logger { override fun trace(message: String, frame: StackFrame) { transport.send(LogMessage(evaluatorId, 0, message, frame.moduleUri)) diff --git a/pkl-server/src/main/kotlin/org/pkl/server/ClientModuleKeyFactory.kt b/pkl-server/src/main/kotlin/org/pkl/server/ClientModuleKeyFactory.kt index 49da5082..77aa8585 100644 --- a/pkl-server/src/main/kotlin/org/pkl/server/ClientModuleKeyFactory.kt +++ b/pkl-server/src/main/kotlin/org/pkl/server/ClientModuleKeyFactory.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import org.pkl.core.module.* internal class ClientModuleKeyFactory( private val readerSpecs: Collection, transport: MessageTransport, - evaluatorId: Long + evaluatorId: Long, ) : ModuleKeyFactory { private val schemes = readerSpecs.map { it.scheme } diff --git a/pkl-server/src/main/kotlin/org/pkl/server/Server.kt b/pkl-server/src/main/kotlin/org/pkl/server/Server.kt index e121fa76..b721a120 100644 --- a/pkl-server/src/main/kotlin/org/pkl/server/Server.kt +++ b/pkl-server/src/main/kotlin/org/pkl/server/Server.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable { MessageTransports.stream( ServerMessagePackDecoder(inputStream), ServerMessagePackEncoder(outputStream), - ::log + ::log, ) ) } @@ -76,7 +76,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable { is EvaluateRequest -> handleEvaluate(message) else -> throw ProtocolException("Unexpected incoming request message: $message") } - } + }, ) } @@ -147,7 +147,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable { private fun buildDeclaredDependencies( projectFileUri: URI, dependencies: Map, - myPackageUri: URI? + myPackageUri: URI?, ): DeclaredDependencies { val remoteDependencies = buildMap { for ((key, dep) in dependencies) { @@ -156,8 +156,8 @@ class Server(private val transport: MessageTransport) : AutoCloseable { key, org.pkl.core.packages.Dependency.RemoteDependency( PackageUri(dep.packageUri), - dep.checksums - ) + dep.checksums, + ), ) } } @@ -175,7 +175,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable { remoteDependencies, localDependencies, projectFileUri, - myPackageUri?.let(::PackageUri) + myPackageUri?.let(::PackageUri), ) } @@ -210,7 +210,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable { allowedModules, allowedResources, SecurityManagers.defaultTrustLevels, - rootDir + rootDir, ), httpClient, ClientLogger(evaluatorId, transport), @@ -221,14 +221,14 @@ class Server(private val transport: MessageTransport) : AutoCloseable { timeout, cacheDir, dependencies, - message.outputFormat + message.outputFormat, ) } private fun createResourceReaders( message: CreateEvaluatorRequest, evaluatorId: Long, - modulePathResolver: ModulePathResolver + modulePathResolver: ModulePathResolver, ): List = buildList { add(ResourceReaders.environmentVariable()) add(ResourceReaders.externalProperty()) @@ -248,7 +248,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable { add( ResourceReaders.externalResolver( readerSpec, - MessageTransportResourceResolver(transport, evaluatorId) + MessageTransportResourceResolver(transport, evaluatorId), ) ) } @@ -257,7 +257,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable { private fun createModuleKeyFactories( message: CreateEvaluatorRequest, evaluatorId: Long, - modulePathResolver: ModulePathResolver + modulePathResolver: ModulePathResolver, ): List = buildList { // add client-side module key factory first to ensure it wins over builtin ones if (message.clientModuleReaders?.isNotEmpty() == true) { @@ -268,7 +268,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable { ModuleKeyFactories.externalProcess( scheme, getExternalProcess(evaluatorId, spec), - evaluatorId + evaluatorId, ) ) } diff --git a/pkl-server/src/main/kotlin/org/pkl/server/ServerMessagePackDecoder.kt b/pkl-server/src/main/kotlin/org/pkl/server/ServerMessagePackDecoder.kt index 833ab8d1..57aa3b78 100644 --- a/pkl-server/src/main/kotlin/org/pkl/server/ServerMessagePackDecoder.kt +++ b/pkl-server/src/main/kotlin/org/pkl/server/ServerMessagePackDecoder.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,13 +52,13 @@ class ServerMessagePackDecoder(unpacker: MessageUnpacker) : BaseMessagePackDecod map.unpackProject(), map.unpackHttp(), unpackStringMapOrNull(map, "externalModuleReaders", ::unpackExternalReader), - unpackStringMapOrNull(map, "externalResourceReaders", ::unpackExternalReader) + unpackStringMapOrNull(map, "externalResourceReaders", ::unpackExternalReader), ) Message.Type.CREATE_EVALUATOR_RESPONSE -> CreateEvaluatorResponse( unpackLong(map, "requestId"), unpackLongOrNull(map, "evaluatorId"), - unpackStringOrNull(map, "error") + unpackStringOrNull(map, "error"), ) Message.Type.CLOSE_EVALUATOR -> CloseEvaluator(unpackLong(map, "evaluatorId")) Message.Type.EVALUATE_REQUEST -> @@ -67,21 +67,21 @@ class ServerMessagePackDecoder(unpacker: MessageUnpacker) : BaseMessagePackDecod unpackLong(map, "evaluatorId"), URI(unpackString(map, "moduleUri")), unpackStringOrNull(map, "moduleText"), - unpackStringOrNull(map, "expr") + unpackStringOrNull(map, "expr"), ) Message.Type.EVALUATE_RESPONSE -> EvaluateResponse( unpackLong(map, "requestId"), unpackLong(map, "evaluatorId"), unpackByteArray(map, "result"), - unpackStringOrNull(map, "error") + unpackStringOrNull(map, "error"), ) Message.Type.LOG_MESSAGE -> LogMessage( unpackLong(map, "evaluatorId"), unpackInt(map, "level"), unpackString(map, "message"), - unpackString(map, "frameUri") + unpackString(map, "frameUri"), ) else -> super.decodeMessage(msgType, map) } diff --git a/pkl-server/src/main/kotlin/org/pkl/server/ServerMessages.kt b/pkl-server/src/main/kotlin/org/pkl/server/ServerMessages.kt index 1e7562d6..cbb7ad89 100644 --- a/pkl-server/src/main/kotlin/org/pkl/server/ServerMessages.kt +++ b/pkl-server/src/main/kotlin/org/pkl/server/ServerMessages.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ data class CreateEvaluatorRequest( val project: Project?, val http: Http?, val externalModuleReaders: Map?, - val externalResourceReaders: Map? + val externalResourceReaders: Map?, ) : Message.Client.Request { override fun type(): Message.Type = Message.Type.CREATE_EVALUATOR_REQUEST @@ -61,11 +61,11 @@ data class CreateEvaluatorRequest( return requestId == other.requestId && Objects.equals( allowedModules?.map { it.pattern() }, - other.allowedModules?.map { it.pattern() } + other.allowedModules?.map { it.pattern() }, ) && Objects.equals( allowedResources?.map { it.pattern() }, - other.allowedResources?.map { it.pattern() } + other.allowedResources?.map { it.pattern() }, ) && clientModuleReaders.equalsNullable(other.clientModuleReaders) && clientResourceReaders.equalsNullable(other.clientResourceReaders) && @@ -108,7 +108,7 @@ data class Http( /** PEM-format CA certificates as raw bytes. */ val caCertificates: ByteArray?, /** Proxy settings */ - val proxy: Proxy? + val proxy: Proxy?, ) { override fun equals(other: Any?): Boolean { if (this === other) return true @@ -130,7 +130,7 @@ data class Http( enum class DependencyType(val value: String) { LOCAL("local"), - REMOTE("remote") + REMOTE("remote"), } sealed interface Dependency { @@ -145,7 +145,7 @@ data class RemoteDependency(override val packageUri: URI, val checksums: Checksu data class Project( val projectFileUri: URI, override val packageUri: URI?, - val dependencies: Map + val dependencies: Map, ) : Dependency { override val type: DependencyType = DependencyType.LOCAL } @@ -169,7 +169,7 @@ data class EvaluateRequest( val evaluatorId: Long, val moduleUri: URI, val moduleText: String?, - val expr: String? + val expr: String?, ) : Message.Client.Request { override fun type(): Message.Type = Message.Type.EVALUATE_REQUEST @@ -180,7 +180,7 @@ data class EvaluateResponse( private val requestId: Long, val evaluatorId: Long, val result: ByteArray?, - val error: String? + val error: String?, ) : Message.Server.Response { override fun type(): Message.Type = Message.Type.EVALUATE_RESPONSE @@ -212,7 +212,7 @@ data class LogMessage( val evaluatorId: Long, val level: Int, val message: String, - val frameUri: String + val frameUri: String, ) : Message.Server.OneWay { override fun type(): Message.Type = Message.Type.LOG_MESSAGE } diff --git a/pkl-server/src/test/kotlin/org/pkl/server/JvmServerTest.kt b/pkl-server/src/test/kotlin/org/pkl/server/JvmServerTest.kt index abe30444..84dbf636 100644 --- a/pkl-server/src/test/kotlin/org/pkl/server/JvmServerTest.kt +++ b/pkl-server/src/test/kotlin/org/pkl/server/JvmServerTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,13 +37,13 @@ class JvmServerTest : AbstractServerTest() { MessageTransports.stream( ServerMessagePackDecoder(in1), ServerMessagePackEncoder(out2), - ::log + ::log, ), MessageTransports.stream( ServerMessagePackDecoder(in2), ServerMessagePackEncoder(out1), - ::log - ) + ::log, + ), ) } } diff --git a/pkl-server/src/test/kotlin/org/pkl/server/NativeServerTest.kt b/pkl-server/src/test/kotlin/org/pkl/server/NativeServerTest.kt index 40b7c69c..c34c2862 100644 --- a/pkl-server/src/test/kotlin/org/pkl/server/NativeServerTest.kt +++ b/pkl-server/src/test/kotlin/org/pkl/server/NativeServerTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ class NativeServerTest : AbstractServerTest() { TestTransport( MessageTransports.stream( ServerMessagePackDecoder(server.inputStream), - ServerMessagePackEncoder(server.outputStream) + ServerMessagePackEncoder(server.outputStream), ) { _ -> } ) diff --git a/pkl-server/src/test/kotlin/org/pkl/server/ServerMessagePackCodecTest.kt b/pkl-server/src/test/kotlin/org/pkl/server/ServerMessagePackCodecTest.kt index 26dd08cf..d0dff6e0 100644 --- a/pkl-server/src/test/kotlin/org/pkl/server/ServerMessagePackCodecTest.kt +++ b/pkl-server/src/test/kotlin/org/pkl/server/ServerMessagePackCodecTest.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,18 +52,8 @@ class ServerMessagePackCodecTest { @Test fun `round-trip CreateEvaluatorRequest`() { - val resourceReader1 = - ResourceReaderSpec( - "resourceReader1", - true, - true, - ) - val resourceReader2 = - ResourceReaderSpec( - "resourceReader2", - true, - false, - ) + val resourceReader1 = ResourceReaderSpec("resourceReader1", true, true) + val resourceReader2 = ResourceReaderSpec("resourceReader2", true, false) val moduleReader1 = ModuleReaderSpec("moduleReader1", true, true, true) val moduleReader2 = ModuleReaderSpec("moduleReader2", true, false, false) val externalReader = ExternalReader("external-cmd", listOf("arg1", "arg2")) @@ -99,18 +89,18 @@ class ServerMessagePackCodecTest { Project( projectFileUri = URI("file:///bar"), packageUri = URI("package://localhost:0/bar@1.1.0"), - dependencies = emptyMap() + dependencies = emptyMap(), ) - ) + ), ), "baz" to - RemoteDependency(URI("package://localhost:0/baz@1.1.0"), Checksums("abc123")) - ) + RemoteDependency(URI("package://localhost:0/baz@1.1.0"), Checksums("abc123")), + ), ), http = Http( proxy = PklEvaluatorSettings.Proxy(URI("http://foo.com:1234"), listOf("bar", "baz")), - caCertificates = byteArrayOf(1, 2, 3, 4) + caCertificates = byteArrayOf(1, 2, 3, 4), ), externalModuleReaders = mapOf("external" to externalReader, "external2" to externalReader), externalResourceReaders = mapOf("external" to externalReader), @@ -136,7 +126,7 @@ class ServerMessagePackCodecTest { evaluatorId = 456, moduleUri = URI("some/module.pkl"), moduleText = null, - expr = "some + expression" + expr = "some + expression", ) ) } @@ -148,7 +138,7 @@ class ServerMessagePackCodecTest { requestId = 123, evaluatorId = 456, result = byteArrayOf(1, 2, 3, 4, 5), - error = null + error = null, ) ) } @@ -160,7 +150,7 @@ class ServerMessagePackCodecTest { evaluatorId = 123, level = 0, message = "Hello, world!", - frameUri = "file:///some/module.pkl" + frameUri = "file:///some/module.pkl", ) ) } diff --git a/stdlib/stdlib.gradle.kts b/stdlib/stdlib.gradle.kts index 5914027a..da974a76 100644 --- a/stdlib/stdlib.gradle.kts +++ b/stdlib/stdlib.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ spotless { target("*.pkl") licenseHeaderFile( rootProject.file("buildSrc/src/main/resources/license-header.line-comment.txt"), - "/// " + "/// ", ) } }