FIR IDE: add validity token to KtCall
This commit is contained in:
committed by
Ilya Kirillov
parent
245c4082cd
commit
9f0f1781c9
@@ -5,16 +5,19 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.calls
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnostic
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtFunctionLikeSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtValueParameterSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtVariableLikeSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
import org.jetbrains.kotlin.analysis.api.withValidityAssertion
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
|
||||
/**
|
||||
* Represents direct or indirect (via invoke) function call from Kotlin code
|
||||
*/
|
||||
public sealed class KtCall {
|
||||
public sealed class KtCall : ValidityTokenOwner {
|
||||
public abstract val isErrorCall: Boolean
|
||||
public abstract val argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>
|
||||
public abstract val targetFunction: KtCallTarget
|
||||
@@ -28,11 +31,17 @@ public sealed class KtCall {
|
||||
* }
|
||||
*/
|
||||
public class KtFunctionalTypeVariableCall(
|
||||
public val target: KtVariableLikeSymbol,
|
||||
override val argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>,
|
||||
override val targetFunction: KtCallTarget
|
||||
private val _target: KtVariableLikeSymbol,
|
||||
private val _argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>,
|
||||
private val _targetFunction: KtCallTarget,
|
||||
override val token: ValidityToken
|
||||
) : KtCall() {
|
||||
override val isErrorCall: Boolean get() = false
|
||||
public val target: KtVariableLikeSymbol get() = withValidityAssertion { _target }
|
||||
override val isErrorCall: Boolean get() = withValidityAssertion { false }
|
||||
override val argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>
|
||||
get() = withValidityAssertion { _argumentMapping }
|
||||
override val targetFunction: KtCallTarget
|
||||
get() = withValidityAssertion { _targetFunction }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +49,7 @@ public class KtFunctionalTypeVariableCall(
|
||||
*/
|
||||
public sealed class KtDeclaredFunctionCall : KtCall() {
|
||||
override val isErrorCall: Boolean
|
||||
get() = targetFunction is KtErrorCallTarget
|
||||
get() = withValidityAssertion { targetFunction is KtErrorCallTarget }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,9 +63,15 @@ public sealed class KtDeclaredFunctionCall : KtCall() {
|
||||
*/
|
||||
public class KtVariableWithInvokeFunctionCall(
|
||||
public val target: KtVariableLikeSymbol,
|
||||
override val argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>,
|
||||
private val _argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>,
|
||||
private val _targetFunction: KtCallTarget,
|
||||
override val token: ValidityToken
|
||||
) : KtDeclaredFunctionCall() {
|
||||
override val argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>
|
||||
get() = withValidityAssertion { _argumentMapping }
|
||||
override val targetFunction: KtCallTarget
|
||||
) : KtDeclaredFunctionCall()
|
||||
get() = withValidityAssertion { _targetFunction }
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple function call, e.g.,
|
||||
@@ -64,9 +79,15 @@ public class KtVariableWithInvokeFunctionCall(
|
||||
* x.toString() // function call
|
||||
*/
|
||||
public class KtFunctionCall(
|
||||
override val argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>,
|
||||
private val _argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>,
|
||||
private val _targetFunction: KtCallTarget,
|
||||
override val token: ValidityToken
|
||||
) : KtDeclaredFunctionCall() {
|
||||
override val argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>
|
||||
get() = withValidityAssertion { _argumentMapping }
|
||||
override val targetFunction: KtCallTarget
|
||||
) : KtDeclaredFunctionCall()
|
||||
get() = withValidityAssertion { _targetFunction }
|
||||
}
|
||||
|
||||
/**
|
||||
* Annotation call, e.g.,
|
||||
@@ -75,9 +96,15 @@ public class KtFunctionCall(
|
||||
* annotation class Ann
|
||||
*/
|
||||
public class KtAnnotationCall(
|
||||
override val argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>,
|
||||
private val _argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>,
|
||||
private val _targetFunction: KtCallTarget,
|
||||
override val token: ValidityToken
|
||||
) : KtDeclaredFunctionCall() {
|
||||
override val argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>
|
||||
get() = withValidityAssertion { _argumentMapping }
|
||||
override val targetFunction: KtCallTarget
|
||||
) : KtDeclaredFunctionCall()
|
||||
get() = withValidityAssertion { _targetFunction }
|
||||
}
|
||||
// TODO: Add other properties, e.g., useSiteTarget
|
||||
|
||||
/**
|
||||
@@ -89,10 +116,16 @@ public class KtAnnotationCall(
|
||||
* }
|
||||
*/
|
||||
public class KtDelegatedConstructorCall(
|
||||
override val argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>,
|
||||
override val targetFunction: KtCallTarget,
|
||||
public val kind: KtDelegatedConstructorCallKind
|
||||
) : KtDeclaredFunctionCall()
|
||||
private val _argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>,
|
||||
private val _targetFunction: KtCallTarget,
|
||||
public val kind: KtDelegatedConstructorCallKind,
|
||||
override val token: ValidityToken
|
||||
) : KtDeclaredFunctionCall() {
|
||||
override val argumentMapping: LinkedHashMap<KtExpression, KtValueParameterSymbol>
|
||||
get() = withValidityAssertion { _argumentMapping }
|
||||
override val targetFunction: KtCallTarget
|
||||
get() = withValidityAssertion { _targetFunction }
|
||||
}
|
||||
|
||||
public enum class KtDelegatedConstructorCallKind { SUPER_CALL, THIS_CALL }
|
||||
|
||||
@@ -101,22 +134,26 @@ public enum class KtDelegatedConstructorCallKind { SUPER_CALL, THIS_CALL }
|
||||
* Can be success [KtSuccessCallTarget] in this case there only one such function
|
||||
* Or erroneous [KtErrorCallTarget] in this case there can be any count of candidates
|
||||
*/
|
||||
public sealed class KtCallTarget {
|
||||
public sealed class KtCallTarget : ValidityTokenOwner {
|
||||
public abstract val candidates: Collection<KtFunctionLikeSymbol>
|
||||
}
|
||||
|
||||
/**
|
||||
* Success call of [symbol]
|
||||
*/
|
||||
public class KtSuccessCallTarget(public val symbol: KtFunctionLikeSymbol) : KtCallTarget() {
|
||||
override val candidates: Collection<KtFunctionLikeSymbol>
|
||||
get() = listOf(symbol)
|
||||
public class KtSuccessCallTarget(private val _symbol: KtFunctionLikeSymbol, override val token: ValidityToken) : KtCallTarget() {
|
||||
public val symbol: KtFunctionLikeSymbol get() = withValidityAssertion { _symbol }
|
||||
override val candidates: Collection<KtFunctionLikeSymbol> get() = withValidityAssertion { listOf(symbol) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Function all with errors, possible candidates are [candidates]
|
||||
* Function call with errors, possible candidates are [candidates]
|
||||
*/
|
||||
public class KtErrorCallTarget(
|
||||
override val candidates: Collection<KtFunctionLikeSymbol>,
|
||||
public val diagnostic: KtDiagnostic
|
||||
) : KtCallTarget()
|
||||
private val _candidates: Collection<KtFunctionLikeSymbol>,
|
||||
private val _diagnostic: KtDiagnostic,
|
||||
override val token: ValidityToken
|
||||
) : KtCallTarget() {
|
||||
public val diagnostic: KtDiagnostic get() = withValidityAssertion { _diagnostic }
|
||||
override val candidates: Collection<KtFunctionLikeSymbol> get() = withValidityAssertion { _candidates }
|
||||
}
|
||||
Reference in New Issue
Block a user