Reformat Kotlin code (#1560)

ktfmt has much improved how it formats Kotlin code. Unfortunately, this
means that whenever we touch a single line in a Kotlin file, we get a
_lot_ more changes thanks to ratcheting now picking up this file for
formatting.

This PR just reformats every single Kotlin file so we don't have to deal
with this churn in future PRs that touch Kotlin code.
This commit is contained in:
Daniel Chao
2026-04-25 06:14:44 -07:00
committed by GitHub
parent c4f56bf20d
commit 2b3603b544
44 changed files with 2862 additions and 2848 deletions
+82 -70
View File
@@ -1,3 +1,22 @@
/*
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.nio.file.Files
import kotlin.io.path.isDirectory
import kotlin.io.path.isRegularFile
import kotlin.io.path.useDirectoryEntries
import org.junit.platform.commons.annotation.Testable import org.junit.platform.commons.annotation.Testable
import org.junit.platform.engine.* import org.junit.platform.engine.*
import org.junit.platform.engine.TestDescriptor.Type import org.junit.platform.engine.TestDescriptor.Type
@@ -16,23 +35,18 @@ import org.pkl.core.Loggers
import org.pkl.core.SecurityManagers import org.pkl.core.SecurityManagers
import org.pkl.core.StackFrameTransformers import org.pkl.core.StackFrameTransformers
import org.pkl.core.evaluatorSettings.TraceMode import org.pkl.core.evaluatorSettings.TraceMode
import org.pkl.core.http.HttpClient
import org.pkl.core.module.ModuleKeyFactories import org.pkl.core.module.ModuleKeyFactories
import org.pkl.core.repl.ReplRequest import org.pkl.core.repl.ReplRequest
import org.pkl.core.repl.ReplResponse import org.pkl.core.repl.ReplResponse
import org.pkl.core.repl.ReplServer import org.pkl.core.repl.ReplServer
import org.pkl.core.resource.ResourceReaders
import org.pkl.core.util.IoUtils import org.pkl.core.util.IoUtils
import org.pkl.core.http.HttpClient
import org.pkl.parser.Parser import org.pkl.parser.Parser
import org.pkl.parser.ParserError import org.pkl.parser.ParserError
import org.pkl.parser.syntax.ClassProperty import org.pkl.parser.syntax.ClassProperty
import org.pkl.core.resource.ResourceReaders
import java.nio.file.Files
import kotlin.io.path.isDirectory
import kotlin.io.path.isRegularFile
import kotlin.io.path.useDirectoryEntries
@Testable @Testable class DocSnippetTests
class DocSnippetTests
class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.ExecutionContext>() { class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.ExecutionContext>() {
private val projectDir = rootProjectDir.resolve("docs") private val projectDir = rootProjectDir.resolve("docs")
@@ -41,7 +55,8 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
private companion object { private companion object {
val headingRegex = Regex("""(?u)^\s*(=++)\s*(.+)""") val headingRegex = Regex("""(?u)^\s*(=++)\s*(.+)""")
val collapsibleBlockRegex = Regex("""(?u)^\s*\[%collapsible""") val collapsibleBlockRegex = Regex("""(?u)^\s*\[%collapsible""")
val codeBlockRegex = Regex("""(?u)^\s*\[source(?:%(tested|parsed)(%error)?)?(?:,\{?([a-zA-Z-_]+)}?)?""") val codeBlockRegex =
Regex("""(?u)^\s*\[source(?:%(tested|parsed)(%error)?)?(?:,\{?([a-zA-Z-_]+)}?)?""")
val codeBlockNameRegex = Regex("""(?u)^\s*\.(.+)""") val codeBlockNameRegex = Regex("""(?u)^\s*\.(.+)""")
val codeBlockDelimiterRegex = Regex("""(?u)^\s*----""") val codeBlockDelimiterRegex = Regex("""(?u)^\s*----""")
val graphicsRegex = Regex("\\[small]#.+#") val graphicsRegex = Regex("\\[small]#.+#")
@@ -51,7 +66,7 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
override fun discover( override fun discover(
discoveryRequest: EngineDiscoveryRequest, discoveryRequest: EngineDiscoveryRequest,
uniqueId: UniqueId uniqueId: UniqueId,
): TestDescriptor { ): TestDescriptor {
val packageSelectors = discoveryRequest.getSelectorsByType(PackageSelector::class.java) val packageSelectors = discoveryRequest.getSelectorsByType(PackageSelector::class.java)
val classSelectors = discoveryRequest.getSelectorsByType(ClassSelector::class.java) val classSelectors = discoveryRequest.getSelectorsByType(ClassSelector::class.java)
@@ -62,12 +77,14 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
val packageName = testClass.`package`.name val packageName = testClass.`package`.name
val className = testClass.name val className = testClass.name
if (methodSelectors.isEmpty() if (
&& (packageSelectors.isEmpty() || packageSelectors.any { it.packageName == packageName }) methodSelectors.isEmpty() &&
&& (classSelectors.isEmpty() || classSelectors.any { it.className == className }) (packageSelectors.isEmpty() || packageSelectors.any { it.packageName == packageName }) &&
(classSelectors.isEmpty() || classSelectors.any { it.className == className })
) { ) {
val rootDescriptor = Descriptor.Path(uniqueId, docsDir.fileName.toString(), ClassSource.from(testClass), docsDir) val rootDescriptor =
Descriptor.Path(uniqueId, docsDir.fileName.toString(), ClassSource.from(testClass), docsDir)
doDiscover(rootDescriptor, uniqueIdSelectors) doDiscover(rootDescriptor, uniqueIdSelectors)
return rootDescriptor return rootDescriptor
} }
@@ -77,19 +94,17 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
} }
override fun createExecutionContext(request: ExecutionRequest): ExecutionContext { override fun createExecutionContext(request: ExecutionRequest): ExecutionContext {
val replServer = ReplServer( val replServer =
ReplServer(
SecurityManagers.defaultManager, SecurityManagers.defaultManager,
HttpClient.dummyClient(), HttpClient.dummyClient(),
Loggers.stdErr(), Loggers.stdErr(),
listOf( listOf(
ModuleKeyFactories.standardLibrary, ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.classPath(DocSnippetTests::class.java.classLoader), ModuleKeyFactories.classPath(DocSnippetTests::class.java.classLoader),
ModuleKeyFactories.file ModuleKeyFactories.file,
),
listOf(
ResourceReaders.environmentVariable(),
ResourceReaders.externalProperty()
), ),
listOf(ResourceReaders.environmentVariable(), ResourceReaders.externalProperty()),
System.getenv(), System.getenv(),
emptyMap(), emptyMap(),
null, null,
@@ -104,9 +119,9 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
} }
private fun doDiscover(rootDescriptor: TestDescriptor, selectors: List<UniqueIdSelector>) { private fun doDiscover(rootDescriptor: TestDescriptor, selectors: List<UniqueIdSelector>) {
fun isMatch(other: UniqueId) = selectors.isEmpty() || selectors.any { fun isMatch(other: UniqueId) =
it.uniqueId.hasPrefix(other) || other.hasPrefix(it.uniqueId) selectors.isEmpty() ||
} selectors.any { it.uniqueId.hasPrefix(other) || other.hasPrefix(it.uniqueId) }
docsDir.useDirectoryEntries { docsDirEntries -> docsDir.useDirectoryEntries { docsDirEntries ->
for (docsDirEntry in docsDirEntries) { for (docsDirEntry in docsDirEntries) {
@@ -116,11 +131,12 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
val docsDirEntryId = rootDescriptor.uniqueId.append("dir", docsDirEntryName) val docsDirEntryId = rootDescriptor.uniqueId.append("dir", docsDirEntryName)
if (!isMatch(docsDirEntryId)) continue if (!isMatch(docsDirEntryId)) continue
val docsDirEntryDescriptor = Descriptor.Path( val docsDirEntryDescriptor =
Descriptor.Path(
docsDirEntryId, docsDirEntryId,
docsDirEntryName, docsDirEntryName,
DirectorySource.from(docsDirEntry.toFile()), DirectorySource.from(docsDirEntry.toFile()),
docsDirEntry docsDirEntry,
) )
rootDescriptor.addChild(docsDirEntryDescriptor) rootDescriptor.addChild(docsDirEntryDescriptor)
@@ -131,16 +147,19 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
for (pagesDirEntry in pagesDirEntries) { for (pagesDirEntry in pagesDirEntries) {
val pagesDirEntryName = pagesDirEntry.fileName.toString() val pagesDirEntryName = pagesDirEntry.fileName.toString()
val pagesDirEntryId = docsDirEntryId.append("file", pagesDirEntryName) val pagesDirEntryId = docsDirEntryId.append("file", pagesDirEntryName)
if (!pagesDirEntry.isRegularFile() || if (
!pagesDirEntry.isRegularFile() ||
!pagesDirEntryName.endsWith(".adoc") || !pagesDirEntryName.endsWith(".adoc") ||
!isMatch(pagesDirEntryId) !isMatch(pagesDirEntryId)
) continue )
continue
val pagesDirEntryDescriptor = Descriptor.Path( val pagesDirEntryDescriptor =
Descriptor.Path(
pagesDirEntryId, pagesDirEntryId,
pagesDirEntryName, pagesDirEntryName,
FileSource.from(pagesDirEntry.toFile()), FileSource.from(pagesDirEntry.toFile()),
pagesDirEntry pagesDirEntry,
) )
docsDirEntryDescriptor.addChild(pagesDirEntryDescriptor) docsDirEntryDescriptor.addChild(pagesDirEntryDescriptor)
@@ -174,16 +193,14 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
} }
val parent = sections.firstOrNull() ?: docDescriptor val parent = sections.firstOrNull() ?: docDescriptor
val normalizedTitle = title val normalizedTitle =
.replace("<code>", "") title.replace("<code>", "").replace("</code>", "").replace(graphicsRegex, "").trim()
.replace("</code>", "") val childSection =
.replace(graphicsRegex, "") Descriptor.Section(
.trim()
val childSection = Descriptor.Section(
parent.uniqueId.append("section", normalizedTitle), parent.uniqueId.append("section", normalizedTitle),
normalizedTitle, normalizedTitle,
FileSource.from(docDescriptor.path.toFile(), FilePosition.from(lineNum)), FileSource.from(docDescriptor.path.toFile(), FilePosition.from(lineNum)),
newLevel newLevel,
) )
sections.addFirst(childSection) sections.addFirst(childSection)
@@ -217,7 +234,8 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
codeBlockNum += 1 codeBlockNum += 1
val (testMode, error, language) = codeBlockMatch.destructured val (testMode, error, language) = codeBlockMatch.destructured
if (testMode.isNotEmpty()) { if (testMode.isNotEmpty()) {
val blockName = codeBlockNameRegex.find(prevLine)?.groupValues?.get(1) ?: "snippet$codeBlockNum" val blockName =
codeBlockNameRegex.find(prevLine)?.groupValues?.get(1) ?: "snippet$codeBlockNum"
while (linesIterator.hasNext()) { while (linesIterator.hasNext()) {
advance() advance()
val startDelimiterMatch = codeBlockDelimiterRegex.find(line) val startDelimiterMatch = codeBlockDelimiterRegex.find(line)
@@ -236,10 +254,13 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
snippetId, snippetId,
blockName, blockName,
language, language,
FileSource.from(docDescriptor.path.toFile(), FilePosition.from(jumpToLineNum)), FileSource.from(
docDescriptor.path.toFile(),
FilePosition.from(jumpToLineNum),
),
builder.toString(), builder.toString(),
testMode == "parsed", testMode == "parsed",
error.isNotEmpty() error.isNotEmpty(),
) )
) )
} }
@@ -261,28 +282,21 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
} }
} }
private sealed class Descriptor( private sealed class Descriptor(uniqueId: UniqueId, displayName: String, source: TestSource) :
uniqueId: UniqueId, AbstractTestDescriptor(uniqueId, displayName, source), Node<ExecutionContext> {
displayName: String,
source: TestSource
) : AbstractTestDescriptor(uniqueId, displayName, source), Node<ExecutionContext> {
class Path( class Path(
uniqueId: UniqueId, uniqueId: UniqueId,
displayName: String, displayName: String,
source: TestSource, source: TestSource,
val path: java.nio.file.Path val path: java.nio.file.Path,
) : Descriptor(uniqueId, displayName, source) { ) : Descriptor(uniqueId, displayName, source) {
override fun getType() = Type.CONTAINER override fun getType() = Type.CONTAINER
} }
class Section( class Section(uniqueId: UniqueId, displayName: String, source: TestSource, val level: Int) :
uniqueId: UniqueId, Descriptor(uniqueId, displayName, source) {
displayName: String,
source: TestSource,
val level: Int
) : Descriptor(uniqueId, displayName, source) {
override fun getType() = Type.CONTAINER override fun getType() = Type.CONTAINER
@@ -299,7 +313,7 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
source: TestSource, source: TestSource,
private val code: String, private val code: String,
private val parseOnly: Boolean, private val parseOnly: Boolean,
private val expectError: Boolean private val expectError: Boolean,
) : Descriptor(uniqueId, displayName, source) { ) : Descriptor(uniqueId, displayName, source) {
override fun getType() = Type.TEST override fun getType() = Type.TEST
@@ -308,11 +322,14 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
when (language) { when (language) {
"pkl" -> Parser().parseModule(code) "pkl" -> Parser().parseModule(code)
"pkl-expr" -> Parser().parseExpressionInput(code) "pkl-expr" -> Parser().parseExpressionInput(code)
else -> throw(Exception("Unrecognized language: $language")) else -> throw (Exception("Unrecognized language: $language"))
} }
} }
override fun execute(context: ExecutionContext, executor: DynamicTestExecutor): ExecutionContext { override fun execute(
context: ExecutionContext,
executor: DynamicTestExecutor,
): ExecutionContext {
if (parseOnly) { if (parseOnly) {
try { try {
parsed parsed
@@ -328,12 +345,7 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
} }
context.replServer.handleRequest( context.replServer.handleRequest(
ReplRequest.Eval( ReplRequest.Eval("snippet", code, !expectError, !expectError)
"snippet",
code,
!expectError,
!expectError
)
) )
val properties = parsed.children()?.filterIsInstance<ClassProperty>() ?: emptyList() val properties = parsed.children()?.filterIsInstance<ClassProperty>() ?: emptyList()
@@ -342,21 +354,21 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
// force each property // force each property
for (prop in properties) { for (prop in properties) {
responses.addAll(context.replServer.handleRequest( responses.addAll(
ReplRequest.Eval( context.replServer.handleRequest(
"snippet", ReplRequest.Eval("snippet", prop.name.value, false, true)
prop.name.value, )
false,
true
) )
))
} }
if (expectError) { if (expectError) {
if (responses.dropLast(1).any { it !is ReplResponse.EvalSuccess } || if (
responses.last() !is ReplResponse.EvalError) { responses.dropLast(1).any { it !is ReplResponse.EvalSuccess } ||
responses.last() !is ReplResponse.EvalError
) {
throw AssertionError( throw AssertionError(
"Expected %error snippet to fail at the end, but got the following REPL responses:\n\n" + "Expected %error snippet to fail at the end, but got the following REPL responses:\n\n" +
responses.joinToString("\n\n") { it.message }) responses.joinToString("\n\n") { it.message }
)
} }
return context return context
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1549,8 +1549,9 @@ class JavaCodeGeneratorTest {
// not worthwhile to add spring & spring boot dependency just so that this test can compile // not worthwhile to add spring & spring boot dependency just so that this test can compile
// their annotations // their annotations
val javaCodeWithoutSpringAnnotations = val javaCodeWithoutSpringAnnotations = javaCode.deleteLines {
javaCode.deleteLines { it.contains("ConfigurationProperties") } it.contains("ConfigurationProperties")
}
assertThat(javaCodeWithoutSpringAnnotations).compilesSuccessfully() assertThat(javaCodeWithoutSpringAnnotations).compilesSuccessfully()
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1464,8 +1464,9 @@ class KotlinCodeGeneratorTest {
// not worthwhile to add spring & spring boot dependency just so that this test can compile // not worthwhile to add spring & spring boot dependency just so that this test can compile
// their annotations // their annotations
val kotlinCodeWithoutSpringAnnotations = val kotlinCodeWithoutSpringAnnotations = kotlinCode.deleteLines {
kotlinCode.deleteLines { it.contains("ConfigurationProperties") } it.contains("ConfigurationProperties")
}
assertThat(kotlinCodeWithoutSpringAnnotations).compilesSuccessfully() assertThat(kotlinCodeWithoutSpringAnnotations).compilesSuccessfully()
} }
@@ -192,8 +192,7 @@ data class CliBaseOptions(
// sort modules to make cli output independent of source module order // sort modules to make cli output independent of source module order
.sorted() .sorted()
val normalizedSettingsModule: URI? = val normalizedSettingsModule: URI? = settings?.let { uri ->
settings?.let { uri ->
if (uri.isAbsolute) uri else IoUtils.resolve(normalizedWorkingDir.toUri(), uri) if (uri.isAbsolute) uri else IoUtils.resolve(normalizedWorkingDir.toUri(), uri)
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -69,8 +69,7 @@ internal class MainPageGenerator(
private fun HtmlBlockTag.renderPackages() { private fun HtmlBlockTag.renderPackages() {
if (packagesData.isEmpty()) return if (packagesData.isEmpty()) return
val sortedPackages = val sortedPackages = packagesData.sortedWith { pkg1, pkg2 ->
packagesData.sortedWith { pkg1, pkg2 ->
when { when {
pkg1.ref.pkg == "pkl" -> -1 // always sort the stdlib first pkg1.ref.pkg == "pkl" -> -1 // always sort the stdlib first
else -> pkg1.ref.pkg.compareTo(pkg2.ref.pkg) else -> pkg1.ref.pkg.compareTo(pkg2.ref.pkg)
@@ -723,11 +723,13 @@ internal abstract class PageGenerator<out S>(
?.let { markdownRenderer.render(markdownParser.parse(it)).trim().ifEmpty { null } } ?.let { markdownRenderer.render(markdownParser.parse(it)).trim().ifEmpty { null } }
} }
private val deprecatedAnnotation: PObject? = private val deprecatedAnnotation: PObject? = annotations.find {
annotations.find { it.classInfo == PClassInfo.Deprecated } it.classInfo == PClassInfo.Deprecated
}
private val alsoKnownAsAnnotation: PObject? = private val alsoKnownAsAnnotation: PObject? = annotations.find {
annotations.find { it.classInfo == PClassInfo.AlsoKnownAs } it.classInfo == PClassInfo.AlsoKnownAs
}
val isDeprecatedMember: Boolean = deprecatedAnnotation != null val isDeprecatedMember: Boolean = deprecatedAnnotation != null
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -36,11 +36,11 @@ internal fun AutoCloseable.closeQuietly() {
} }
} }
internal val threadLocalBufferPacker: ThreadLocal<MessageBufferPacker> = internal val threadLocalBufferPacker: ThreadLocal<MessageBufferPacker> = ThreadLocal.withInitial {
ThreadLocal.withInitial { MessagePack.newDefaultBufferPacker() } MessagePack.newDefaultBufferPacker()
}
private val threadLocalEncoder: ThreadLocal<(Message) -> ByteArray> = private val threadLocalEncoder: ThreadLocal<(Message) -> ByteArray> = ThreadLocal.withInitial {
ThreadLocal.withInitial {
val packer = threadLocalBufferPacker.get() val packer = threadLocalBufferPacker.get()
val encoder = ServerMessagePackEncoder(packer); val encoder = ServerMessagePackEncoder(packer);
{ message: Message -> { message: Message ->
@@ -48,7 +48,7 @@ private val threadLocalEncoder: ThreadLocal<(Message) -> ByteArray> =
encoder.encode(message) encoder.encode(message)
packer.toByteArray() packer.toByteArray()
} }
} }
@Suppress("unused") @Suppress("unused")
internal fun encode(message: Message): ByteArray { internal fun encode(message: Message): ByteArray {