[analysis api] rename ValidityToken -> KtLifetimeToken
This commit is contained in:
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbolProvider
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbolProviderMixIn
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.KtLifetimeToken
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
*
|
||||
* To create analysis session consider using [analyse]
|
||||
*/
|
||||
public abstract class KtAnalysisSession(final override val token: ValidityToken) : ValidityTokenOwner,
|
||||
public abstract class KtAnalysisSession(final override val token: KtLifetimeToken) : KtLifetimeOwner,
|
||||
KtSmartCastProviderMixIn,
|
||||
KtCallResolverMixIn,
|
||||
KtSamResolverMixIn,
|
||||
|
||||
+11
-11
@@ -14,9 +14,9 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Computable
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.AlwaysAccessibleValidityTokenFactory
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ReadActionConfinementValidityTokenFactory
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityTokenFactory
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.KtAlwaysAccessibleLifetimeTokenFactory
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ReadActionConfinementValidityTokenFactoryFactory
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.KtLifetimeTokenFactory
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
@@ -37,7 +37,7 @@ public abstract class KtAnalysisSessionProvider : Disposable {
|
||||
public val noWriteActionInAnalyseCallChecker: NoWriteActionInAnalyseCallChecker = NoWriteActionInAnalyseCallChecker(this)
|
||||
|
||||
@InvalidWayOfUsingAnalysisSession
|
||||
public abstract fun getAnalysisSession(contextElement: KtElement, factory: ValidityTokenFactory): KtAnalysisSession
|
||||
public abstract fun getAnalysisSession(contextElement: KtElement, factory: KtLifetimeTokenFactory): KtAnalysisSession
|
||||
|
||||
@InvalidWayOfUsingAnalysisSession
|
||||
public abstract fun getAnalysisSessionBySymbol(contextSymbol: KtSymbol): KtAnalysisSession
|
||||
@@ -57,18 +57,18 @@ public abstract class KtAnalysisSessionProvider : Disposable {
|
||||
elementToReanalyze: KtElement,
|
||||
action: KtAnalysisSession.() -> R
|
||||
): R {
|
||||
val dependedAnalysisSession = getAnalysisSession(originalFile, ReadActionConfinementValidityTokenFactory)
|
||||
val dependedAnalysisSession = getAnalysisSession(originalFile, ReadActionConfinementValidityTokenFactoryFactory)
|
||||
.createContextDependentCopy(originalFile, elementToReanalyze)
|
||||
return analyse(dependedAnalysisSession, ReadActionConfinementValidityTokenFactory, action)
|
||||
return analyse(dependedAnalysisSession, ReadActionConfinementValidityTokenFactoryFactory, action)
|
||||
}
|
||||
|
||||
@InvalidWayOfUsingAnalysisSession
|
||||
public inline fun <R> analyse(contextElement: KtElement, tokenFactory: ValidityTokenFactory, action: KtAnalysisSession.() -> R): R =
|
||||
public inline fun <R> analyse(contextElement: KtElement, tokenFactory: KtLifetimeTokenFactory, action: KtAnalysisSession.() -> R): R =
|
||||
analyse(getAnalysisSession(contextElement, tokenFactory), tokenFactory, action)
|
||||
|
||||
@OptIn(KtAnalysisSessionProviderInternals::class, KtInternalApiMarker::class)
|
||||
@InvalidWayOfUsingAnalysisSession
|
||||
public inline fun <R> analyse(analysisSession: KtAnalysisSession, factory: ValidityTokenFactory, action: KtAnalysisSession.() -> R): R {
|
||||
public inline fun <R> analyse(analysisSession: KtAnalysisSession, factory: KtLifetimeTokenFactory, action: KtAnalysisSession.() -> R): R {
|
||||
noWriteActionInAnalyseCallChecker.beforeEnteringAnalysisContext()
|
||||
factory.beforeEnteringAnalysisContext()
|
||||
return try {
|
||||
@@ -105,12 +105,12 @@ public abstract class KtAnalysisSessionProvider : Disposable {
|
||||
@OptIn(InvalidWayOfUsingAnalysisSession::class)
|
||||
public inline fun <R> analyse(contextElement: KtElement, action: KtAnalysisSession.() -> R): R =
|
||||
KtAnalysisSessionProvider.getInstance(contextElement.project)
|
||||
.analyse(contextElement, ReadActionConfinementValidityTokenFactory, action)
|
||||
.analyse(contextElement, ReadActionConfinementValidityTokenFactoryFactory, action)
|
||||
|
||||
@OptIn(InvalidWayOfUsingAnalysisSession::class)
|
||||
public inline fun <R> analyseWithCustomToken(
|
||||
contextElement: KtElement,
|
||||
tokenFactory: ValidityTokenFactory,
|
||||
tokenFactory: KtLifetimeTokenFactory,
|
||||
action: KtAnalysisSession.() -> R
|
||||
): R =
|
||||
KtAnalysisSessionProvider.getInstance(contextElement.project)
|
||||
@@ -124,7 +124,7 @@ public inline fun <R> analyseForUast(
|
||||
contextElement: KtElement,
|
||||
action: KtAnalysisSession.() -> R
|
||||
): R =
|
||||
analyseWithCustomToken(contextElement, AlwaysAccessibleValidityTokenFactory, action)
|
||||
analyseWithCustomToken(contextElement, KtAlwaysAccessibleLifetimeTokenFactory, action)
|
||||
|
||||
@OptIn(InvalidWayOfUsingAnalysisSession::class)
|
||||
public inline fun <R> analyseInDependedAnalysisSession(
|
||||
|
||||
+6
-6
@@ -5,21 +5,21 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.KtLifetimeToken
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.assertIsValidAndAccessible
|
||||
|
||||
public interface ValidityTokenOwner {
|
||||
public val token: ValidityToken
|
||||
public interface KtLifetimeOwner {
|
||||
public val token: KtLifetimeToken
|
||||
}
|
||||
|
||||
public fun ValidityTokenOwner.isValid(): Boolean = token.isValid()
|
||||
public fun KtLifetimeOwner.isValid(): Boolean = token.isValid()
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun ValidityTokenOwner.assertIsValidAndAccessible() {
|
||||
public inline fun KtLifetimeOwner.assertIsValidAndAccessible() {
|
||||
token.assertIsValidAndAccessible()
|
||||
}
|
||||
|
||||
public inline fun <R> ValidityTokenOwner.withValidityAssertion(action: () -> R): R {
|
||||
public inline fun <R> KtLifetimeOwner.withValidityAssertion(action: () -> R): R {
|
||||
assertIsValidAndAccessible()
|
||||
return action()
|
||||
}
|
||||
@@ -5,21 +5,21 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.KtLifetimeToken
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
public sealed class KtTypeArgument : ValidityTokenOwner {
|
||||
public sealed class KtTypeArgument : KtLifetimeOwner {
|
||||
public abstract val type: KtType?
|
||||
}
|
||||
|
||||
public class KtStarProjectionTypeArgument(override val token: ValidityToken) : KtTypeArgument() {
|
||||
public class KtStarProjectionTypeArgument(override val token: KtLifetimeToken) : KtTypeArgument() {
|
||||
override val type: KtType? get() = withValidityAssertion { null }
|
||||
}
|
||||
|
||||
public class KtTypeArgumentWithVariance(
|
||||
override val type: KtType,
|
||||
public val variance: Variance,
|
||||
override val token: ValidityToken,
|
||||
override val token: KtLifetimeToken,
|
||||
) : KtTypeArgument()
|
||||
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.annotations
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
*
|
||||
* Annotation owners are usually implement [KtAnnotated]
|
||||
*/
|
||||
public abstract class KtAnnotationsList : ValidityTokenOwner {
|
||||
public abstract class KtAnnotationsList : KtLifetimeOwner {
|
||||
/**
|
||||
* A list of annotations applied.
|
||||
*
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.calls
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnostic
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.*
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.KtLifetimeToken
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
import org.jetbrains.kotlin.analysis.api.withValidityAssertion
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
@@ -16,13 +16,13 @@ import org.jetbrains.kotlin.psi.KtExpression
|
||||
/**
|
||||
* Call information at call site.
|
||||
*/
|
||||
public sealed class KtCallInfo : ValidityTokenOwner
|
||||
public sealed class KtCallInfo : KtLifetimeOwner
|
||||
|
||||
/**
|
||||
* Successfully resolved call.
|
||||
*/
|
||||
public class KtSuccessCallInfo(private val _call: KtCall) : KtCallInfo() {
|
||||
override val token: ValidityToken
|
||||
override val token: KtLifetimeToken
|
||||
get() = _call.token
|
||||
public val call: KtCall get() = withValidityAssertion { _call }
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class KtSuccessCallInfo(private val _call: KtCall) : KtCallInfo() {
|
||||
public class KtErrorCallInfo(
|
||||
private val _candidateCalls: List<KtCall>,
|
||||
private val _diagnostic: KtDiagnostic,
|
||||
override val token: ValidityToken
|
||||
override val token: KtLifetimeToken
|
||||
) : KtCallInfo() {
|
||||
public val candidateCalls: List<KtCall> get() = withValidityAssertion { _candidateCalls }
|
||||
public val diagnostic: KtDiagnostic get() = withValidityAssertion { _diagnostic }
|
||||
@@ -73,8 +73,8 @@ public fun KtCallInfo.successfulConstructorCallOrNull(): KtFunctionCall<KtConstr
|
||||
public sealed class KtCallCandidateInfo(
|
||||
private val _candidate: KtCall,
|
||||
private val _isInBestCandidates: Boolean,
|
||||
) : ValidityTokenOwner {
|
||||
override val token: ValidityToken
|
||||
) : KtLifetimeOwner {
|
||||
override val token: KtLifetimeToken
|
||||
get() = _candidate.token
|
||||
public val candidate: KtCall get() = withValidityAssertion { _candidate }
|
||||
|
||||
@@ -112,7 +112,7 @@ public class KtInapplicableCallCandidateInfo(
|
||||
/**
|
||||
* A call to a function, a simple/compound access to a property, or a simple/compound access through `get` and `set` convention.
|
||||
*/
|
||||
public sealed class KtCall : ValidityTokenOwner
|
||||
public sealed class KtCall : KtLifetimeOwner
|
||||
|
||||
/**
|
||||
* A callable symbol partially applied with receivers and type arguments. Essentially, this is a call that misses some information. For
|
||||
@@ -123,9 +123,9 @@ public class KtPartiallyAppliedSymbol<out S : KtCallableSymbol, out C : KtSignat
|
||||
private val _signature: C,
|
||||
private val _dispatchReceiver: KtReceiverValue?,
|
||||
private val _extensionReceiver: KtReceiverValue?,
|
||||
) : ValidityTokenOwner {
|
||||
) : KtLifetimeOwner {
|
||||
|
||||
override val token: ValidityToken get() = _signature.token
|
||||
override val token: KtLifetimeToken get() = _signature.token
|
||||
|
||||
/**
|
||||
* The function or variable (property) declaration.
|
||||
@@ -154,7 +154,7 @@ public val <S : KtCallableSymbol, C : KtSignature<S>> KtPartiallyAppliedSymbol<S
|
||||
* ```
|
||||
*/
|
||||
public class KtCheckNotNullCall(
|
||||
override val token: ValidityToken,
|
||||
override val token: KtLifetimeToken,
|
||||
private val _baseExpression: KtExpression,
|
||||
) : KtCall() {
|
||||
public val baseExpression: KtExpression get() = withValidityAssertion { _baseExpression }
|
||||
@@ -190,7 +190,7 @@ public class KtSimpleFunctionCall(
|
||||
argumentMapping: LinkedHashMap<KtExpression, KtVariableLikeSignature<KtValueParameterSymbol>>,
|
||||
private val _isImplicitInvoke: Boolean,
|
||||
) : KtFunctionCall<KtFunctionLikeSymbol>(argumentMapping) {
|
||||
override val token: ValidityToken get() = _partiallyAppliedSymbol.token
|
||||
override val token: KtLifetimeToken get() = _partiallyAppliedSymbol.token
|
||||
|
||||
/**
|
||||
* The function and receivers for this call.
|
||||
@@ -215,7 +215,7 @@ public class KtAnnotationCall(
|
||||
private val _partiallyAppliedSymbol: KtPartiallyAppliedFunctionSymbol<KtConstructorSymbol>,
|
||||
argumentMapping: LinkedHashMap<KtExpression, KtVariableLikeSignature<KtValueParameterSymbol>>,
|
||||
) : KtFunctionCall<KtConstructorSymbol>(argumentMapping) {
|
||||
override val token: ValidityToken get() = _partiallyAppliedSymbol.token
|
||||
override val token: KtLifetimeToken get() = _partiallyAppliedSymbol.token
|
||||
|
||||
/**
|
||||
* The function and receivers for this call.
|
||||
@@ -239,7 +239,7 @@ public class KtDelegatedConstructorCall(
|
||||
private val _kind: Kind,
|
||||
argumentMapping: LinkedHashMap<KtExpression, KtVariableLikeSignature<KtValueParameterSymbol>>,
|
||||
) : KtFunctionCall<KtConstructorSymbol>(argumentMapping) {
|
||||
override val token: ValidityToken get() = _partiallyAppliedSymbol.token
|
||||
override val token: KtLifetimeToken get() = _partiallyAppliedSymbol.token
|
||||
|
||||
/**
|
||||
* The function and receivers for this call.
|
||||
@@ -266,7 +266,7 @@ public class KtSimpleVariableAccessCall(
|
||||
private val _simpleAccess: KtSimpleVariableAccess
|
||||
) : KtVariableAccessCall() {
|
||||
|
||||
override val token: ValidityToken get() = _partiallyAppliedSymbol.token
|
||||
override val token: KtLifetimeToken get() = _partiallyAppliedSymbol.token
|
||||
|
||||
override val partiallyAppliedSymbol: KtPartiallyAppliedVariableSymbol<KtVariableLikeSymbol> get() = withValidityAssertion { _partiallyAppliedSymbol }
|
||||
|
||||
@@ -337,7 +337,7 @@ public class KtCompoundVariableAccessCall(
|
||||
private val _partiallyAppliedSymbol: KtPartiallyAppliedVariableSymbol<KtVariableLikeSymbol>,
|
||||
private val _compoundAccess: KtCompoundAccess
|
||||
) : KtVariableAccessCall(), KtCompoundAccessCall {
|
||||
override val token: ValidityToken
|
||||
override val token: KtLifetimeToken
|
||||
get() = _partiallyAppliedSymbol.token
|
||||
override val partiallyAppliedSymbol: KtPartiallyAppliedVariableSymbol<KtVariableLikeSymbol> get() = withValidityAssertion { _partiallyAppliedSymbol }
|
||||
override val compoundAccess: KtCompoundAccess get() = withValidityAssertion { _compoundAccess }
|
||||
@@ -387,7 +387,7 @@ public class KtCompoundArrayAccessCall(
|
||||
|
||||
) : KtCall(), KtCompoundAccessCall {
|
||||
|
||||
override val token: ValidityToken get() = _compoundAccess.token
|
||||
override val token: KtLifetimeToken get() = _compoundAccess.token
|
||||
|
||||
override val compoundAccess: KtCompoundAccess get() = withValidityAssertion { _compoundAccess }
|
||||
|
||||
@@ -409,9 +409,9 @@ public class KtCompoundArrayAccessCall(
|
||||
* The type of access to a variable or using the array access convention.
|
||||
*/
|
||||
public sealed class KtCompoundAccess(private val _operationPartiallyAppliedSymbol: KtPartiallyAppliedFunctionSymbol<KtFunctionSymbol>) :
|
||||
ValidityTokenOwner {
|
||||
KtLifetimeOwner {
|
||||
|
||||
override val token: ValidityToken
|
||||
override val token: KtLifetimeToken
|
||||
get() = _operationPartiallyAppliedSymbol.token
|
||||
|
||||
/**
|
||||
@@ -461,7 +461,7 @@ public sealed class KtCompoundAccess(private val _operationPartiallyAppliedSymbo
|
||||
/**
|
||||
* A receiver value of a call.
|
||||
*/
|
||||
public sealed class KtReceiverValue : ValidityTokenOwner
|
||||
public sealed class KtReceiverValue : KtLifetimeOwner
|
||||
|
||||
/**
|
||||
* An explicit expression receiver. For example
|
||||
@@ -472,7 +472,7 @@ public sealed class KtReceiverValue : ValidityTokenOwner
|
||||
public class KtExplicitReceiverValue(
|
||||
private val _expression: KtExpression,
|
||||
private val _isSafeNavigation: Boolean,
|
||||
override val token: ValidityToken
|
||||
override val token: KtLifetimeToken
|
||||
) : KtReceiverValue() {
|
||||
public val expression: KtExpression get() = withValidityAssertion { _expression }
|
||||
|
||||
@@ -504,7 +504,7 @@ public class KtExplicitReceiverValue(
|
||||
* ```
|
||||
*/
|
||||
public class KtImplicitReceiverValue(private val _symbol: KtSymbol) : KtReceiverValue() {
|
||||
override val token: ValidityToken get() = _symbol.token
|
||||
override val token: KtLifetimeToken get() = _symbol.token
|
||||
public val symbol: KtSymbol get() = withValidityAssertion { _symbol }
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ public class KtImplicitReceiverValue(private val _symbol: KtSymbol) : KtReceiver
|
||||
* ```
|
||||
*/
|
||||
public class KtSmartCastedReceiverValue(private val _original: KtReceiverValue, private val _smartCastType: KtType) : KtReceiverValue() {
|
||||
override val token: ValidityToken
|
||||
override val token: KtLifetimeToken
|
||||
get() = _original.token
|
||||
public val original: KtReceiverValue get() = withValidityAssertion { _original }
|
||||
public val smartCastType: KtType get() = withValidityAssertion { _smartCastType }
|
||||
|
||||
+2
-2
@@ -6,9 +6,9 @@
|
||||
package org.jetbrains.kotlin.analysis.api.components
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
|
||||
public abstract class KtAnalysisSessionComponent : ValidityTokenOwner {
|
||||
public abstract class KtAnalysisSessionComponent : KtLifetimeOwner {
|
||||
protected abstract val analysisSession: KtAnalysisSession
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.components
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtImportDirective
|
||||
|
||||
public abstract class KtImportOptimizer : ValidityTokenOwner {
|
||||
public abstract class KtImportOptimizer : KtLifetimeOwner {
|
||||
public abstract fun analyseImports(file: KtFile): KtImportOptimizerResult
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -5,14 +5,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.components
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
import org.jetbrains.kotlin.analysis.api.scopes.*
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtFileSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtPackageSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolWithDeclarations
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolWithMembers
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.KtLifetimeToken
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -77,7 +76,7 @@ public interface KtScopeProviderMixIn : KtAnalysisSessionMixIn {
|
||||
public data class KtScopeContext(val scopes: KtScope, val implicitReceivers: List<KtImplicitReceiver>)
|
||||
|
||||
public class KtImplicitReceiver(
|
||||
override val token: ValidityToken,
|
||||
override val token: KtLifetimeToken,
|
||||
public val type: KtType,
|
||||
public val ownerSymbol: KtSymbol
|
||||
) : ValidityTokenOwner
|
||||
) : KtLifetimeOwner
|
||||
|
||||
+6
-6
@@ -5,8 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.components
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.KtLifetimeToken
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
import org.jetbrains.kotlin.analysis.api.withValidityAssertion
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
@@ -42,8 +42,8 @@ public interface KtSmartCastProviderMixIn : KtAnalysisSessionMixIn {
|
||||
public data class KtSmartCastInfo(
|
||||
private val _smartCastType: KtType,
|
||||
private val _isStable: Boolean,
|
||||
override val token: ValidityToken
|
||||
) : ValidityTokenOwner {
|
||||
override val token: KtLifetimeToken
|
||||
) : KtLifetimeOwner {
|
||||
public val isStable: Boolean get() = withValidityAssertion { _isStable }
|
||||
public val smartCastType: KtType get() = withValidityAssertion { _smartCastType }
|
||||
}
|
||||
@@ -51,8 +51,8 @@ public data class KtSmartCastInfo(
|
||||
public data class KtImplicitReceiverSmartCast(
|
||||
private val _type: KtType,
|
||||
private val _kind: KtImplicitReceiverSmartCastKind,
|
||||
override val token: ValidityToken
|
||||
) : ValidityTokenOwner {
|
||||
override val token: KtLifetimeToken
|
||||
) : KtLifetimeOwner {
|
||||
public val type: KtType get() = withValidityAssertion { _type }
|
||||
public val kind: KtImplicitReceiverSmartCastKind get() = withValidityAssertion { _kind }
|
||||
}
|
||||
|
||||
+2
-3
@@ -5,10 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.components
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtNamedClassOrObjectSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtPossibleMemberSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtFlexibleType
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtTypeNullability
|
||||
@@ -139,7 +138,7 @@ public interface KtTypeProviderMixIn : KtAnalysisSessionMixIn {
|
||||
}
|
||||
|
||||
@Suppress("PropertyName")
|
||||
public abstract class KtBuiltinTypes : ValidityTokenOwner {
|
||||
public abstract class KtBuiltinTypes : KtLifetimeOwner {
|
||||
public abstract val INT: KtType
|
||||
public abstract val LONG: KtType
|
||||
public abstract val SHORT: KtType
|
||||
|
||||
+4
-4
@@ -8,11 +8,11 @@ package org.jetbrains.kotlin.analysis.api.diagnostics
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.KtLifetimeToken
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
public interface KtDiagnostic : ValidityTokenOwner {
|
||||
public interface KtDiagnostic : KtLifetimeOwner {
|
||||
public val severity: Severity
|
||||
public val factoryName: String?
|
||||
public val defaultMessage: String
|
||||
@@ -27,7 +27,7 @@ public interface KtDiagnosticWithPsi<out PSI : PsiElement> : KtDiagnostic {
|
||||
public class KtNonBoundToPsiErrorDiagnostic(
|
||||
override val factoryName: String?,
|
||||
override val defaultMessage: String,
|
||||
override val token: ValidityToken,
|
||||
override val token: KtLifetimeToken,
|
||||
) : KtDiagnostic {
|
||||
override val severity: Severity get() = Severity.ERROR
|
||||
}
|
||||
|
||||
@@ -5,16 +5,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.scopes
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.*
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolWithDeclarations
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolWithMembers
|
||||
import org.jetbrains.kotlin.analysis.api.withValidityAssertion
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
|
||||
public interface KtScope : ValidityTokenOwner {
|
||||
public interface KtScope : KtLifetimeOwner {
|
||||
/**
|
||||
* Returns a **subset** of names which current scope may contain.
|
||||
* In other words `ALL_NAMES(scope)` is a subset of `scope.getAllNames()`
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.symbols
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplication
|
||||
import org.jetbrains.kotlin.analysis.api.annotations.KtConstantAnnotationValue
|
||||
import org.jetbrains.kotlin.analysis.api.annotations.annotationsByClassId
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.KtLifetimeToken
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtSubstitutor
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
import org.jetbrains.kotlin.analysis.api.withValidityAssertion
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
*
|
||||
* Equality of [KtSignature] is derived from its content.
|
||||
*/
|
||||
public sealed class KtSignature<out S : KtCallableSymbol> : ValidityTokenOwner {
|
||||
public sealed class KtSignature<out S : KtCallableSymbol> : KtLifetimeOwner {
|
||||
/**
|
||||
* The original symbol for this signature.
|
||||
*/
|
||||
@@ -58,7 +58,7 @@ public data class KtFunctionLikeSignature<out S : KtFunctionLikeSymbol>(
|
||||
private val _receiverType: KtType?,
|
||||
private val _valueParameters: List<KtVariableLikeSignature<KtValueParameterSymbol>>,
|
||||
) : KtSignature<S>() {
|
||||
override val token: ValidityToken
|
||||
override val token: KtLifetimeToken
|
||||
get() = _symbol.token
|
||||
override val symbol: S
|
||||
get() = withValidityAssertion { _symbol }
|
||||
@@ -82,7 +82,7 @@ public data class KtVariableLikeSignature<out S : KtVariableLikeSymbol>(
|
||||
private val _returnType: KtType,
|
||||
private val _receiverType: KtType?,
|
||||
) : KtSignature<S>() {
|
||||
override val token: ValidityToken
|
||||
override val token: KtLifetimeToken
|
||||
get() = _symbol.token
|
||||
override val symbol: S
|
||||
get() = withValidityAssertion { _symbol }
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
package org.jetbrains.kotlin.analysis.api.symbols
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
||||
|
||||
public interface KtSymbol : ValidityTokenOwner {
|
||||
public interface KtSymbol : KtLifetimeOwner {
|
||||
public val origin: KtSymbolOrigin
|
||||
|
||||
/**
|
||||
|
||||
+6
-6
@@ -9,7 +9,7 @@ import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.analysis.providers.createProjectWideOutOfBlockModificationTracker
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
public class AlwaysAccessibleValidityToken(project: Project) : ValidityToken() {
|
||||
public class KtAlwaysAccessibleLifetimeToken(project: Project) : KtLifetimeToken() {
|
||||
private val modificationTracker = project.createProjectWideOutOfBlockModificationTracker()
|
||||
private val onCreatedTimeStamp = modificationTracker.modificationCount
|
||||
|
||||
@@ -30,12 +30,12 @@ public class AlwaysAccessibleValidityToken(project: Project) : ValidityToken() {
|
||||
error("Getting inaccessibility reason for validity token when it is accessible")
|
||||
}
|
||||
|
||||
override val factory: ValidityTokenFactory = AlwaysAccessibleValidityTokenFactory
|
||||
override val factory: KtLifetimeTokenFactory = KtAlwaysAccessibleLifetimeTokenFactory
|
||||
}
|
||||
|
||||
public object AlwaysAccessibleValidityTokenFactory : ValidityTokenFactory() {
|
||||
override val identifier: KClass<out ValidityToken> = AlwaysAccessibleValidityToken::class
|
||||
public object KtAlwaysAccessibleLifetimeTokenFactory : KtLifetimeTokenFactory() {
|
||||
override val identifier: KClass<out KtLifetimeToken> = KtAlwaysAccessibleLifetimeToken::class
|
||||
|
||||
override fun create(project: Project): ValidityToken =
|
||||
AlwaysAccessibleValidityToken(project)
|
||||
override fun create(project: Project): KtLifetimeToken =
|
||||
KtAlwaysAccessibleLifetimeToken(project)
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.tokens
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
public abstract class KtLifetimeToken {
|
||||
public abstract fun isValid(): Boolean
|
||||
public abstract fun getInvalidationReason(): String
|
||||
|
||||
public abstract fun isAccessible(): Boolean
|
||||
public abstract fun getInaccessibilityReason(): String
|
||||
|
||||
public abstract val factory: KtLifetimeTokenFactory
|
||||
}
|
||||
|
||||
public abstract class KtLifetimeTokenFactory {
|
||||
public abstract val identifier: KClass<out KtLifetimeToken>
|
||||
public abstract fun create(project: Project): KtLifetimeToken
|
||||
|
||||
public open fun beforeEnteringAnalysisContext() {}
|
||||
public open fun afterLeavingAnalysisContext() {}
|
||||
}
|
||||
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun KtLifetimeToken.assertIsValidAndAccessible() {
|
||||
if (!isValid()) {
|
||||
throw KtInvalidLifetimeOwnerAccessException("Access to invalid $this: ${getInvalidationReason()}")
|
||||
}
|
||||
if (!isAccessible()) {
|
||||
throw KtInaccessibleLifetimeOwnerAccessException("$this is inaccessible: ${getInaccessibilityReason()}")
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class KtIllegalLifetimeOwnerAccessException : IllegalStateException()
|
||||
|
||||
public class KtInvalidLifetimeOwnerAccessException(override val message: String) : KtIllegalLifetimeOwnerAccessException()
|
||||
public class KtInaccessibleLifetimeOwnerAccessException(override val message: String) : KtIllegalLifetimeOwnerAccessException()
|
||||
|
||||
+11
-11
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.analysis.providers.createProjectWideOutOfBlockModifi
|
||||
import org.jetbrains.kotlin.analysis.api.*
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
public class ReadActionConfinementValidityToken(project: Project) : ValidityToken() {
|
||||
public class KtReadActionConfinementLifetimeToken(project: Project) : KtLifetimeToken() {
|
||||
private val modificationTracker = project.createProjectWideOutOfBlockModificationTracker()
|
||||
private val onCreatedTimeStamp = modificationTracker.modificationCount
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ReadActionConfinementValidityToken(project: Project) : ValidityToke
|
||||
if (application.isDispatchThread && !allowOnEdt.get()) return false
|
||||
if (ForbidKtResolve.resovleIsForbidenInActionWithName.get() != null) return false
|
||||
if (!application.isReadAccessAllowed) return false
|
||||
if (!ReadActionConfinementValidityTokenFactory.isInsideAnalysisContext()) return false
|
||||
if (!ReadActionConfinementValidityTokenFactoryFactory.isInsideAnalysisContext()) return false
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ReadActionConfinementValidityToken(project: Project) : ValidityToke
|
||||
ForbidKtResolve.resovleIsForbidenInActionWithName.get()?.let { actionName ->
|
||||
return "Resolve is forbidden in $actionName"
|
||||
}
|
||||
if (!ReadActionConfinementValidityTokenFactory.isInsideAnalysisContext()) return "Called outside analyse method"
|
||||
if (!ReadActionConfinementValidityTokenFactoryFactory.isInsideAnalysisContext()) return "Called outside analyse method"
|
||||
error("Getting inaccessibility reason for validity token when it is accessible")
|
||||
}
|
||||
|
||||
@@ -53,13 +53,13 @@ public class ReadActionConfinementValidityToken(project: Project) : ValidityToke
|
||||
public val allowOnEdt: ThreadLocal<Boolean> = ThreadLocal.withInitial { false }
|
||||
}
|
||||
|
||||
public override val factory: ValidityTokenFactory = ReadActionConfinementValidityTokenFactory
|
||||
public override val factory: KtLifetimeTokenFactory = ReadActionConfinementValidityTokenFactoryFactory
|
||||
}
|
||||
|
||||
public object ReadActionConfinementValidityTokenFactory : ValidityTokenFactory() {
|
||||
override val identifier: KClass<out ValidityToken> = ReadActionConfinementValidityToken::class
|
||||
public object ReadActionConfinementValidityTokenFactoryFactory : KtLifetimeTokenFactory() {
|
||||
override val identifier: KClass<out KtLifetimeToken> = KtReadActionConfinementLifetimeToken::class
|
||||
|
||||
override fun create(project: Project): ValidityToken = ReadActionConfinementValidityToken(project)
|
||||
override fun create(project: Project): KtLifetimeToken = KtReadActionConfinementLifetimeToken(project)
|
||||
|
||||
override fun beforeEnteringAnalysisContext() {
|
||||
currentAnalysisContextEnteringCount.set(currentAnalysisContextEnteringCount.get() + 1)
|
||||
@@ -82,15 +82,15 @@ public annotation class HackToForceAllowRunningAnalyzeOnEDT
|
||||
* All frontend related work should not be allowed to be ran from EDT thread. Only use it as a temporary solution.
|
||||
*
|
||||
* @see KtAnalysisSession
|
||||
* @see ReadActionConfinementValidityToken
|
||||
* @see KtReadActionConfinementLifetimeToken
|
||||
*/
|
||||
@HackToForceAllowRunningAnalyzeOnEDT
|
||||
public inline fun <T> hackyAllowRunningOnEdt(action: () -> T): T {
|
||||
if (ReadActionConfinementValidityToken.allowOnEdt.get()) return action()
|
||||
ReadActionConfinementValidityToken.allowOnEdt.set(true)
|
||||
if (KtReadActionConfinementLifetimeToken.allowOnEdt.get()) return action()
|
||||
KtReadActionConfinementLifetimeToken.allowOnEdt.set(true)
|
||||
try {
|
||||
return action()
|
||||
} finally {
|
||||
ReadActionConfinementValidityToken.allowOnEdt.set(false)
|
||||
KtReadActionConfinementLifetimeToken.allowOnEdt.set(false)
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.tokens
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
public abstract class ValidityToken {
|
||||
public abstract fun isValid(): Boolean
|
||||
public abstract fun getInvalidationReason(): String
|
||||
|
||||
public abstract fun isAccessible(): Boolean
|
||||
public abstract fun getInaccessibilityReason(): String
|
||||
|
||||
public abstract val factory: ValidityTokenFactory
|
||||
}
|
||||
|
||||
public abstract class ValidityTokenFactory {
|
||||
public abstract val identifier: KClass<out ValidityToken>
|
||||
public abstract fun create(project: Project): ValidityToken
|
||||
|
||||
public open fun beforeEnteringAnalysisContext() {}
|
||||
public open fun afterLeavingAnalysisContext() {}
|
||||
}
|
||||
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun ValidityToken.assertIsValidAndAccessible() {
|
||||
if (!isValid()) {
|
||||
throw InvalidEntityAccessException("Access to invalid $this: ${getInvalidationReason()}")
|
||||
}
|
||||
if (!isAccessible()) {
|
||||
throw InaccessibleEntityAccessException("$this is inaccessible: ${getInaccessibilityReason()}")
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BadEntityAccessException() : IllegalStateException()
|
||||
|
||||
public class InvalidEntityAccessException(override val message: String) : BadEntityAccessException()
|
||||
public class InaccessibleEntityAccessException(override val message: String) : BadEntityAccessException()
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.types
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.KtLifetimeToken
|
||||
import org.jetbrains.kotlin.analysis.api.withValidityAssertion
|
||||
|
||||
|
||||
public interface KtSubstitutor : ValidityTokenOwner {
|
||||
public interface KtSubstitutor : KtLifetimeOwner {
|
||||
public fun substituteOrSelf(type: KtType): KtType = substituteOrNull(type) ?: type
|
||||
public fun substituteOrNull(type: KtType): KtType?
|
||||
|
||||
public class Empty(override val token: ValidityToken) : KtSubstitutor {
|
||||
public class Empty(override val token: KtLifetimeToken) : KtSubstitutor {
|
||||
override fun substituteOrNull(type: KtType): KtType = withValidityAssertion { type }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,14 @@
|
||||
package org.jetbrains.kotlin.analysis.api.types
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.KtTypeArgument
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.KtLifetimeOwner
|
||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotated
|
||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationsList
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtClassLikeSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
public sealed interface KtType : ValidityTokenOwner, KtAnnotated {
|
||||
public sealed interface KtType : KtLifetimeOwner, KtAnnotated {
|
||||
public val nullability: KtTypeNullability
|
||||
public fun asStringForDebugging(): String
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user