Fix IDE resolve on startup

This commit is contained in:
Him188 2020-10-02 13:45:25 +08:00
parent 6e16ee3d13
commit e214a43043
3 changed files with 4 additions and 6 deletions

View File

@ -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()

View File

@ -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")

View File

@ -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<KtCallExpression>()
.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<out CallableDescriptor>? {
return this?.getCall(context)?.getResolvedCall(context) ?: this?.resolveToCall(bodyResolveMode)
return this?.getCall(context)?.getResolvedCall(context)// ?: this?.resolveToCall(bodyResolveMode)
}
val ResolvedCall<out CallableDescriptor>.valueParameters: List<ValueParameterDescriptor> get() = this.resultingDescriptor.valueParameters