Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master' into KT-642…
Browse files Browse the repository at this point in the history
…00/maven-jvm-test-suite
  • Loading branch information
adam-enko committed Jun 18, 2024
2 parents dd8fa25 + 09437c3 commit 5b12e28
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@file:Suppress("unused")

import org.w3c.dom.HTMLAnchorElement
import kotlinx.coroutines.CoroutineScope

/**
Expand All @@ -16,9 +15,6 @@ fun test(list: MutableList<Int>) = "list"
@JsNonModule
external fun <T> sorted(a: Array<T>): Boolean

// this declaration can be used to check deserialization of dynamic type
external interface TextLinkProps: AnchorHTMLAttributes<HTMLAnchorElement>

// this declaration uses external library and external documentation link
fun CoroutineScope.externalClass() = "some string"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@file:Suppress("unused")

import org.w3c.dom.HTMLAnchorElement
import kotlinx.coroutines.CoroutineScope

/**
Expand All @@ -16,9 +15,6 @@ fun test(list: MutableList<Int>) = "list"
@JsNonModule
external fun <T> sorted(a: Array<T>): Boolean

// this declaration can be used to check deserialization of dynamic type
external interface TextLinkProps: AnchorHTMLAttributes<HTMLAnchorElement>

// this declaration uses external library and external documentation link
fun CoroutineScope.externalClass() = "some string"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ internal class WasmTestedVersionsArgumentsProvider : AllSupportedTestedVersionsA

class WasmGradleIntegrationTest : AbstractGradleIntegrationTest() {

@OnlyDescriptors
@ParameterizedTest(name = "{0}")
@ArgumentsSource(WasmTestedVersionsArgumentsProvider::class)
fun execute(buildVersions: BuildVersions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ internal class WasmJsWasiTestedVersionsArgumentsProvider : AllSupportedTestedVer

class WasmJsWasiGradleIntegrationTest : AbstractGradleIntegrationTest() {

@OnlyDescriptors
@ParameterizedTest(name = "{0}")
@ArgumentsSource(WasmJsWasiTestedVersionsArgumentsProvider::class)
fun execute(buildVersions: BuildVersions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ internal class DokkaPsiParser(
*/
fun Array<PsiClassType>.getSuperTypesPsiClasses(): List<Pair<PsiClass, JavaClassKindTypes>> {
forEach { type ->
(type as? PsiClassType)?.resolve()?.let {
type.resolve()?.let {
val definedAt = DRI.from(it)
it.methods.forEach { method ->
val hash = method.hash
Expand Down Expand Up @@ -588,7 +588,7 @@ internal class DokkaPsiParser(
type.isExtends -> Covariance(getBound(type.extendsBound))
type.isSuper -> Contravariance(getBound(type.superBound))
// If the type isn't explicitly bounded, it still has an implicit `extends Object` bound
type.extendsBound != PsiType.NULL -> Covariance(getBound(type.extendsBound))
type.extendsBound != PsiTypes.nullType() -> Covariance(getBound(type.extendsBound))
else -> throw IllegalStateException("${type.presentableText} has incorrect bounds")
}

Expand Down Expand Up @@ -782,12 +782,12 @@ internal class DokkaPsiParser(
}

private fun PsiLiteralExpression.toValue(): AnnotationParameterValue? = when (type) {
PsiType.INT -> (value as? Int)?.let { IntValue(it) }
PsiType.LONG -> (value as? Long)?.let { LongValue(it) }
PsiType.FLOAT -> (value as? Float)?.let { FloatValue(it) }
PsiType.DOUBLE -> (value as? Double)?.let { DoubleValue(it) }
PsiType.BOOLEAN -> (value as? Boolean)?.let { BooleanValue(it) }
PsiType.NULL -> NullValue
PsiTypes.intType() -> (value as? Int)?.let { IntValue(it) }
PsiTypes.longType() -> (value as? Long)?.let { LongValue(it) }
PsiTypes.floatType() -> (value as? Float)?.let { FloatValue(it) }
PsiTypes.doubleType() -> (value as? Double)?.let { DoubleValue(it) }
PsiTypes.booleanType() -> (value as? Boolean)?.let { BooleanValue(it) }
PsiTypes.nullType() -> NullValue
else -> StringValue(text ?: "")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class AnalysisEnvironment(
private val configuration = CompilerConfiguration()

init {
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector)
configuration.put(CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector)
}

internal fun createCoreEnvironment(): KotlinCoreEnvironment {
Expand Down Expand Up @@ -319,7 +319,7 @@ public class AnalysisEnvironment(
)
}
} catch (e: Throwable) {
configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
configuration.getNotNull(CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY)
.report(CompilerMessageSeverity.WARNING, "Can not resolve KLIB. " + e.message)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ internal fun KaSession.getKDocDocumentationFrom(symbol: KaSymbol, logger: DokkaL
val ktElement = symbol.psi
val kdocLocation = ktElement?.containingFile?.name?.let {
val name = when(symbol) {
is KaCallableSymbol -> symbol.callableIdIfNonLocal?.toString()
is KaClassOrObjectSymbol -> symbol.classIdIfNonLocal?.toString()
is KaCallableSymbol -> symbol.callableId?.toString()
is KaClassOrObjectSymbol -> symbol.classId?.toString()
is KaNamedSymbol -> symbol.name.asString()
else -> null
}?.replace('/', '.') // replace to be compatible with K1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.utilities.DokkaLogger
import org.jetbrains.kotlin.analysis.api.KtAnalysisApiInternals
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeTokenProvider
import org.jetbrains.kotlin.analysis.api.standalone.KtAlwaysAccessibleLifetimeTokenProvider
import org.jetbrains.kotlin.analysis.api.standalone.buildStandaloneAnalysisAPISession
import org.jetbrains.kotlin.analysis.project.structure.KtSourceModule
import org.jetbrains.kotlin.analysis.project.structure.builder.KtModuleBuilder
Expand Down Expand Up @@ -72,8 +70,6 @@ internal fun createAnalysisSession(
projectDisposable = projectDisposable,
withPsiDeclarationFromBinaryModuleProvider = false
) {
registerProjectService(KtLifetimeTokenProvider::class.java, KtAlwaysAccessibleLifetimeTokenProvider())

val sortedSourceSets = topologicalSortByDependantSourceSets(sourceSets, logger)

val sourcesModuleBySourceSetId = mutableMapOf<DokkaSourceSetID, KtSourceModule>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,14 @@ private fun CallableId.createDRI(receiver: TypeReference?, params: List<TypeRefe
internal fun getDRIFromNonErrorClassType(nonErrorClassType: KaNonErrorClassType): DRI =
nonErrorClassType.classId.createDRI()

private val KaCallableSymbol.callableId
get() = this.callableIdIfNonLocal ?: throw IllegalStateException("Can not get callable Id due to it is local")

// because of compatibility with Dokka K1, DRI of entry is kept as non-callable
internal fun getDRIFromEnumEntry(symbol: KaEnumEntrySymbol): DRI =
symbol.callableId.let {
DRI(
packageName = it.packageName.asString(),
classNames = it.className?.asString() + "." + it.callableName.asString(),
)
}.withEnumEntryExtra()
internal fun getDRIFromEnumEntry(symbol: KaEnumEntrySymbol): DRI {
val callableId = symbol.callableId ?: throw IllegalStateException("Can not get callable Id due to it is local")
return DRI(
packageName = callableId.packageName.asString(),
classNames = callableId.className?.asString() + "." + callableId.callableName.asString(),
).withEnumEntryExtra()
}


internal fun KaSession.getDRIFromTypeParameter(symbol: KaTypeParameterSymbol): DRI {
Expand All @@ -55,32 +52,33 @@ internal fun KaSession.getDRIFromTypeParameter(symbol: KaTypeParameterSymbol): D
return getDRIFromSymbol(containingSymbol).copy(target = PointingToGenericParameters(index))
}

internal fun KaSession.getDRIFromConstructor(symbol: KaConstructorSymbol): DRI =
(symbol.containingClassIdIfNonLocal
?: throw IllegalStateException("Can not get class Id due to it is local")).createDRI().copy(
internal fun KaSession.getDRIFromConstructor(symbol: KaConstructorSymbol): DRI {
val containingClassId =
symbol.containingClassId ?: throw IllegalStateException("Can not get class Id due to it is local")
return containingClassId.createDRI().copy(
callable = Callable(
name = symbol.containingClassIdIfNonLocal?.shortClassName?.asString() ?: "",
params = symbol.valueParameters.map { getTypeReferenceFrom(it.returnType) })
name = containingClassId.shortClassName.asString(),
params = symbol.valueParameters.map { getTypeReferenceFrom(it.returnType) }
)
)
}

internal fun KaSession.getDRIFromVariableLike(symbol: KaVariableLikeSymbol): DRI {
val receiver = symbol.receiverType?.let {
getTypeReferenceFrom(it)
}
return symbol.callableId.createDRI(receiver, emptyList())
val callableId = symbol.callableId ?: throw IllegalStateException("Can not get callable Id due to it is local")
val receiver = symbol.receiverType?.let(::getTypeReferenceFrom)
return callableId.createDRI(receiver, emptyList())
}

internal fun KaSession.getDRIFromFunctionLike(symbol: KaFunctionLikeSymbol): DRI {
val params = symbol.valueParameters.map { getTypeReferenceFrom(it.returnType) }
val receiver = symbol.receiverType?.let {
getTypeReferenceFrom(it)
}
return symbol.callableIdIfNonLocal?.createDRI(receiver, params)
?: getDRIFromLocalFunction(symbol)
return symbol.callableId?.createDRI(receiver, params) ?: getDRIFromLocalFunction(symbol)
}

internal fun getDRIFromClassLike(symbol: KaClassLikeSymbol): DRI =
symbol.classIdIfNonLocal?.createDRI() ?: throw IllegalStateException("Can not get class Id due to it is local")
symbol.classId?.createDRI() ?: throw IllegalStateException("Can not get class Id due to it is local")

internal fun getDRIFromPackage(symbol: KaPackageSymbol): DRI =
DRI(packageName = symbol.fqName.asString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ internal class DokkaSymbolVisitor(
.filterOutSyntheticJavaPropBackingField()

fun List<KaFunctionSymbol>.filterOutSyntheticJavaPropAccessors() = filterNot { fn ->
if (fn.origin == KaSymbolOrigin.JAVA && fn.callableIdIfNonLocal != null)
syntheticJavaProperties.any { fn.callableIdIfNonLocal == it.javaGetterSymbol.callableIdIfNonLocal || fn.callableIdIfNonLocal == it.javaSetterSymbol?.callableIdIfNonLocal }
if (fn.origin == KaSymbolOrigin.JAVA && fn.callableId != null)
syntheticJavaProperties.any { fn.callableId == it.javaGetterSymbol.callableId || fn.callableId == it.javaSetterSymbol?.callableId }
else false
}

Expand Down Expand Up @@ -577,9 +577,9 @@ internal class DokkaSymbolVisitor(
// it also covers @JvmName annotation
val name = (if (isGetter) propertySymbol.javaGetterName else propertySymbol.javaSetterName)?.asString() ?: ""

// SyntheticJavaProperty has callableIdIfNonLocal, propertyAccessorSymbol.origin = JAVA_SYNTHETIC_PROPERTY
// For Kotlin properties callableIdIfNonLocal=null
val dri = if (propertyAccessorSymbol.callableIdIfNonLocal != null)
// SyntheticJavaProperty has callableId, propertyAccessorSymbol.origin = JAVA_SYNTHETIC_PROPERTY
// For Kotlin properties callableId=null
val dri = if (propertyAccessorSymbol.callableId != null)
getDRIFromFunctionLike(propertyAccessorSymbol)
else
propertyDRI.copy(
Expand Down Expand Up @@ -629,7 +629,7 @@ internal class DokkaSymbolVisitor(
private fun KaSession.visitConstructorSymbol(
constructorSymbol: KaConstructorSymbol
): DFunction = withExceptionCatcher(constructorSymbol) {
val name = constructorSymbol.containingClassIdIfNonLocal?.shortClassName?.asString()
val name = constructorSymbol.containingClassId?.shortClassName?.asString()
?: throw IllegalStateException("Unknown containing class of constructor")
val dri = createDRIWithOverridden(constructorSymbol).origin
val isExpect = constructorSymbol.isExpect
Expand Down
10 changes: 6 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ kotlinx-serialization = "1.6.0"
kotlinx-bcv = "0.13.2"

## Analysis
kotlin-compiler = "2.0.0"
kotlin-compiler-k2 = "2.0.20-dev-4579"
# Version of compiler for analysis-descriptor is in sync with K2 because of updated intellij-platform in 2.0.20-dev-5055
# can be changed to just 2.0.20 after release of Kotlin 2.0.20
kotlin-compiler = "2.0.20-dev-5135"
kotlin-compiler-k2 = "2.0.20-dev-5135"

# MUST match the version of the intellij platform used in the kotlin compiler,
# otherwise this will lead to different versions of psi API and implementations
# on the classpath and will fail with hard to debug problems in runtime.
# See: https://github.com/JetBrains/kotlin/blob/e6633d3d9214402fcf3585ae8c24213a4761cc8b/gradle/versions.properties#L1
intellij-platform = "213.7172.53"
# See: https://github.com/JetBrains/kotlin/blob/480b38f967493adf494b4e049cbe5ac1060d215f/gradle/versions.properties#L1
intellij-platform = "233.13135.103"

## HTML
jsoup = "1.16.1"
Expand Down

0 comments on commit 5b12e28

Please sign in to comment.