Skip to content

Commit a21a5cc

Browse files
authored
Api naming (#236)
1 parent 41d4a86 commit a21a5cc

File tree

167 files changed

+1464
-1146
lines changed

Some content is hidden

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

167 files changed

+1464
-1146
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ A few things to remember:
102102
* Every public API (including functions, classes, objects and so on) should be documented,
103103
every parameter, property, return types and exceptions should be described properly.
104104
* A Public API that is not intended to be used by end-users that couldn't be made private/internal due to technical reasons,
105-
should be marked with `@InternalRPCApi` annotation.
105+
should be marked with `@InternalRpcApi` annotation.
106106

107107
### Commit messages
108108

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Then, choose how do you want your service to communicate. For example, you can u
4444
```kotlin
4545
fun main() {
4646
embeddedServer(Netty, 8080) {
47-
install(RPC)
47+
install(Krpc)
4848
routing {
4949
rpc("/awesome") {
5050
rpcConfig {
@@ -61,7 +61,7 @@ fun main() {
6161
```
6262
To connect to the server use the following [Ktor Client](https://ktor.io/docs/create-client.html) setup:
6363
```kotlin
64-
val rpcClient = HttpClient { installRPC() }.rpc {
64+
val rpcClient = HttpClient { installKrpc() }.rpc {
6565
url("ws://localhost:8080/awesome")
6666

6767
rpcConfig {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import org.jetbrains.kotlin.ir.util.dumpKotlinLike
1616

1717
/**
1818
* This class scans user declared RPC service
19-
* and returns all necessary information for code generation by [RPCStubGenerator].
19+
* and returns all necessary information for code generation by [RpcStubGenerator].
2020
*
2121
* Some checks are preformed during scanning,
2222
* but all user-friendly errors are expected to be thrown by frontend plugins
2323
*/
24-
internal object RPCDeclarationScanner {
25-
fun scanServiceDeclaration(service: IrClass, ctx: RPCIrContext, logger: MessageCollector): ServiceDeclaration {
24+
internal object RpcDeclarationScanner {
25+
fun scanServiceDeclaration(service: IrClass, ctx: RpcIrContext, logger: MessageCollector): ServiceDeclaration {
2626
var stubClass: IrClass? = null
2727

2828
val declarations = service.declarations.memoryOptimizedMap { declaration ->
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.ir.util.properties
1919
import org.jetbrains.kotlin.platform.konan.isNative
2020
import org.jetbrains.kotlin.types.Variance
2121

22-
internal class RPCIrContext(
22+
internal class RpcIrContext(
2323
val pluginContext: IrPluginContext,
2424
val versionSpecificApi: VersionSpecificApi,
2525
) {
@@ -98,7 +98,7 @@ internal class RPCIrContext(
9898
}
9999

100100
val rpcEagerFieldAnnotation by lazy {
101-
getRpcIrClassSymbol("RPCEagerField")
101+
getRpcIrClassSymbol("RpcEagerField")
102102
}
103103

104104
val rpcServiceDescriptor by lazy {
@@ -200,7 +200,7 @@ internal class RPCIrContext(
200200

201201
val lazyGetValue by lazy {
202202
namedFunction("kotlin", "getValue") {
203-
it.owner.extensionReceiverParameter?.type?.classOrNull == this@RPCIrContext.lazy
203+
it.owner.extensionReceiverParameter?.type?.classOrNull == this@RpcIrContext.lazy
204204
}
205205
}
206206

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector
1111
import org.jetbrains.kotlin.config.CompilerConfiguration
1212
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
1313

14-
class RPCIrExtension(configuration: CompilerConfiguration) : IrGenerationExtension {
14+
class RpcIrExtension(configuration: CompilerConfiguration) : IrGenerationExtension {
1515
private val logger = configuration.get(VersionSpecificApi.INSTANCE.messageCollectorKey, MessageCollector.NONE)
1616

1717
override fun generate(
1818
moduleFragment: IrModuleFragment,
1919
pluginContext: IrPluginContext,
2020
) {
21-
val context = RPCIrContext(pluginContext, VersionSpecificApi.INSTANCE)
21+
val context = RpcIrContext(pluginContext, VersionSpecificApi.INSTANCE)
2222

23-
val processor = RPCIrServiceProcessor(logger)
23+
val processor = RpcIrServiceProcessor(logger)
2424
moduleFragment.transform(processor, context)
2525
}
2626
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ import org.jetbrains.kotlin.ir.declarations.IrClass
1111
import org.jetbrains.kotlin.ir.util.hasAnnotation
1212
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
1313

14-
internal class RPCIrServiceProcessor(
14+
internal class RpcIrServiceProcessor(
1515
@Suppress("unused")
1616
private val logger: MessageCollector,
17-
) : IrElementTransformer<RPCIrContext> {
18-
override fun visitClass(declaration: IrClass, data: RPCIrContext): IrStatement {
17+
) : IrElementTransformer<RpcIrContext> {
18+
override fun visitClass(declaration: IrClass, data: RpcIrContext): IrStatement {
1919
if (declaration.hasAnnotation(RpcClassId.rpcAnnotation)) {
2020
processService(declaration, data)
2121
}
2222

2323
return super.visitClass(declaration, data)
2424
}
2525

26-
private fun processService(service: IrClass, context: RPCIrContext) {
27-
val declaration = RPCDeclarationScanner.scanServiceDeclaration(service, context, logger)
28-
RPCStubGenerator(declaration, context, logger).generate()
26+
private fun processService(service: IrClass, context: RpcIrContext) {
27+
val declaration = RpcDeclarationScanner.scanServiceDeclaration(service, context, logger)
28+
RpcStubGenerator(declaration, context, logger).generate()
2929
}
3030
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ private object Descriptor {
4545
}
4646

4747
@Suppress("detekt.LargeClass", "detekt.TooManyFunctions")
48-
internal class RPCStubGenerator(
48+
internal class RpcStubGenerator(
4949
private val declaration: ServiceDeclaration,
50-
private val ctx: RPCIrContext,
50+
private val ctx: RpcIrContext,
5151
@Suppress("unused")
5252
private val logger: MessageCollector,
5353
) {
@@ -253,7 +253,7 @@ internal class RPCStubGenerator(
253253

254254
/**
255255
* RPC fields.
256-
* Can be of two kinds: Lazy and Eager (defined by `@RPCEagerField` annotation)
256+
* Can be of two kinds: Lazy and Eager (defined by `@RpcEagerField` annotation)
257257
*
258258
* Lazy:
259259
* ``` kotlin
@@ -623,15 +623,15 @@ internal class RPCStubGenerator(
623623
* ```
624624
*
625625
* This method generates missing getters and backing fields' values.
626-
* And adds RPCMethodClassArguments supertype with `asArray` method implemented.
626+
* And adds RpcMethodClassArguments supertype with `asArray` method implemented.
627627
*
628628
* Resulting class:
629629
* ```kotlin
630630
* @Serializable
631631
* class hello$rpcMethod(
632632
* val arg1: String,
633633
* val arg2: Int,
634-
* ) : RPCMethodClassArguments {
634+
* ) : RpcMethodClassArguments {
635635
* // or emptyArray when no arguments
636636
* override fun asArray(): Array<Any?> = arrayOf(arg1, arg2)
637637
* }

compiler-plugin/compiler-plugin-cli/src/main-resources/latest/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
#
44

5-
kotlinx.rpc.codegen.RPCCommandLineProcessor
5+
kotlinx.rpc.codegen.RpcCommandLineProcessor

compiler-plugin/compiler-plugin-cli/src/main-resources/latest/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
#
44

5-
kotlinx.rpc.codegen.RPCCompilerPlugin
5+
kotlinx.rpc.codegen.RpcCompilerPlugin
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
package kotlinx.rpc.codegen
66

7-
import kotlinx.rpc.codegen.extension.RPCIrExtension
7+
import kotlinx.rpc.codegen.extension.RpcIrExtension
88
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
99
import org.jetbrains.kotlin.compiler.plugin.CliOption
1010
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
@@ -14,14 +14,14 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
1414
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarAdapter
1515

1616
@OptIn(ExperimentalCompilerApi::class)
17-
class RPCCommandLineProcessor : CommandLineProcessor {
17+
class RpcCommandLineProcessor : CommandLineProcessor {
1818
override val pluginId = "kotlinx.rpc.compiler-plugin"
1919

2020
override val pluginOptions = emptyList<CliOption>()
2121
}
2222

2323
@OptIn(ExperimentalCompilerApi::class)
24-
class RPCCompilerPlugin : CompilerPluginRegistrar() {
24+
class RpcCompilerPlugin : CompilerPluginRegistrar() {
2525
override val supportsK2: Boolean = true
2626

2727
override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
@@ -33,6 +33,6 @@ class RPCCompilerPlugin : CompilerPluginRegistrar() {
3333
fun CompilerPluginRegistrar.ExtensionStorage.registerRpcExtensions(configuration: CompilerConfiguration) {
3434
VersionSpecificApi.INSTANCE = VersionSpecificApiImpl
3535

36-
IrGenerationExtension.registerExtension(RPCIrExtension(configuration))
36+
IrGenerationExtension.registerExtension(RpcIrExtension(configuration))
3737
FirExtensionRegistrarAdapter.registerExtension(FirRpcExtensionRegistrar(configuration))
3838
}

0 commit comments

Comments
 (0)