Introduce COMPONENT_FUNCTION_NAME_PREFIX constant
This commit is contained in:
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.backend
|
||||
|
||||
import com.intellij.psi.PsiCompiledElement
|
||||
import org.jetbrains.kotlin.*
|
||||
import org.jetbrains.kotlin.builtins.StandardNames.DATA_CLASS_COMPONENT_PREFIX
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.builder.buildPackageDirective
|
||||
@@ -510,7 +511,7 @@ internal fun FirReference.statementOrigin(): IrStatementOrigin? {
|
||||
source?.elementType == KtNodeTypes.OPERATION_REFERENCE ->
|
||||
nameToOperationConventionOrigin[symbol.callableId.callableName]
|
||||
source?.kind is KtFakeSourceElementKind.DesugaredComponentFunctionCall ->
|
||||
IrStatementOrigin.COMPONENT_N.withIndex(name.asString().removePrefix("component").toInt())
|
||||
IrStatementOrigin.COMPONENT_N.withIndex(name.asString().removePrefix(DATA_CLASS_COMPONENT_PREFIX).toInt())
|
||||
else ->
|
||||
null
|
||||
}
|
||||
|
||||
@@ -5,20 +5,19 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import org.jetbrains.kotlin.builtins.StandardNames.DATA_CLASS_COMPONENT_PREFIX
|
||||
import org.jetbrains.kotlin.builtins.StandardNames.DATA_CLASS_COPY
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
object DataClassResolver {
|
||||
private const val COMPONENT_FUNCTION_NAME_PREFIX = "component"
|
||||
fun createComponentName(index: Int): Name = Name.identifier(DATA_CLASS_COMPONENT_PREFIX + index)
|
||||
|
||||
fun createComponentName(index: Int): Name = Name.identifier(COMPONENT_FUNCTION_NAME_PREFIX + index)
|
||||
|
||||
fun getComponentIndex(componentName: String): Int = componentName.substring(COMPONENT_FUNCTION_NAME_PREFIX.length).toInt()
|
||||
fun getComponentIndex(componentName: String): Int = componentName.substring(DATA_CLASS_COMPONENT_PREFIX.length).toInt()
|
||||
|
||||
fun isComponentLike(name: Name): Boolean = isComponentLike(name.asString())
|
||||
|
||||
private fun isComponentLike(name: String): Boolean {
|
||||
if (!name.startsWith(COMPONENT_FUNCTION_NAME_PREFIX)) return false
|
||||
if (!name.startsWith(DATA_CLASS_COMPONENT_PREFIX)) return false
|
||||
|
||||
try {
|
||||
getComponentIndex(name)
|
||||
|
||||
@@ -26,6 +26,8 @@ object StandardNames {
|
||||
|
||||
@JvmField val DATA_CLASS_COPY = Name.identifier("copy")
|
||||
|
||||
@JvmField val DATA_CLASS_COMPONENT_PREFIX = "component"
|
||||
|
||||
@JvmField val HASHCODE_NAME = Name.identifier("hashCode")
|
||||
|
||||
@JvmField val CHAR_CODE = Name.identifier("code")
|
||||
|
||||
Reference in New Issue
Block a user