Skip to content

Commit 8ae9414

Browse files
authored
KRPC-167 Internal symbols are the first completion candidate in projects where kxrpc is configured (#305)
1 parent ddeab6f commit 8ae9414

File tree

51 files changed

+258
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+258
-257
lines changed

compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcIrContext.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ internal class RpcIrContext(
169169
}
170170

171171
val dataCast by lazy {
172-
namedFunction("kotlinx.rpc.internal", "dataCast")
172+
namedFunction("kotlinx.rpc.internal", "rpcInternalDataCast")
173173
}
174174

175175
val rpcClientCall by lazy {

core/src/commonMain/kotlin/kotlinx/rpc/descriptor/RpcServiceDescriptor.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ public inline fun <@Rpc reified T : Any> serviceDescriptorOf(): RpcServiceDescri
1919

2020
@ExperimentalRpcApi
2121
public fun <@Rpc T : Any> serviceDescriptorOf(kType: KType): RpcServiceDescriptor<T> {
22-
return serviceDescriptorOf(kType.kClass())
22+
return serviceDescriptorOf(kType.rpcInternalKClass())
2323
}
2424

2525
@ExperimentalRpcApi
2626
public fun <@Rpc T : Any> serviceDescriptorOf(kClass: KClass<T>): RpcServiceDescriptor<T> {
2727
val maybeDescriptor = internalServiceDescriptorOf(kClass)
28-
?: internalError("Unable to find a service descriptor of the $kClass")
28+
?: internalRpcError("Unable to find a service descriptor of the $kClass")
2929

3030
if (maybeDescriptor is RpcServiceDescriptor<*>) {
3131
@Suppress("UNCHECKED_CAST")
3232
return maybeDescriptor as RpcServiceDescriptor<T>
3333
}
3434

35-
internalError(
35+
internalRpcError(
3636
"Located descriptor object is not of a desired type ${RpcServiceDescriptor::class}, " +
3737
"instead found $maybeDescriptor of the class " +
38-
(maybeDescriptor::class.qualifiedClassNameOrNull ?: maybeDescriptor::class)
38+
(maybeDescriptor::class.rpcInternalQualifiedClassNameOrNull ?: maybeDescriptor::class)
3939
)
4040
}
4141

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.rpc.internal
@@ -10,24 +10,24 @@ import kotlin.reflect.KType
1010

1111
@InternalRpcApi
1212
@Suppress("UNCHECKED_CAST")
13-
public fun <T : Any> KType.kClass(): KClass<T> {
13+
public fun <T : Any> KType.rpcInternalKClass(): KClass<T> {
1414
val classifier = classifier ?: error("Expected denotable type, found $this")
1515
val classifierClass = classifier as? KClass<*> ?: error("Expected class type, found $this")
1616

1717
return classifierClass as KClass<T>
1818
}
1919

2020
@InternalRpcApi
21-
public fun internalError(message: String): Nothing {
21+
public fun internalRpcError(message: String): Nothing {
2222
error("Internal kotlinx.rpc error: $message")
2323
}
2424

2525
@InternalRpcApi
26-
public expect val KClass<*>.typeName: String?
26+
public expect val KClass<*>.rpcInternalTypeName: String?
2727

2828
@InternalRpcApi
29-
public expect val KClass<*>.qualifiedClassNameOrNull: String?
29+
public expect val KClass<*>.rpcInternalQualifiedClassNameOrNull: String?
3030

3131
@InternalRpcApi
32-
public val KClass<*>.qualifiedClassName: String get() = qualifiedClassNameOrNull
32+
public val KClass<*>.rpcInternalQualifiedClassName: String get() = rpcInternalQualifiedClassNameOrNull
3333
?: error("Expected qualifiedClassName for $this")

core/src/commonMain/kotlin/kotlinx/rpc/internal/dataCast.kt renamed to core/src/commonMain/kotlin/kotlinx/rpc/internal/rpcInternalDataCast.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.rpc.internal
66

77
import kotlinx.rpc.internal.utils.InternalRpcApi
88

99
@InternalRpcApi
10-
public inline fun <reified T> Any?.dataCast(methodName: String, serviceName: String): T {
10+
public inline fun <reified T> Any?.rpcInternalDataCast(methodName: String, serviceName: String): T {
1111
return this as? T
1212
?: throw IllegalArgumentException(
1313
"Wrong data type for $methodName in service $serviceName. " +

core/src/commonMain/kotlin/kotlinx/rpc/withService.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.rpc
66

77
import kotlinx.atomicfu.atomic
88
import kotlinx.rpc.annotations.Rpc
99
import kotlinx.rpc.descriptor.serviceDescriptorOf
10-
import kotlinx.rpc.internal.kClass
10+
import kotlinx.rpc.internal.rpcInternalKClass
1111
import kotlin.reflect.KClass
1212
import kotlin.reflect.KType
1313

@@ -33,7 +33,7 @@ public inline fun <@Rpc reified T : Any> RpcClient.withService(): T {
3333
* @return instance of the generated service.
3434
*/
3535
public fun <@Rpc T : Any> RpcClient.withService(serviceKType: KType): T {
36-
return withService(serviceKType.kClass())
36+
return withService(serviceKType.rpcInternalKClass())
3737
}
3838

3939
/**
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
@file:Suppress("detekt.MatchingDeclarationName")
@@ -10,9 +10,9 @@ import kotlinx.rpc.internal.utils.InternalRpcApi
1010
import kotlin.reflect.KClass
1111

1212
@InternalRpcApi
13-
public actual val KClass<*>.qualifiedClassNameOrNull: String?
13+
public actual val KClass<*>.rpcInternalQualifiedClassNameOrNull: String?
1414
get() = toString()
1515

1616
@InternalRpcApi
17-
public actual val KClass<*>.typeName: String?
18-
get() = qualifiedClassNameOrNull
17+
public actual val KClass<*>.rpcInternalTypeName: String?
18+
get() = rpcInternalQualifiedClassNameOrNull
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
@file:Suppress("detekt.MatchingDeclarationName")
@@ -10,9 +10,9 @@ import kotlinx.rpc.internal.utils.InternalRpcApi
1010
import kotlin.reflect.KClass
1111

1212
@InternalRpcApi
13-
public actual val KClass<*>.qualifiedClassNameOrNull: String?
13+
public actual val KClass<*>.rpcInternalQualifiedClassNameOrNull: String?
1414
get() = qualifiedName
1515

1616
@InternalRpcApi
17-
public actual val KClass<*>.typeName: String?
17+
public actual val KClass<*>.rpcInternalTypeName: String?
1818
get() = java.typeName
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
@file:Suppress("detekt.MatchingDeclarationName")
@@ -10,9 +10,9 @@ import kotlinx.rpc.internal.utils.InternalRpcApi
1010
import kotlin.reflect.KClass
1111

1212
@InternalRpcApi
13-
public actual val KClass<*>.qualifiedClassNameOrNull: String?
13+
public actual val KClass<*>.rpcInternalQualifiedClassNameOrNull: String?
1414
get() = qualifiedName
1515

1616
@InternalRpcApi
17-
public actual val KClass<*>.typeName: String?
18-
get() = qualifiedClassNameOrNull
17+
public actual val KClass<*>.rpcInternalTypeName: String?
18+
get() = rpcInternalQualifiedClassNameOrNull
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
@file:Suppress("detekt.MatchingDeclarationName")
@@ -10,9 +10,9 @@ import kotlinx.rpc.internal.utils.InternalRpcApi
1010
import kotlin.reflect.KClass
1111

1212
@InternalRpcApi
13-
public actual val KClass<*>.qualifiedClassNameOrNull: String?
13+
public actual val KClass<*>.rpcInternalQualifiedClassNameOrNull: String?
1414
get() = toString()
1515

1616
@InternalRpcApi
17-
public actual val KClass<*>.typeName: String?
18-
get() = qualifiedClassNameOrNull
17+
public actual val KClass<*>.rpcInternalTypeName: String?
18+
get() = rpcInternalQualifiedClassNameOrNull
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
@file:Suppress("detekt.MatchingDeclarationName")
@@ -10,9 +10,9 @@ import kotlinx.rpc.internal.utils.InternalRpcApi
1010
import kotlin.reflect.KClass
1111

1212
@InternalRpcApi
13-
public actual val KClass<*>.qualifiedClassNameOrNull: String?
13+
public actual val KClass<*>.rpcInternalQualifiedClassNameOrNull: String?
1414
get() = toString()
1515

1616
@InternalRpcApi
17-
public actual val KClass<*>.typeName: String?
18-
get() = qualifiedClassNameOrNull
17+
public actual val KClass<*>.rpcInternalTypeName: String?
18+
get() = rpcInternalQualifiedClassNameOrNull

0 commit comments

Comments
 (0)