Skip to content

Commit

Permalink
Minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Nov 30, 2023
1 parent 1f94c7e commit cd89d3d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/main/kotlin/org/openrewrite/kotlin/KotlinTypeMapping.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef
import org.jetbrains.kotlin.load.java.structure.*
import org.jetbrains.kotlin.load.java.structure.impl.classFiles.*
import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.types.ConstantValueKind
import org.jetbrains.kotlin.types.Variance
import org.openrewrite.java.JavaTypeMapping
Expand All @@ -56,7 +57,6 @@ import org.openrewrite.java.tree.JavaType
import org.openrewrite.java.tree.JavaType.*
import org.openrewrite.java.tree.TypeUtils
import org.openrewrite.kotlin.KotlinTypeSignatureBuilder.Companion.convertClassIdToFqn
import org.openrewrite.kotlin.KotlinTypeSignatureBuilder.Companion.convertKotlinFqToJavaFq
import kotlin.collections.ArrayList

@Suppress("DuplicatedCode")
Expand Down Expand Up @@ -706,9 +706,9 @@ class KotlinTypeMapping(
val source: JvmPackagePartSource? = resolvedSymbol.fir.containerSource as JvmPackagePartSource?
if (source != null) {
declaringType = if (source.facadeClassName != null) {
createShallowClass(convertKotlinFqToJavaFq(source.facadeClassName.toString()))
createShallowClass((source.facadeClassName as JvmClassName).fqNameForTopLevelClassMaybeWithDollars.asString())
} else {
createShallowClass(convertKotlinFqToJavaFq(source.className.toString()))
createShallowClass(source.className.fqNameForTopLevelClassMaybeWithDollars.asString())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import org.jetbrains.kotlin.load.java.structure.impl.classFiles.BinaryJavaTypePa
import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.types.Variance
import org.openrewrite.java.JavaTypeSignatureBuilder
import org.openrewrite.java.tree.JavaType
Expand Down Expand Up @@ -369,9 +370,9 @@ class KotlinTypeSignatureBuilder(private val firSession: FirSession, private val
val source: JvmPackagePartSource? = resolvedSymbol.fir.containerSource as JvmPackagePartSource?
if (source != null) {
declaringSig = if (source.facadeClassName != null) {
convertKotlinFqToJavaFq(source.facadeClassName.toString())
(source.facadeClassName as JvmClassName).fqNameForTopLevelClassMaybeWithDollars.asString()
} else {
convertKotlinFqToJavaFq(source.className.toString())
source.className.fqNameForTopLevelClassMaybeWithDollars.asString()
}
}
}
Expand Down Expand Up @@ -684,7 +685,7 @@ class KotlinTypeSignatureBuilder(private val firSession: FirSession, private val
.replace(".", "$")
.replace("/", ".")
.replace("?", "")
return if (cleanedFqn.startsWith(".")) cleanedFqn.replaceFirst(".".toRegex(), "") else cleanedFqn
return if (cleanedFqn.startsWith(".")) cleanedFqn.substring(1) else cleanedFqn
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import static java.util.Collections.singletonList;
import static java.util.Objects.requireNonNull;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.in;
import static org.openrewrite.ExecutionContext.REQUIRE_PRINT_EQUALS_INPUT;
import static org.openrewrite.java.tree.JavaType.GenericTypeVariable.Variance.*;
import static org.openrewrite.kotlin.Assertions.kotlin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void methodReference() {
@Test
void getJavaClass() {
rewriteRun(
kotlin("val a = Integer :: class . java ")
kotlin("val a = Int :: class . java ")
);
}

Expand Down

0 comments on commit cd89d3d

Please sign in to comment.