Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierSegoviaCordoba committed Aug 25, 2024
1 parent 74ecc4b commit 78c3f1a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("ReturnCount")

package com.javiersc.kotlin.kopy.compiler.fir.checker.checkers

import com.javiersc.kotlin.compiler.extensions.common.classId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("ReturnCount")

package com.javiersc.kotlin.kopy.compiler.fir.generation

import com.javiersc.kotlin.compiler.extensions.common.classId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("ReturnCount")

package com.javiersc.kotlin.kopy.compiler.fir.generation

import com.javiersc.kotlin.compiler.extensions.common.classId
Expand Down Expand Up @@ -66,10 +68,10 @@ internal class FirKopyDeclarationGenerationExtension(
) : FirDeclarationGenerationExtension(session) {

private val kopyVisibility: KopyVisibility
get() = configuration.get(KopyKey.Visibility, KopyVisibility.Auto)
get() = configuration[KopyKey.Visibility, KopyVisibility.Auto]

private val kopyFunctions: KopyFunctions
get() = configuration.get(KopyKey.Functions, KopyFunctions.All)
get() = configuration[KopyKey.Functions, KopyFunctions.All]

private val kopyOptInClassId: ClassId = "com.javiersc.kotlin.kopy.KopyOptIn".toClassId()
private val kopyFunctionCopyClassId: ClassId = classId<KopyFunctionCopy>()
Expand Down Expand Up @@ -430,6 +432,7 @@ internal class FirKopyDeclarationGenerationExtension(
private fun KopyVisibility.isMoreRestrictedThan(visibility: Visibility): Boolean =
this.restrictive > visibility.restrictive

@Suppress("MagicNumber")
private val Visibility.restrictive: Int
get() = when (this) {
Visibilities.Public -> 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ internal class IrFunctionsTransformer(
private val pluginContext: IrPluginContext,
) : IrElementTransformerVoidWithContext() {

private val kopyOptInClassId: ClassId = "com.javiersc.kotlin.kopy.KopyOptIn".toClassId()
private val kopyFunctionCopyClassId: ClassId = classId<KopyFunctionCopy>()
private val kopyFunctionInvokeClassId: ClassId = classId<KopyFunctionInvoke>()
private val kopyFunctionSetClassId: ClassId = classId<KopyFunctionSet>()
private val kopyFunctionUpdateClassId: ClassId = classId<KopyFunctionUpdate>()
private val kopyFunctionUpdateEachClassId: ClassId = classId<KopyFunctionUpdateEach>()
private val atomicRefClassId: ClassId = "kotlinx.atomicfu.AtomicRef".toClassId()
// private val kopyOptInClassId: ClassId = "com.javiersc.kotlin.kopy.KopyOptIn".toClassId()
// private val kopyFunctionCopyClassId: ClassId = classId<KopyFunctionCopy>()
// private val kopyFunctionInvokeClassId: ClassId = classId<KopyFunctionInvoke>()
// private val kopyFunctionSetClassId: ClassId = classId<KopyFunctionSet>()
// private val kopyFunctionUpdateClassId: ClassId = classId<KopyFunctionUpdate>()
// private val kopyFunctionUpdateEachClassId: ClassId = classId<KopyFunctionUpdateEach>()
// private val atomicRefClassId: ClassId = "kotlinx.atomicfu.AtomicRef".toClassId()
private val atomicName: Name = "_atomic".toName()
private val valueName: Name = "value".toName()
private val copyName: Name = "copy".toName()
private val invokeName: Name = "invoke".toName()
private val setName: Name = "set".toName()
private val updateName: Name = "update".toName()
private val updateEachName: Name = "updateEach".toName()
// private val setName: Name = "set".toName()
// private val updateName: Name = "update".toName()
// private val updateEachName: Name = "updateEach".toName()

private val unitType: IrType = pluginContext.irBuiltIns.unitType

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("ReturnCount")

package com.javiersc.kotlin.kopy.compiler.ir.transformers

import com.javiersc.kotlin.compiler.extensions.common.classId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ internal val IrElement.isKopyCopy: Boolean
internal val IrElement.isKopyCopyOrInvoke: Boolean
get() = isKopyCopy || isKopyInvoke

internal val IrCall.isKopyInvoke: Boolean
get() = hasAnnotation(fqName<KopyFunctionInvoke>())

internal val IrSimpleFunction.isKopyInvokeOrKopy: Boolean
get() = hasAnnotation(fqName<KopyFunctionInvoke>()) || hasAnnotation(fqName<KopyFunctionCopy>())

internal val IrSimpleFunction.isKopySet: Boolean
get() = hasAnnotation(fqName<KopyFunctionSet>())

Expand All @@ -42,10 +36,7 @@ internal val IrCall.isKopyUpdate: Boolean
get() = hasAnnotation(fqName<KopyFunctionUpdate>())

internal val IrCall.isKopySetOrUpdate: Boolean
get() = hasAnnotation(fqName<KopyFunctionSet>()) || hasAnnotation(fqName<KopyFunctionUpdate>())

internal val IrSimpleFunction.isKopySetOrUpdate: Boolean
get() = hasAnnotation(fqName<KopyFunctionSet>()) || hasAnnotation(fqName<KopyFunctionUpdate>())
get() = isKopySet || isKopyUpdate

internal val IrCall.isKopyUpdateEach: Boolean
get() = hasAnnotation(fqName<KopyFunctionUpdateEach>())

0 comments on commit 78c3f1a

Please sign in to comment.