FIR IDE: resolve constructors to correct CallInfo
This commit is contained in:
@@ -5,23 +5,30 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.frontend.api
|
||||
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiMethod
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtConstructor
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
|
||||
sealed class CallInfo {
|
||||
abstract val isSuspendCall: Boolean
|
||||
abstract val targetFunction: PsiElement?
|
||||
abstract val isJavaFunctionCall: Boolean
|
||||
}
|
||||
|
||||
data class VariableAsFunctionCallInfo(val target: PsiElement, override val isSuspendCall: Boolean) : CallInfo() {
|
||||
override val targetFunction: PsiElement? = null
|
||||
override val isJavaFunctionCall: Boolean = false
|
||||
}
|
||||
|
||||
data class VariableAsFunctionLikeCallInfo(val target: PsiElement, val invokeFunction: KtNamedFunction) : CallInfo() {
|
||||
override val isSuspendCall: Boolean get() = invokeFunction.hasModifier(KtTokens.SUSPEND_KEYWORD)
|
||||
override val targetFunction: PsiElement? get() = invokeFunction
|
||||
override val isJavaFunctionCall: Boolean = false
|
||||
}
|
||||
|
||||
// SimpleFunctionCallInfo
|
||||
@@ -32,23 +39,44 @@ sealed class SimpleFunctionCallInfo : CallInfo() {
|
||||
|
||||
data class SimpleKtFunctionCallInfo(override val targetFunction: KtNamedFunction) : SimpleFunctionCallInfo() {
|
||||
override val isSuspendCall: Boolean get() = targetFunction.hasModifier(KtTokens.SUSPEND_KEYWORD)
|
||||
override val isJavaFunctionCall: Boolean = true
|
||||
}
|
||||
|
||||
data class SimpleJavaFunctionCallInfo(override val targetFunction: PsiMethod) : SimpleFunctionCallInfo() {
|
||||
override val isSuspendCall: Boolean = false
|
||||
override val isJavaFunctionCall: Boolean = false
|
||||
}
|
||||
|
||||
|
||||
// ConstructorCallInfo
|
||||
|
||||
//TODO
|
||||
object ConstructorCallInfo : CallInfo() {
|
||||
// abstract val targetConstructor: PsiElement?
|
||||
sealed class ConstructorCallInfo : CallInfo() {
|
||||
final override val isSuspendCall: Boolean = false
|
||||
override val targetFunction: PsiElement? = null
|
||||
abstract val isPrimary: Boolean
|
||||
}
|
||||
|
||||
//data class SimpleKtConstructorCallInfo(override val targetConstructor: KtConstructor<*>) : ConstructorCallInfo()
|
||||
data class KtExplicitConstructorCallInfo(
|
||||
override val targetFunction: KtConstructor<*>,
|
||||
override val isPrimary: Boolean
|
||||
) : ConstructorCallInfo() {
|
||||
override val isJavaFunctionCall: Boolean = false
|
||||
}
|
||||
|
||||
//data class SimpleJavaConstructorCallInfo(override val targetConstructor: PsiMethod) : ConstructorCallInfo()
|
||||
data class KtImplicitPrimaryConstructorCallInfo(val owner: KtClass) : ConstructorCallInfo() {
|
||||
override val targetFunction: PsiElement? = null
|
||||
override val isJavaFunctionCall: Boolean = false
|
||||
override val isPrimary: Boolean = true
|
||||
}
|
||||
|
||||
data class JavaExplicitConstructorCallInfo(
|
||||
override val targetFunction: PsiMethod,
|
||||
override val isPrimary: Boolean
|
||||
) : ConstructorCallInfo() {
|
||||
override val isJavaFunctionCall: Boolean = true
|
||||
}
|
||||
|
||||
data class JavaImplicitPrimaryConstructorCallInfo(val owner: PsiClass) : ConstructorCallInfo() {
|
||||
override val targetFunction: PsiElement? = null
|
||||
override val isJavaFunctionCall: Boolean = true
|
||||
override val isPrimary: Boolean = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user