Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ val upstreamMavenVersion: Provider<String> = run {
val child = childPom.singleFile.readText()
val parentBlock =
checkNotNull(
Regex("""<parent>(.*?)</parent>""", RegexOption.DOT_MATCHES_ALL).find(child)
Regex("""<parent>(.*?)</parent>""", RegexOption.DOT_MATCHES_ALL).find(child),
) {
"kotlin-maven-plugin の POM に <parent> がありません"
}
Expand All @@ -124,7 +124,7 @@ val upstreamMavenVersion: Provider<String> = run {
}
checkNotNull(
Regex("""<maven\.version>([^<]+)</maven\.version>""")
.find(parentPom.singleFile.readText())
.find(parentPom.singleFile.readText()),
) {
"親 POM に <maven.version> がありません"
}
Expand Down Expand Up @@ -152,7 +152,7 @@ val checkMavenVersion =
if (declared != expected) {
throw GradleException(
"maven 版が kotlin-maven-plugin の参照版とズレています(宣言 $declared / 上流 $expected)。" +
"./gradlew syncMavenVersion で追随してください"
"./gradlew syncMavenVersion で追随してください",
)
}
}
Expand Down Expand Up @@ -232,7 +232,7 @@ val checkVersionMentions =
if (stale.isNotEmpty()) {
throw GradleException(
"現行バージョンとズレた表記があります: ${stale.joinToString { it.first }}。" +
"./gradlew syncVersionMentions で追随してください"
"./gradlew syncVersionMentions で追随してください",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class EnumizeCommandLineProcessor : CommandLineProcessor {
LABEL_CASE_OPTION_NAME -> configuration.put(LABEL_CASE_KEY, parseLabelCase(value))
else ->
throw CliOptionProcessingException(
"Unsupported plugin option: ${option.optionName}"
"Unsupported plugin option: ${option.optionName}",
)
}
}
Expand Down Expand Up @@ -57,7 +57,7 @@ class EnumizeCommandLineProcessor : CommandLineProcessor {
EnumizeLabelCase.fromNameOrNull(value)
?: throw CliOptionProcessingException(
"Unknown value for plugin option '$LABEL_CASE_OPTION_NAME': '$value'. " +
"Expected one of: ${EnumizeLabelCase.entries.joinToString { it.name }}"
"Expected one of: ${EnumizeLabelCase.entries.joinToString { it.name }}",
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EnumizeCompilerPluginRegistrar : CompilerPluginRegistrar() {
configuration[EnumizeCommandLineProcessor.LABEL_CASE_KEY]
?: EnumizeLabelCase.BUILT_IN_DEFAULT
FirExtensionRegistrarAdapter.registerExtension(
EnumizeFirExtensionRegistrar(defaultLabelCase)
EnumizeFirExtensionRegistrar(defaultLabelCase),
)
IrGenerationExtension.registerExtension(EnumizeIrGenerationExtension(defaultLabelCase))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class EnumizeDeclarationGenerationExtension(session: FirSession) :
}

override fun generateConstructors(
context: MemberGenerationContext
context: MemberGenerationContext,
): List<FirConstructorSymbol> {
val owner = context.owner as? FirRegularClassSymbol ?: return emptyList()
if (!owner.rawStatus.isCompanion || !owner.isGeneratedByEnumize) return emptyList()
Expand Down Expand Up @@ -306,8 +306,8 @@ class EnumizeDeclarationGenerationExtension(session: FirSession) :
createCompanionObject(enumish, EnumizeKey) {
superType(
EnumizeNames.ENUMISH_COMPANION_CLASS_ID.constructClassLikeType(
arrayOf<ConeTypeProjection>(enumish.classId.constructClassLikeType())
)
arrayOf<ConeTypeProjection>(enumish.classId.constructClassLikeType()),
),
)
}
EnumizeOwnerGeneratorPatch.stamp(companion, this)
Expand Down Expand Up @@ -351,7 +351,7 @@ class EnumizeDeclarationGenerationExtension(session: FirSession) :
EnumizeKey,
EnumizeNames.ENUMIZED_CLASS_PROPERTY,
StandardClassIds.KClass.constructClassLikeType(
arrayOf(ConeKotlinTypeProjectionOut(resolver.starProjectedType(base)))
arrayOf(ConeKotlinTypeProjectionOut(resolver.starProjectedType(base))),
),
hasBackingField = false,
) {
Expand Down Expand Up @@ -392,7 +392,7 @@ class EnumizeDeclarationGenerationExtension(session: FirSession) :
EnumizeKey,
EnumizeNames.ENUMIZED_CLASS_PROPERTY,
StandardClassIds.KClass.constructClassLikeType(
arrayOf<ConeTypeProjection>(resolver.starProjectedType(leaf))
arrayOf<ConeTypeProjection>(resolver.starProjectedType(leaf)),
),
hasBackingField = false,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class EnumizeHierarchyResolver(

fun starProjectedType(symbol: FirRegularClassSymbol): ConeClassLikeType =
symbol.classId.constructClassLikeType(
Array<ConeTypeProjection>(symbol.typeParameterSymbols.size) { ConeStarProjection }
Array<ConeTypeProjection>(symbol.typeParameterSymbols.size) { ConeStarProjection },
)

// asEnumish の返り値型の規則(docs/コンパイラプラグイン設計01.md §5.4・docs/エッジケースへの対応方針.md §1.3)。
Expand Down Expand Up @@ -291,7 +291,7 @@ class EnumizeHierarchyResolver(
}

private fun computeSupertypeClosure(
symbol: FirRegularClassSymbol
symbol: FirRegularClassSymbol,
): List<FirRegularClassSymbol> {
val result = LinkedHashMap<ClassId, FirRegularClassSymbol>()
collectClosure(symbol, result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class EnumizeSupertypeGenerationExtension(session: FirSession) :
.constructClassLikeType()
return listOf(
EnumizeNames.ENUMIZED_CLASS_ID.constructClassLikeType(
arrayOf<ConeTypeProjection>(enumishType)
)
arrayOf<ConeTypeProjection>(enumishType),
),
)
}

Expand All @@ -120,7 +120,7 @@ class EnumizeSupertypeGenerationExtension(session: FirSession) :

// 処理中の宣言に与えられた解決済み supertype を展開して辿り、階層の基底を探す
private fun findBaseFromResolved(
resolvedSupertypes: List<FirResolvedTypeRef>
resolvedSupertypes: List<FirResolvedTypeRef>,
): FirRegularClassSymbol? {
val superSymbols = resolvedSupertypes.mapNotNull {
tracker.resolveExpandedClassSymbol(it.coneType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ object EnumizeRegularClassChecker : FirRegularClassChecker(MppCheckerKind.Common
// 継承経路上で label を宣言している最初のクラス。Enumish 由来(runtime-api Enumish・生成 Enumish)の
// label は kind の値そのものを返すためシャドーイングの実害が無く、対象から外す
private fun EnumizeHierarchyResolver.inheritedLabelOwner(
symbol: FirRegularClassSymbol
symbol: FirRegularClassSymbol,
): FirRegularClassSymbol? =
supertypeClosure(symbol).firstOrNull { superSymbol ->
superSymbol.classId != EnumizeNames.ENUMISH_CLASS_ID &&
Expand All @@ -466,7 +466,7 @@ object EnumizeRegularClassChecker : FirRegularClassChecker(MppCheckerKind.Common

// private プロパティはクラス外の呼び出し点の解決に参加せず継承もされないため、シャドーイングの対象から外す
private fun EnumizeHierarchyResolver.isVisibleLabelProperty(
declaration: FirDeclaration
declaration: FirDeclaration,
): Boolean {
if (declaration !is FirProperty || declaration.name != EnumizeNames.LABEL) return false
if (declaration.symbol.isGeneratedByEnumize) return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class EnumizeEntriesHolderIrGenerator(private val ctx: EnumizeIrContext) {
returnType,
base.symbol,
baseStarType,
)
),
)
}
}
Expand Down Expand Up @@ -149,7 +149,7 @@ class EnumizeEntriesHolderIrGenerator(private val ctx: EnumizeIrContext) {
irCall(ctx.listOfVararg, returnType).apply {
typeArguments[0] = enumishType
arguments[0] = vararg
}
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class EnumizeIrBaseGenerator(private val ctx: EnumizeIrContext) {
+irReturn(
irCall(holderEntriesGetter.symbol, getter.returnType).apply {
dispatchReceiver = irGetObjectValue(holder.defaultType, holder.symbol)
}
},
)
}
}
Expand All @@ -125,7 +125,7 @@ class EnumizeIrBaseGenerator(private val ctx: EnumizeIrContext) {
irCall(callee, function.returnType).apply {
dispatchReceiver = irGetObjectValue(holder.defaultType, holder.symbol)
setRegularArgument(callee, irGet(valueParameter))
}
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class EnumizeIrContext(val pluginContext: IrPluginContext, val defaultLabelCase:
val holderBaseClass: IrClassSymbol =
pluginContext.referenceClass(EnumizeNames.ENTRIES_HOLDER_BASE_CLASS_ID)
?: error(
"runtime-api class not found on classpath: ${EnumizeNames.ENTRIES_HOLDER_BASE_CLASS_ID}"
"runtime-api class not found on classpath: ${EnumizeNames.ENTRIES_HOLDER_BASE_CLASS_ID}",
)

val holderBaseConstructor =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class EnumizeIrGenerationExtension(private val defaultLabelCase: EnumizeLabelCas
private fun verifyBody(function: IrFunction, modality: Modality, owner: IrClass) {
if (modality == Modality.ABSTRACT || function.body != null) return
error(
"generated declaration was not filled: ${owner.kotlinFqName}.${function.name} (${function.origin})"
"generated declaration was not filled: ${owner.kotlinFqName}.${function.name} (${function.origin})",
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class EnumizeIrLeafGenerator(private val ctx: EnumizeIrContext) {
val argument = (enumizedClassGetter.returnType as? IrSimpleType)?.arguments?.singleOrNull()
return argument?.typeOrNull?.classOrNull?.owner
?: error(
"enumizedClass of ${enumizedClassGetter.parentAsClass.name} does not denote KClass<leaf>"
"enumizedClass of ${enumizedClassGetter.parentAsClass.name} does not denote KClass<leaf>",
)
}

Expand All @@ -117,7 +117,7 @@ class EnumizeIrLeafGenerator(private val ctx: EnumizeIrContext) {
ctx.kClassTypeOf(leafStarType),
leaf.symbol,
leafStarType,
)
),
)
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ class EnumizeIrLeafGenerator(private val ctx: EnumizeIrContext) {
+irReturn(
irCall(labelGetter.symbol, ctx.stringType).apply {
dispatchReceiver = irGet(receiver)
}
},
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ val generateCoordinates =
outputDir
.get()
.file(
"io/github/projectmapk/sealedClassEnumizer/gradle/SealedClassEnumizerCoordinates.kt"
"io/github/projectmapk/sealedClassEnumizer/gradle/SealedClassEnumizerCoordinates.kt",
)
.asFile
file.parentFile.mkdirs()
Expand All @@ -92,7 +92,7 @@ val generateCoordinates =
| const val COMPILER_PLUGIN_ID: String = "$id"
|}
|"""
.trimMargin()
.trimMargin(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SealedClassEnumizerGradlePlugin : KotlinCompilerPluginSupportPlugin {
"sealed-class-enumizer ${SealedClassEnumizerCoordinates.VERSION} targets Kotlin " +
"$supported and is not verified against Kotlin $appliedKotlinVersion applied to " +
"${project.path}. Compilation may fail; use the plugin version matching your " +
"Kotlin version."
"Kotlin version.",
)
}

Expand All @@ -46,7 +46,7 @@ class SealedClassEnumizerGradlePlugin : KotlinCompilerPluginSupportPlugin {
)

override fun applyToCompilation(
kotlinCompilation: KotlinCompilation<*>
kotlinCompilation: KotlinCompilation<*>,
): Provider<List<SubpluginOption>> {
val project = kotlinCompilation.target.project
addRuntimeDependencyIfEnabled(project, kotlinCompilation)
Expand All @@ -59,7 +59,7 @@ class SealedClassEnumizerGradlePlugin : KotlinCompilerPluginSupportPlugin {
SubpluginOption(
key = LABEL_CASE_OPTION_NAME,
value = extension.labelCase.get().name,
)
),
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[versions]
kotlin = "2.4.21"
autoservice = "0.1.5"
ktfmt = "0.27.0"
ktfmt = "0.28.0"
mavenPublish = "0.37.0"
pluginPublish = "2.2.1"
dokka = "2.2.0"
dokka = "2.3.0"

# 以下は単一情報源から導出される版であり、手で選ばない。
# maven は maven-plugin がコンパイル時に参照する Maven API の版で、kotlin-maven-plugin の親 POM の
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BinarySwapTest {
// (inline なら v1 の集合が焼き込まれ差し替えが壊れる)
val mainClass =
dir.resolve(
"consumer/build/classes/kotlin/main/io/github/projectmapk/swapuse/MainKt.class"
"consumer/build/classes/kotlin/main/io/github/projectmapk/swapuse/MainKt.class",
)
val constantPoolText = String(mainClass.readBytes(), Charsets.ISO_8859_1)
assertTrue("getEntries" in constantPoolText, "entries アクセサ呼び出しがメンバー参照のまま残ること")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class IcCompanionTest {
// クラス出力(ファイル単位の帰属を持つもの)だけを dirty 税の判定対象にする
val changed =
IcTestSupport.changedKeys(times0, IcTestSupport.classTimes(dir)).filterTo(
mutableSetOf()
mutableSetOf(),
) {
!it.startsWith("META-INF/")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object IcTestSupport {
Path.of(
requireNotNull(System.getProperty("enumizer.fixtureWorkRoot")) {
"システムプロパティ enumizer.fixtureWorkRoot が未設定(gradle-integration/build.gradle.kts が注入する)"
}
},
)

fun emptyDir(prefix: String): Path {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object TestKitHarness {
requireNotNull(javaClass.classLoader.getResource("fixtures")) {
"src/test/resources/fixtures が見つからない"
}
.toURI()
.toURI(),
)

// フィクスチャ一式を projectDir へ展開し、テキストファイルのプレースホルダを置換する
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class MavenBuildTest {
Failed(
result.succeeded,
result.output.contains(
"'@Enumize' is applicable only to a sealed class or a sealed interface."
"'@Enumize' is applicable only to a sealed class or a sealed interface.",
),
),
result.output,
Expand All @@ -102,7 +102,7 @@ class MavenBuildTest {
result.output.contains(
"Unknown value for the 'sealed-class-enumizer.labelCase' property: " +
"'Upper_Snake'. Expected one of: AS_DECLARED, UPPER_SNAKE_CASE, " +
"SNAKE_CASE, KEBAB_CASE"
"SNAKE_CASE, KEBAB_CASE",
),
),
result.output,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object MavenHarness {
requireNotNull(javaClass.classLoader.getResource("fixtures")) {
"src/test/resources/fixtures が見つからない"
}
.toURI()
.toURI(),
)

private val workDirCounter = AtomicInteger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ sealed interface Cased {
@EnumishLabel("legacy-name") data class Renamed(val v: Int) : Cased

enum class Builtin : Cased {
HELP
HELP,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ sealed interface Zoo {
interface Ghost : Zoo

enum class EnumLeaf : Zoo {
ONE
ONE,
}

@JvmInline value class ValueLeaf(val x: Int) : Zoo
Expand Down
4 changes: 2 additions & 2 deletions maven-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ val generateCoordinates =
outputDir
.get()
.file(
"io/github/projectmapk/sealedClassEnumizer/maven/SealedClassEnumizerCoordinates.kt"
"io/github/projectmapk/sealedClassEnumizer/maven/SealedClassEnumizerCoordinates.kt",
)
.asFile
file.parentFile.mkdirs()
Expand All @@ -68,7 +68,7 @@ val generateCoordinates =
| const val COMPILER_PLUGIN_ID: String = "$compilerPluginId"
|}
|"""
.trimMargin()
.trimMargin(),
)
}
}
Expand Down
Loading
Loading