diff --git a/buildSrc/src/main/kotlin/ProjectConfigure.kt b/buildSrc/src/main/kotlin/ProjectConfigure.kt index 409eb33d3..dfa36dd95 100644 --- a/buildSrc/src/main/kotlin/ProjectConfigure.kt +++ b/buildSrc/src/main/kotlin/ProjectConfigure.kt @@ -36,7 +36,7 @@ fun Project.useIr() { private fun Project.jvmVersion(): JavaVersion { return if (project.path.endsWith("mirai-console-intellij")) { - JavaVersion.VERSION_11 + JavaVersion.VERSION_17 } else { JavaVersion.VERSION_1_8 } diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index f219294d3..77a4bf167 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -72,7 +72,7 @@ object Versions { const val junit = "5.7.2" const val yamlkt = "0.12.0" - const val intellijGradlePlugin = "1.7.0" + const val intellijGradlePlugin = "1.11.0" // https://github.com/google/jimfs // Java In Memory File System diff --git a/mirai-console/tools/intellij-plugin/build.gradle.kts b/mirai-console/tools/intellij-plugin/build.gradle.kts index 561e9f0cb..0a7e08766 100644 --- a/mirai-console/tools/intellij-plugin/build.gradle.kts +++ b/mirai-console/tools/intellij-plugin/build.gradle.kts @@ -44,8 +44,8 @@ intellij { } java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } tasks.getByName("publishPlugin", org.jetbrains.intellij.tasks.PublishPluginTask::class) { @@ -64,15 +64,15 @@ fun File.resolveMkdir(relative: String): File { kotlin.target.compilations.all { kotlinOptions { - jvmTarget = "11" - apiVersion = "1.5" // bundled Kotlin is 1.5.10 + jvmTarget = "17" + apiVersion = "1.7" // bundled Kotlin is 1.7.20 } } // https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library tasks.withType { - sinceBuild.set("221") - untilBuild.set("222.*") + sinceBuild.set("223") + untilBuild.set("223.*") pluginDescription.set( """ Plugin development support for Mirai Console diff --git a/mirai-console/tools/intellij-plugin/run/projects/test-project/build.gradle.kts b/mirai-console/tools/intellij-plugin/run/projects/test-project/build.gradle.kts index 51870ee5a..cefd7c8ab 100644 --- a/mirai-console/tools/intellij-plugin/run/projects/test-project/build.gradle.kts +++ b/mirai-console/tools/intellij-plugin/run/projects/test-project/build.gradle.kts @@ -1,6 +1,15 @@ +/* + * Copyright 2019-2022 Mamoe Technologies and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. + * + * https://github.com/mamoe/mirai/blob/dev/LICENSE + */ + plugins { - kotlin("jvm") version "1.6.0" - kotlin("plugin.serialization") version "1.6.0" + kotlin("jvm") version "1.7.20" + kotlin("plugin.serialization") version "1.7.20" id("net.mamoe.mirai-console") version "2.99.0-local" java } diff --git a/mirai-console/tools/intellij-plugin/src/IDEContainerContributor.kt b/mirai-console/tools/intellij-plugin/src/IDEContainerContributor.kt index a9d852cce..8601d71c6 100644 --- a/mirai-console/tools/intellij-plugin/src/IDEContainerContributor.kt +++ b/mirai-console/tools/intellij-plugin/src/IDEContainerContributor.kt @@ -1,10 +1,10 @@ /* - * Copyright 2019-2021 Mamoe Technologies and contributors. + * Copyright 2019-2022 Mamoe Technologies and contributors. * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. * - * https://github.com/mamoe/mirai/blob/master/LICENSE + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ package net.mamoe.mirai.console.intellij @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.container.useInstance import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor -import org.jetbrains.kotlin.idea.core.unwrapModuleSourceInfo +import org.jetbrains.kotlin.idea.base.projectStructure.unwrapModuleSourceInfo import org.jetbrains.kotlin.idea.facet.KotlinFacet import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker diff --git a/mirai-console/tools/intellij-plugin/src/diagnostics/PluginMainServiceNotConfiguredInspection.kt b/mirai-console/tools/intellij-plugin/src/diagnostics/PluginMainServiceNotConfiguredInspection.kt index 161495139..7ba38dd95 100644 --- a/mirai-console/tools/intellij-plugin/src/diagnostics/PluginMainServiceNotConfiguredInspection.kt +++ b/mirai-console/tools/intellij-plugin/src/diagnostics/PluginMainServiceNotConfiguredInspection.kt @@ -11,7 +11,9 @@ package net.mamoe.mirai.console.intellij.diagnostics import com.intellij.codeInspection.ProblemHighlightType import com.intellij.codeInspection.ProblemsHolder +import com.intellij.openapi.application.runReadAction import com.intellij.openapi.progress.impl.CancellationCheck.Companion.runWithCancellationCheck +import com.intellij.openapi.project.rootManager import com.intellij.psi.PsiClass import com.intellij.psi.PsiElement import com.intellij.psi.PsiElementVisitor @@ -21,10 +23,8 @@ import net.mamoe.mirai.console.compiler.common.resolve.PLUGIN_FQ_NAME import net.mamoe.mirai.console.intellij.diagnostics.fix.ConfigurePluginMainServiceFix import net.mamoe.mirai.console.intellij.resolve.allSuperNames import net.mamoe.mirai.console.intellij.resolve.hasAnnotation -import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection -import org.jetbrains.kotlin.idea.util.application.runReadAction -import org.jetbrains.kotlin.idea.util.module -import org.jetbrains.kotlin.idea.util.rootManager +import org.jetbrains.kotlin.idea.base.util.module +import org.jetbrains.kotlin.idea.codeinsight.api.classic.inspections.AbstractKotlinInspection import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtObjectDeclaration import org.jetbrains.kotlin.psi.classOrObjectVisitor diff --git a/mirai-console/tools/intellij-plugin/src/diagnostics/ResourceNotClosedInspection.kt b/mirai-console/tools/intellij-plugin/src/diagnostics/ResourceNotClosedInspection.kt index 2d76c26fd..49cec3bee 100644 --- a/mirai-console/tools/intellij-plugin/src/diagnostics/ResourceNotClosedInspection.kt +++ b/mirai-console/tools/intellij-plugin/src/diagnostics/ResourceNotClosedInspection.kt @@ -16,15 +16,15 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.psi.* import net.mamoe.mirai.console.intellij.resolve.* -import org.jetbrains.kotlin.idea.base.utils.fqname.getKotlinFqName +import org.jetbrains.kotlin.idea.base.psi.kotlinFqName import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall -import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection +import org.jetbrains.kotlin.idea.codeinsight.api.classic.inspections.AbstractKotlinInspection import org.jetbrains.kotlin.idea.inspections.KotlinUniversalQuickFix import org.jetbrains.kotlin.idea.quickfix.KotlinCrossLanguageQuickFixAction +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor import org.jetbrains.kotlin.idea.util.ImportInsertHelper import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.nj2k.postProcessing.resolve import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject import org.jetbrains.kotlin.psi.psiUtil.referenceExpression @@ -65,7 +65,7 @@ val CONTACT_FQ_NAME = FqName("net.mamoe.mirai.contact.Contact") val CONTACT_COMPANION_FQ_NAME = FqName("net.mamoe.mirai.contact.Contact.Companion") fun KtReferenceExpression.resolveCalleeFunction(): KtNamedFunction? { - val originalCallee = getCalleeExpressionIfAny()?.referenceExpression()?.resolve() ?: return null + val originalCallee = getCalleeExpressionIfAny()?.referenceExpression()?.mainReference?.resolve() ?: return null if (originalCallee !is KtNamedFunction) return null return originalCallee @@ -77,12 +77,12 @@ fun KtNamedFunction.isNamedMemberFunctionOf( extensionReceiver: String? = null ): Boolean { if (extensionReceiver != null) { - if (this.receiverTypeReference?.resolveReferencedType()?.getKotlinFqName() + if (this.receiverTypeReference?.resolveReferencedType()?.kotlinFqName ?.toString() != extensionReceiver ) return false } return this.name == functionName && this.containingClassOrObject?.allSuperTypes?.any { - it.getKotlinFqName()?.toString() == className + it.kotlinFqName?.toString() == className } == true } @@ -142,6 +142,7 @@ object ResourceNotClosedInspectionProcessors { Fix("sendAsImageTo"), ) } + callee.hasSignature(UPLOAD_AS_IMAGE) -> { holder.registerResourceNotClosedProblem( parent.receiverExpression, @@ -232,6 +233,7 @@ object ResourceNotClosedInspectionProcessors { fileTypeArgument = arguments.getOrNull(1) ) { it.methodExpression.qualifierExpression?.text ?: "this" } } + callee.hasSignature(CONTACT_UPLOAD_IMAGE_STATIC) -> { createFixImpl( expr = expr, diff --git a/mirai-console/tools/intellij-plugin/src/diagnostics/UsingStringPlusMessageInspection.kt b/mirai-console/tools/intellij-plugin/src/diagnostics/UsingStringPlusMessageInspection.kt index 1af4ac19d..320002a5a 100644 --- a/mirai-console/tools/intellij-plugin/src/diagnostics/UsingStringPlusMessageInspection.kt +++ b/mirai-console/tools/intellij-plugin/src/diagnostics/UsingStringPlusMessageInspection.kt @@ -17,12 +17,12 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiElementVisitor import com.intellij.psi.PsiFile import net.mamoe.mirai.console.intellij.resolve.* +import org.jetbrains.kotlin.idea.codeinsight.api.classic.inspections.AbstractKotlinInspection import org.jetbrains.kotlin.idea.core.ShortenReferences -import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection import org.jetbrains.kotlin.idea.inspections.KotlinUniversalQuickFix import org.jetbrains.kotlin.idea.quickfix.KotlinCrossLanguageQuickFixAction +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.lexer.KtTokens -import org.jetbrains.kotlin.nj2k.postProcessing.resolve import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForReceiver @@ -42,7 +42,7 @@ class UsingStringPlusMessageInspection : AbstractKotlinInspection() { fun KtReferenceExpression.isCallingStringPlus(): Boolean { - val callee = this.referenceExpression()?.resolve() ?: return false + val callee = this.referenceExpression()?.mainReference?.resolve() ?: return false if (callee !is KtNamedFunction) return false val className = callee.containingClassOrObject?.fqName?.asString() diff --git a/mirai-console/tools/intellij-plugin/src/diagnostics/diagnosticsUtil.kt b/mirai-console/tools/intellij-plugin/src/diagnostics/diagnosticsUtil.kt index 326f42b44..31bb6daae 100644 --- a/mirai-console/tools/intellij-plugin/src/diagnostics/diagnosticsUtil.kt +++ b/mirai-console/tools/intellij-plugin/src/diagnostics/diagnosticsUtil.kt @@ -15,7 +15,7 @@ import net.mamoe.mirai.console.compiler.common.resolve.READ_ONLY_PLUGIN_DATA_FQ_ import net.mamoe.mirai.console.intellij.resolve.getResolvedCall import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.diagnostics.Diagnostic -import org.jetbrains.kotlin.idea.base.utils.fqname.getKotlinFqName +import org.jetbrains.kotlin.idea.base.psi.kotlinFqName import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtElement @@ -47,7 +47,7 @@ fun KtElement.getResolvedCall( } fun KtTypeReference.isReferencing(fqName: FqName): Boolean { - return resolveReferencedType()?.getKotlinFqName() == fqName + return resolveReferencedType()?.kotlinFqName == fqName } val KtTypeReference.referencedUserType: KtUserType? get() = this.typeElement.castOrNull() diff --git a/mirai-console/tools/intellij-plugin/src/diagnostics/fix/ConfigurePluginMainServiceFix.kt b/mirai-console/tools/intellij-plugin/src/diagnostics/fix/ConfigurePluginMainServiceFix.kt index 0b78e9759..eb87be1e0 100644 --- a/mirai-console/tools/intellij-plugin/src/diagnostics/fix/ConfigurePluginMainServiceFix.kt +++ b/mirai-console/tools/intellij-plugin/src/diagnostics/fix/ConfigurePluginMainServiceFix.kt @@ -18,11 +18,11 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import net.mamoe.mirai.console.intellij.diagnostics.readChildText import net.mamoe.mirai.console.intellij.diagnostics.writeChild -import org.jetbrains.kotlin.idea.core.isAndroidModule +import org.jetbrains.kotlin.idea.base.util.isAndroidModule +import org.jetbrains.kotlin.idea.base.util.module import org.jetbrains.kotlin.idea.inspections.KotlinUniversalQuickFix import org.jetbrains.kotlin.idea.quickfix.KotlinCrossLanguageQuickFixAction import org.jetbrains.kotlin.idea.util.application.executeWriteCommand -import org.jetbrains.kotlin.idea.util.module class ConfigurePluginMainServiceFix( diff --git a/mirai-console/tools/intellij-plugin/src/diagnostics/fix/TypeProjectionFix.kt b/mirai-console/tools/intellij-plugin/src/diagnostics/fix/TypeProjectionFix.kt index d3b3f49fc..e7946c25e 100644 --- a/mirai-console/tools/intellij-plugin/src/diagnostics/fix/TypeProjectionFix.kt +++ b/mirai-console/tools/intellij-plugin/src/diagnostics/fix/TypeProjectionFix.kt @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021 Mamoe Technologies and contributors. + * Copyright 2019-2022 Mamoe Technologies and contributors. * * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. @@ -14,12 +14,11 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.psi.PsiFile import org.jetbrains.kotlin.diagnostics.Diagnostic +import org.jetbrains.kotlin.idea.base.psi.replaced import org.jetbrains.kotlin.idea.core.ShortenReferences -import org.jetbrains.kotlin.idea.core.replaced import org.jetbrains.kotlin.idea.inspections.KotlinUniversalQuickFix import org.jetbrains.kotlin.idea.quickfix.KotlinCrossLanguageQuickFixAction import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory -import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.KtTypeProjection @@ -32,18 +31,15 @@ abstract class AbstractTypeProjectionFix( override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) { val element = element ?: return - project.executeWriteCommand(name) { - val arguments = element.text.substringAfter('<', "") - - val e = element.replaced( - KtPsiFactory(project).createTypeArgument( - if (arguments.isBlank()) { - newTypeFqn - } else "$newTypeFqn<$arguments" - ) - ) - ShortenReferences.DEFAULT.process(e) - } + val arguments = element.text.substringAfter('<', "") + val newTypeElement = KtPsiFactory(project).createTypeArgument( + if (arguments.isBlank()) { + newTypeFqn + } else "$newTypeFqn<$arguments" + ) + val e = element.replaced(newTypeElement) + // ABI change + ShortenReferences.DEFAULT.process(e) } } diff --git a/mirai-console/tools/intellij-plugin/src/diagnostics/fix/WrapWithResourceUseCallIntention.kt b/mirai-console/tools/intellij-plugin/src/diagnostics/fix/WrapWithResourceUseCallIntention.kt index 207d47ed1..835c71ceb 100644 --- a/mirai-console/tools/intellij-plugin/src/diagnostics/fix/WrapWithResourceUseCallIntention.kt +++ b/mirai-console/tools/intellij-plugin/src/diagnostics/fix/WrapWithResourceUseCallIntention.kt @@ -19,8 +19,8 @@ import net.mamoe.mirai.console.intellij.diagnostics.ResourceNotClosedInspectionP import net.mamoe.mirai.console.intellij.diagnostics.replaceExpressionAndShortenReferences import net.mamoe.mirai.console.intellij.diagnostics.resolveCalleeFunction import net.mamoe.mirai.console.intellij.resolve.hasSignature -import org.jetbrains.kotlin.idea.intentions.SelfTargetingIntention -import org.jetbrains.kotlin.idea.util.module +import org.jetbrains.kotlin.idea.base.util.module +import org.jetbrains.kotlin.idea.codeinsight.api.classic.intentions.SelfTargetingIntention import org.jetbrains.kotlin.psi.KtDotQualifiedExpression import org.jetbrains.kotlin.psi.KtSimpleNameExpression import org.jetbrains.kotlin.psi.psiUtil.referenceExpression diff --git a/mirai-console/tools/intellij-plugin/src/resolve/FunctionSignature.kt b/mirai-console/tools/intellij-plugin/src/resolve/FunctionSignature.kt index b0842d58d..d14e0ff2d 100644 --- a/mirai-console/tools/intellij-plugin/src/resolve/FunctionSignature.kt +++ b/mirai-console/tools/intellij-plugin/src/resolve/FunctionSignature.kt @@ -14,12 +14,13 @@ import com.intellij.psi.PsiModifier import net.mamoe.mirai.console.intellij.diagnostics.resolveReferencedType import org.jetbrains.kotlin.asJava.elements.KtLightMethod import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.idea.base.utils.fqname.getKotlinFqName +import org.jetbrains.kotlin.idea.base.psi.kotlinFqName import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall +import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.getReturnTypeReference import org.jetbrains.kotlin.idea.refactoring.fqName.fqName import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.nj2k.postProcessing.type +import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject @@ -87,7 +88,7 @@ fun KtFunction.hasSignature(functionSignature: FunctionSignature): Boolean { } if (functionSignature.extensionReceiver != null) { if (this.receiverTypeReference?.resolveReferencedType() - ?.getKotlinFqName() != functionSignature.extensionReceiver + ?.kotlinFqName != functionSignature.extensionReceiver ) return false } if (functionSignature.parameters != null) { @@ -97,12 +98,14 @@ fun KtFunction.hasSignature(functionSignature: FunctionSignature): Boolean { } if (functionSignature.returnType != null) { if (this.getReturnTypeReference()?.resolveReferencedType() - ?.getKotlinFqName() != functionSignature.returnType + ?.kotlinFqName != functionSignature.returnType ) return false } return true } +fun KtDeclaration.type() = + (resolveToDescriptorIfAny() as? CallableDescriptor)?.returnType fun PsiMethod.hasSignature(functionSignature: FunctionSignature): Boolean { if (functionSignature.name != null) { @@ -115,8 +118,8 @@ fun PsiMethod.hasSignature(functionSignature: FunctionSignature): Boolean { val kotlinContainingClassFqn = if (this is KtLightMethod) { if (this.modifierList.hasExplicitModifier(PsiModifier.STATIC)) { this.containingClass.kotlinOrigin?.companionObjects?.firstOrNull()?.fqName - } else containingClass.getKotlinFqName() - } else containingClass.getKotlinFqName() + } else containingClass.kotlinFqName + } else containingClass.kotlinFqName if (kotlinContainingClassFqn != functionSignature.dispatchReceiver) return false } diff --git a/mirai-console/tools/intellij-plugin/src/resolve/resolveIdea.kt b/mirai-console/tools/intellij-plugin/src/resolve/resolveIdea.kt index 72269ad6c..d12e3be6e 100644 --- a/mirai-console/tools/intellij-plugin/src/resolve/resolveIdea.kt +++ b/mirai-console/tools/intellij-plugin/src/resolve/resolveIdea.kt @@ -15,15 +15,15 @@ import net.mamoe.mirai.console.compiler.common.resolve.COMPOSITE_COMMAND_SUB_COM import net.mamoe.mirai.console.compiler.common.resolve.SIMPLE_COMMAND_HANDLER_COMMAND_FQ_NAME import net.mamoe.mirai.console.compiler.common.resolve.findParent import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.idea.base.utils.fqname.getKotlinFqName +import org.jetbrains.kotlin.idea.base.psi.kotlinFqName import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall import org.jetbrains.kotlin.idea.refactoring.fqName.fqName import org.jetbrains.kotlin.idea.references.KtSimpleNameReference +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.references.resolveToDescriptors import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.nj2k.postProcessing.resolve import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.referenceExpression import org.jetbrains.kotlin.resolve.BindingContext @@ -67,7 +67,8 @@ val KtPureClassOrObject.allSuperTypes: Sequence yieldAll(superTypeListEntries) for (list in superTypeListEntries.asSequence()) { yieldAll( - (list.typeAsUserType?.referenceExpression?.resolve()?.parents(true)?.filterIsInstance() + (list.typeAsUserType?.referenceExpression?.mainReference?.resolve()?.parents(true) + ?.filterIsInstance() ?.firstOrNull())?.allSuperTypes.orEmpty() ) } @@ -118,7 +119,7 @@ fun KtClass.hasSuperType(fqName: FqName): Boolean = allSuperNames.contains(fqNam @kotlin.internal.LowPriorityInOverloadResolution fun PsiElement.hasSuperType(fqName: FqName): Boolean = allSuperNames.contains(fqName) -val KtClassOrObject.allSuperNames: Sequence get() = allSuperTypes.mapNotNull { it.getKotlinFqName() } +val KtClassOrObject.allSuperNames: Sequence get() = allSuperTypes.mapNotNull { it.kotlinFqName } val PsiClass.allSuperNames: Sequence get() = allSuperTypes.mapNotNull { clazz -> clazz.qualifiedName?.let { @@ -151,14 +152,14 @@ fun getElementForLineMark(callElement: PsiElement): PsiElement = val KtAnnotationEntry.annotationClass: KtClass? get() = calleeExpression?.constructorReferenceExpression?.run { try { - resolve() + mainReference.resolve() } catch (e: Exception) { null // type inference with `by lazy {}` is unstable for now. I just ignore exceptions encountering with such issue. } }?.findParent() fun KtAnnotated.hasAnnotation(fqName: FqName): Boolean = - this.annotationEntries.any { it.annotationClass?.getKotlinFqName() == fqName } + this.annotationEntries.any { it.annotationClass?.kotlinFqName == fqName } fun ValueArgument.resolveStringConstantValues(bindingContext: BindingContext): Sequence? { return this.getArgumentExpression()?.resolveStringConstantValues(bindingContext) @@ -199,6 +200,7 @@ fun ConstantValue<*>.selfOrChildrenConstantStrings(): Sequence { is ArrayValue -> sequence { yieldAll(this@selfOrChildrenConstantStrings.selfOrChildrenConstantStrings()) } + else -> emptySequence() } } @@ -230,6 +232,7 @@ fun KtExpression.resolveStringConstantValues(bindingContext: BindingContext): Se //} } } + is KtStringTemplateExpression -> { if (hasInterpolation()) return emptySequence() return sequenceOf(entries.joinToString("") { it.text })