From e214a430433eeb40bc1b8e926829b724087077ff Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 2 Oct 2020 13:45:25 +0800 Subject: [PATCH] Fix IDE resolve on startup --- buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt | 3 +-- .../run/projects/test-project/build.gradle.kts | 2 +- .../net/mamoe/mirai/console/intellij/resolve/resolveIdea.kt | 5 ++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt b/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt index f18ecea8a..8dbd47d8a 100644 --- a/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt +++ b/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt @@ -127,8 +127,7 @@ val gitVersion: String by lazy { exec.waitFor() exec.inputStream.readBytes().toString(Charsets.UTF_8).trim().also { println("Git commit id: $it") - } - }.onFailure { + } }.onFailure { it.printStackTrace() return@lazy "UNKNOWN" }.getOrThrow() diff --git a/tools/intellij-plugin/run/projects/test-project/build.gradle.kts b/tools/intellij-plugin/run/projects/test-project/build.gradle.kts index 72f695b95..e1c0ff8b7 100644 --- a/tools/intellij-plugin/run/projects/test-project/build.gradle.kts +++ b/tools/intellij-plugin/run/projects/test-project/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { compileOnly(kotlin("stdlib-jdk8")) val core = "1.3.0" - val console = "1.0-RC-dev-4" + val console = "1.0-RC-dev-28" compileOnly("net.mamoe:mirai-console:$console") compileOnly("net.mamoe:mirai-core:$core") diff --git a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/resolve/resolveIdea.kt b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/resolve/resolveIdea.kt index a03640687..723da4408 100644 --- a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/resolve/resolveIdea.kt +++ b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/resolve/resolveIdea.kt @@ -19,7 +19,6 @@ import net.mamoe.mirai.console.compiler.common.resolve.findParent import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.descriptors.VariableDescriptor -import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName import org.jetbrains.kotlin.idea.references.KtSimpleNameReference import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor @@ -98,7 +97,7 @@ fun KtDeclaration.resolveAllCallsWithElement(bindingContext: BindingContext): Se .filterIsInstance() .mapNotNull { val callee = it.calleeExpression ?: return@mapNotNull null - val resolved = callee.getResolvedCallOrResolveToCall(bindingContext) ?: return@mapNotNull null + val resolved = callee.getResolvedCall(bindingContext) ?: return@mapNotNull null resolved to it } @@ -128,7 +127,7 @@ fun KtElement?.getResolvedCallOrResolveToCall( context: BindingContext, bodyResolveMode: BodyResolveMode = BodyResolveMode.PARTIAL, ): ResolvedCall? { - return this?.getCall(context)?.getResolvedCall(context) ?: this?.resolveToCall(bodyResolveMode) + return this?.getCall(context)?.getResolvedCall(context)// ?: this?.resolveToCall(bodyResolveMode) } val ResolvedCall.valueParameters: List get() = this.resultingDescriptor.valueParameters