File tree Expand file tree Collapse file tree 7 files changed +23
-20
lines changed
src/main/java/com/bennyhuo/kotlin/trimindent/compiler Expand file tree Collapse file tree 7 files changed +23
-20
lines changed Original file line number Diff line number Diff line change 11plugins {
2- kotlin(" jvm" ) version " 2.1.20 " apply false
2+ kotlin(" jvm" ) version " 2.2.0 " apply false
33 id(" org.jetbrains.dokka" ) version " 1.7.10" apply false
44 id(" com.github.gmazzo.buildconfig" ) version " 2.1.0" apply false
5- id(" com.vanniktech.maven.publish" ) version " 0.22 .0" apply false
5+ id(" com.vanniktech.maven.publish" ) version " 0.31 .0" apply false
66}
77
88subprojects {
Original file line number Diff line number Diff line change 11kotlin.code.style =official
22
3- VERSION_NAME =2.1.20 -1.1.0
3+ VERSION_NAME =2.2.0 -1.1.0
44
55GROUP =com.bennyhuo.kotlin
66
@@ -23,6 +23,6 @@ POM_DEVELOPER_URL=https://github.com/bennyhuo/
2323
2424KOTLIN_PLUGIN_ID =com.bennyhuo.kotlin.trimindent
2525
26- SONATYPE_HOST =S01
26+ SONATYPE_HOST =CENTRAL_PORTAL
2727SONATYPE_AUTOMATIC_RELEASE =true
2828RELEASE_SIGNING_ENABLED =true
Original file line number Diff line number Diff line change 11[versions ]
2- kotlin = " 2.1.21 "
2+ kotlin = " 2.2.0 "
33
44[libraries ]
55
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ dependencies {
1515 compileOnly(" com.google.auto.service:auto-service-annotations:1.0.1" )
1616
1717 testImplementation(kotlin(" test-junit" ))
18- testImplementation(" com.bennyhuo.kotlin:kotlin-compile-testing-extensions:2.1 .0-1.3.0" )
18+ testImplementation(" com.bennyhuo.kotlin:kotlin-compile-testing-extensions:2.2 .0-1.3.0" )
1919}
2020
2121kotlin {
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ import org.jetbrains.kotlin.name.FqName
1616import org.jetbrains.kotlin.name.Name
1717import kotlin.contracts.ExperimentalContracts
1818import kotlin.contracts.contract
19+ import org.jetbrains.kotlin.DeprecatedForRemovalCompilerApi
20+ import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
1921import org.jetbrains.kotlin.name.CallableId
2022
2123/* *
@@ -31,15 +33,17 @@ fun IrStringConcatenation.copyWithNewValues(
3133}
3234
3335internal fun IrCall.isTrimIndent (): Boolean {
34- return symbol.owner.name == Name .identifier(" trimIndent" )
35- && dispatchReceiver == null
36- && extensionReceiver?.type?.classFqName?.asString() == " kotlin.String"
37- && symbol.owner.getPackageFragment().packageFqName.asString() == " kotlin.text"
36+ return symbol.owner.let {
37+ it.name == Name .identifier(" trimIndent" )
38+ && it.parameters.firstOrNull()?.type?.classFqName?.asString() == " kotlin.String"
39+ && it.getPackageFragment().packageFqName.asString() == " kotlin.text"
40+ }
41+
3842}
3943
4044fun IrPluginContext.prependIndent (): IrFunction {
4145 return referenceFunctions(CallableId (FqName (" kotlin.text" ), Name .identifier(" prependIndent" )))
4246 .singleOrNull {
43- it.owner.extensionReceiverParameter ?.type?.classFqName?.asString() == " kotlin.String"
47+ it.owner.parameters.firstOrNull() ?.type?.classFqName?.asString() == " kotlin.String"
4448 }?.owner!!
4549}
Original file line number Diff line number Diff line change 11package com.bennyhuo.kotlin.trimindent.compiler
22
3+ import org.jetbrains.kotlin.DeprecatedForRemovalCompilerApi
34import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
45import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
56import org.jetbrains.kotlin.ir.expressions.IrConst
@@ -44,14 +45,12 @@ class IrExpressionElement(val irExpression: IrExpression) : IrStringElement {
4445 preIndentFunction.symbol as IrSimpleFunctionSymbol ,
4546 0
4647 ).apply {
47- extensionReceiver = irExpression
48- putValueArgument(
49- 0 , IrConstImpl .string(
50- irExpression.startOffset,
51- irExpression.endOffset,
52- pluginContext.irBuiltIns.stringType,
53- indent
54- )
48+ arguments[0 ] = irExpression
49+ arguments[1 ] = IrConstImpl .string(
50+ irExpression.startOffset,
51+ irExpression.endOffset,
52+ pluginContext.irBuiltIns.stringType,
53+ indent
5554 )
5655 }
5756
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ class TrimIndentIrGenerator : IrGenerationExtension {
1818 moduleFragment.transformChildrenVoid(object : IrElementTransformerVoid () {
1919 override fun visitCall (irCall : IrCall ): IrExpression {
2020 if (irCall.isTrimIndent()) {
21- val extensionReceiver = irCall.extensionReceiver !!
21+ val extensionReceiver = irCall.arguments.first()
2222 if (extensionReceiver is IrConst && extensionReceiver.kind == IrConstKind .String ) {
2323 val value = extensionReceiver.value as String
2424 return super .visitExpression(extensionReceiver.copyWithNewValue(value.trimIndent()))
You can’t perform that action at this time.
0 commit comments