FIR IDE: enable explicit API mode in idea-frontend-fir module

This commit is contained in:
Ilya Kirillov
2021-07-06 20:58:43 +02:00
committed by TeamCityServer
parent 51576c70b6
commit 30d0fea003
67 changed files with 593 additions and 589 deletions
+4
View File
@@ -15,6 +15,10 @@ dependencies {
compile(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) }
}
kotlin {
explicitApi()
}
sourceSets {
"main" { projectDefault() }
"test" { projectDefault() }
@@ -5,14 +5,12 @@
package org.jetbrains.kotlin.idea.frontend.api
import kotlin.reflect.KProperty1
@RequiresOptIn
annotation class ForbidKtResolveInternals
public annotation class ForbidKtResolveInternals
object ForbidKtResolve {
public object ForbidKtResolve {
@OptIn(ForbidKtResolveInternals::class)
inline fun <R> forbidResolveIn(actionName: String, action: () -> R): R {
public inline fun <R> forbidResolveIn(actionName: String, action: () -> R): R {
if (resovleIsForbidenInActionWithName.get() != null) return action()
resovleIsForbidenInActionWithName.set(actionName)
return try {
@@ -23,5 +21,5 @@ object ForbidKtResolve {
}
@ForbidKtResolveInternals
val resovleIsForbidenInActionWithName: ThreadLocal<String?> = ThreadLocal.withInitial { null }
public val resovleIsForbidenInActionWithName: ThreadLocal<String?> = ThreadLocal.withInitial { null }
}
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.idea.frontend.api
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
data class ImplicitReceiverSmartCast(val type: KtType, val kind: ImplicitReceiverSmartcastKind)
public data class ImplicitReceiverSmartCast(val type: KtType, val kind: ImplicitReceiverSmartcastKind)
enum class ImplicitReceiverSmartcastKind {
public enum class ImplicitReceiverSmartcastKind {
DISPATCH, EXTENSION
}
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.psi.*
*
* To create analysis session consider using [analyse]
*/
abstract class KtAnalysisSession(final override val token: ValidityToken) : ValidityTokenOwner,
public abstract class KtAnalysisSession(final override val token: ValidityToken) : ValidityTokenOwner,
KtSmartCastProviderMixIn,
KtCallResolverMixIn,
KtDiagnosticProviderMixIn,
@@ -50,7 +50,7 @@ abstract class KtAnalysisSession(final override val token: ValidityToken) : Vali
override val analysisSession: KtAnalysisSession get() = this
abstract fun createContextDependentCopy(originalKtFile: KtFile, elementToReanalyze: KtElement): KtAnalysisSession
public abstract fun createContextDependentCopy(originalKtFile: KtFile, elementToReanalyze: KtElement): KtAnalysisSession
internal val smartCastProvider: KtSmartCastProvider get() = smartCastProviderImpl
protected abstract val smartCastProviderImpl: KtSmartCastProvider
@@ -112,6 +112,8 @@ abstract class KtAnalysisSession(final override val token: ValidityToken) : Vali
internal val inheritorsProvider: KtInheritorsProvider get() = inheritorsProviderImpl
protected abstract val inheritorsProviderImpl: KtInheritorsProvider
@PublishedApi internal val typesCreator: KtTypeCreator get() = typesCreatorImpl
@PublishedApi
internal val typesCreator: KtTypeCreator
get() = typesCreatorImpl
protected abstract val typesCreatorImpl: KtTypeCreator
}
@@ -20,26 +20,26 @@ import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtFile
@RequiresOptIn("To use analysis session, consider using analyze/analyzeWithReadAction/analyseInModalWindow methods")
annotation class InvalidWayOfUsingAnalysisSession
public annotation class InvalidWayOfUsingAnalysisSession
@RequiresOptIn
annotation class KtAnalysisSessionProviderInternals
public annotation class KtAnalysisSessionProviderInternals
/**
* Provides [KtAnalysisSession] by [contextElement]
* Should not be used directly, consider using [analyse]/[analyseWithReadAction]/[analyseInModalWindow] instead
*/
@InvalidWayOfUsingAnalysisSession
abstract class KtAnalysisSessionProvider : Disposable {
public abstract class KtAnalysisSessionProvider : Disposable {
@Suppress("LeakingThis")
@OptIn(KtInternalApiMarker::class)
val noWriteActionInAnalyseCallChecker = NoWriteActionInAnalyseCallChecker(this)
public val noWriteActionInAnalyseCallChecker: NoWriteActionInAnalyseCallChecker = NoWriteActionInAnalyseCallChecker(this)
@InvalidWayOfUsingAnalysisSession
abstract fun getAnalysisSession(contextElement: KtElement, factory: ValidityTokenFactory): KtAnalysisSession
public abstract fun getAnalysisSession(contextElement: KtElement, factory: ValidityTokenFactory): KtAnalysisSession
@InvalidWayOfUsingAnalysisSession
inline fun <R> analyseInDependedAnalysisSession(
public inline fun <R> analyseInDependedAnalysisSession(
originalFile: KtFile,
elementToReanalyze: KtElement,
action: KtAnalysisSession.() -> R
@@ -50,12 +50,12 @@ abstract class KtAnalysisSessionProvider : Disposable {
}
@InvalidWayOfUsingAnalysisSession
inline fun <R> analyse(contextElement: KtElement, tokenFactory: ValidityTokenFactory, action: KtAnalysisSession.() -> R): R =
public inline fun <R> analyse(contextElement: KtElement, tokenFactory: ValidityTokenFactory, action: KtAnalysisSession.() -> R): R =
analyse(getAnalysisSession(contextElement, tokenFactory), tokenFactory, action)
@OptIn(KtAnalysisSessionProviderInternals::class, KtInternalApiMarker::class)
@InvalidWayOfUsingAnalysisSession
inline fun <R> analyse(analysisSession: KtAnalysisSession, factory: ValidityTokenFactory, action: KtAnalysisSession.() -> R): R {
public inline fun <R> analyse(analysisSession: KtAnalysisSession, factory: ValidityTokenFactory, action: KtAnalysisSession.() -> R): R {
noWriteActionInAnalyseCallChecker.beforeEnteringAnalysisContext()
factory.beforeEnteringAnalysisContext()
return try {
@@ -67,12 +67,12 @@ abstract class KtAnalysisSessionProvider : Disposable {
}
@TestOnly
abstract fun clearCaches()
public abstract fun clearCaches()
override fun dispose() {}
companion object {
fun getInstance(project: Project): KtAnalysisSessionProvider =
public companion object {
public fun getInstance(project: Project): KtAnalysisSessionProvider =
ServiceManager.getService(project, KtAnalysisSessionProvider::class.java)
}
}
@@ -90,12 +90,12 @@ abstract class KtAnalysisSessionProvider : Disposable {
* @see analyseWithReadAction
*/
@OptIn(InvalidWayOfUsingAnalysisSession::class)
inline fun <R> analyse(contextElement: KtElement, action: KtAnalysisSession.() -> R): R =
public inline fun <R> analyse(contextElement: KtElement, action: KtAnalysisSession.() -> R): R =
KtAnalysisSessionProvider.getInstance(contextElement.project)
.analyse(contextElement, ReadActionConfinementValidityTokenFactory, action)
@OptIn(InvalidWayOfUsingAnalysisSession::class)
inline fun <R> analyseWithCustomToken(
public inline fun <R> analyseWithCustomToken(
contextElement: KtElement,
tokenFactory: ValidityTokenFactory,
action: KtAnalysisSession.() -> R
@@ -107,14 +107,14 @@ inline fun <R> analyseWithCustomToken(
* UAST-specific version of [analyse] that executes the given [action] in [KtAnalysisSession] context
*/
@OptIn(InvalidWayOfUsingAnalysisSession::class)
inline fun <R> analyseForUast(
public inline fun <R> analyseForUast(
contextElement: KtElement,
action: KtAnalysisSession.() -> R
): R =
analyseWithCustomToken(contextElement, AlwaysAccessibleValidityTokenFactory, action)
@OptIn(InvalidWayOfUsingAnalysisSession::class)
inline fun <R> analyseInDependedAnalysisSession(
public inline fun <R> analyseInDependedAnalysisSession(
originalFile: KtFile,
elementToReanalyze: KtElement,
action: KtAnalysisSession.() -> R
@@ -134,7 +134,7 @@ inline fun <R> analyseInDependedAnalysisSession(
* @see KtAnalysisSession
* @see analyse
*/
inline fun <R> analyseWithReadAction(
public inline fun <R> analyseWithReadAction(
contextElement: KtElement,
crossinline action: KtAnalysisSession.() -> R
): R = ApplicationManager.getApplication().runReadAction(Computable {
@@ -148,7 +148,7 @@ inline fun <R> analyseWithReadAction(
* Should be executed from EDT only
* If you want to analyse something from non-EDT thread, consider using [analyse]/[analyseWithReadAction]
*/
inline fun <R> analyseInModalWindow(
public inline fun <R> analyseInModalWindow(
contextElement: KtElement,
windowTitle: String,
crossinline action: KtAnalysisSession.() -> R
@@ -8,6 +8,6 @@ package org.jetbrains.kotlin.idea.frontend.api
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol
import org.jetbrains.kotlin.idea.references.KtReference
interface KtSymbolBasedReference : KtReference {
fun KtAnalysisSession.resolveToSymbols(): Collection<KtSymbol>
public interface KtSymbolBasedReference : KtReference {
public fun KtAnalysisSession.resolveToSymbols(): Collection<KtSymbol>
}
@@ -9,13 +9,13 @@ import org.jetbrains.kotlin.idea.frontend.api.tokens.ValidityToken
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
import org.jetbrains.kotlin.types.Variance
sealed class KtTypeArgument : ValidityTokenOwner
public sealed class KtTypeArgument : ValidityTokenOwner
class KtStarProjectionTypeArgument(override val token: ValidityToken) : KtTypeArgument()
public class KtStarProjectionTypeArgument(override val token: ValidityToken) : KtTypeArgument()
class KtTypeArgumentWithVariance(
val type: KtType,
val variance: Variance,
public class KtTypeArgumentWithVariance(
public val type: KtType,
public val variance: Variance,
override val token: ValidityToken,
) : KtTypeArgument()
@@ -10,7 +10,7 @@ import com.intellij.openapi.application.ApplicationListener
import com.intellij.openapi.application.ApplicationManager
@KtInternalApiMarker
class NoWriteActionInAnalyseCallChecker(parentDisposable: Disposable) {
public class NoWriteActionInAnalyseCallChecker(parentDisposable: Disposable) {
init {
val listener = object : ApplicationListener {
override fun writeActionFinished(action: Any) {
@@ -22,17 +22,17 @@ class NoWriteActionInAnalyseCallChecker(parentDisposable: Disposable) {
ApplicationManager.getApplication().addApplicationListener(listener, parentDisposable)
}
fun beforeEnteringAnalysisContext() {
public fun beforeEnteringAnalysisContext() {
currentAnalysisContextEnteringCount.set(currentAnalysisContextEnteringCount.get() + 1)
}
fun afterLeavingAnalysisContext() {
public fun afterLeavingAnalysisContext() {
currentAnalysisContextEnteringCount.set(currentAnalysisContextEnteringCount.get() - 1)
}
private val currentAnalysisContextEnteringCount = ThreadLocal.withInitial { 0 }
}
class WriteActionStartInsideAnalysisContextException : IllegalStateException(
public class WriteActionStartInsideAnalysisContextException : IllegalStateException(
"write action should be never executed inside analysis context (e,g. analyse call)"
)
@@ -8,18 +8,18 @@ package org.jetbrains.kotlin.idea.frontend.api
import org.jetbrains.kotlin.idea.frontend.api.tokens.ValidityToken
import org.jetbrains.kotlin.idea.frontend.api.tokens.assertIsValidAndAccessible
interface ValidityTokenOwner {
val token: ValidityToken
public interface ValidityTokenOwner {
public val token: ValidityToken
}
fun ValidityTokenOwner.isValid(): Boolean = token.isValid()
public fun ValidityTokenOwner.isValid(): Boolean = token.isValid()
@Suppress("NOTHING_TO_INLINE")
inline fun ValidityTokenOwner.assertIsValidAndAccessible() {
public inline fun ValidityTokenOwner.assertIsValidAndAccessible() {
token.assertIsValidAndAccessible()
}
inline fun <R> ValidityTokenOwner.withValidityAssertion(action: () -> R): R {
public inline fun <R> ValidityTokenOwner.withValidityAssertion(action: () -> R): R {
assertIsValidAndAccessible()
return action()
}
@@ -6,4 +6,4 @@
package org.jetbrains.kotlin.idea.frontend.api
@RequiresOptIn
annotation class KtInternalApiMarker
public annotation class KtInternalApiMarker
@@ -12,9 +12,9 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtVariableLikeSymbol
/**
* Represents direct or indirect (via invoke) function call from Kotlin code
*/
sealed class KtCall {
abstract val isErrorCall: Boolean
abstract val targetFunction: KtCallTarget
public sealed class KtCall {
public abstract val isErrorCall: Boolean
public abstract val targetFunction: KtCallTarget
}
/**
@@ -24,8 +24,8 @@ sealed class KtCall {
* f() // functional type call
* }
*/
class KtFunctionalTypeVariableCall(
val target: KtVariableLikeSymbol,
public class KtFunctionalTypeVariableCall(
public val target: KtVariableLikeSymbol,
override val targetFunction: KtCallTarget
) : KtCall() {
override val isErrorCall: Boolean get() = false
@@ -34,7 +34,7 @@ class KtFunctionalTypeVariableCall(
/**
* Direct or indirect call of function declared by user
*/
sealed class KtDeclaredFunctionCall : KtCall() {
public sealed class KtDeclaredFunctionCall : KtCall() {
override val isErrorCall: Boolean
get() = targetFunction is KtErrorCallTarget
}
@@ -48,8 +48,8 @@ sealed class KtDeclaredFunctionCall : KtCall() {
*
* fun Int.invoke() {}
*/
class KtVariableWithInvokeFunctionCall(
val target: KtVariableLikeSymbol,
public class KtVariableWithInvokeFunctionCall(
public val target: KtVariableLikeSymbol,
override val targetFunction: KtCallTarget
) : KtDeclaredFunctionCall()
@@ -58,21 +58,21 @@ class KtVariableWithInvokeFunctionCall(
*
* x.toString() // function call
*/
data class KtFunctionCall(override val targetFunction: KtCallTarget) : KtDeclaredFunctionCall()
public data class KtFunctionCall(override val targetFunction: KtCallTarget) : KtDeclaredFunctionCall()
/**
* Represents function(s) in which call was resolved,
* 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
*/
sealed class KtCallTarget {
abstract val candidates: Collection<KtFunctionLikeSymbol>
public sealed class KtCallTarget {
public abstract val candidates: Collection<KtFunctionLikeSymbol>
}
/**
* Success call of [symbol]
*/
class KtSuccessCallTarget(val symbol: KtFunctionLikeSymbol) : KtCallTarget() {
public class KtSuccessCallTarget(public val symbol: KtFunctionLikeSymbol) : KtCallTarget() {
override val candidates: Collection<KtFunctionLikeSymbol>
get() = listOf(symbol)
}
@@ -80,4 +80,7 @@ class KtSuccessCallTarget(val symbol: KtFunctionLikeSymbol) : KtCallTarget() {
/**
* Function all with errors, possible candidates are [candidates]
*/
class KtErrorCallTarget(override val candidates: Collection<KtFunctionLikeSymbol>, val diagnostic: KtDiagnostic) : KtCallTarget()
public class KtErrorCallTarget(
override val candidates: Collection<KtFunctionLikeSymbol>,
public val diagnostic: KtDiagnostic
) : KtCallTarget()
@@ -7,12 +7,12 @@ package org.jetbrains.kotlin.idea.frontend.api.calls
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtFunctionLikeSymbol
fun KtCallTarget.getSuccessCallSymbolOrNull(): KtFunctionLikeSymbol? = when (this) {
public fun KtCallTarget.getSuccessCallSymbolOrNull(): KtFunctionLikeSymbol? = when (this) {
is KtSuccessCallTarget -> symbol
is KtErrorCallTarget -> null
}
inline fun <reified S : KtFunctionLikeSymbol> KtCall.isSuccessCallOf(predicate: (S) -> Boolean): Boolean {
public inline fun <reified S : KtFunctionLikeSymbol> KtCall.isSuccessCallOf(predicate: (S) -> Boolean): Boolean {
if (this !is KtFunctionCall) return false
val symbol = targetFunction.getSuccessCallSymbolOrNull() ?: return false
if (symbol !is S) return false
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.idea.frontend.api.components
import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession
import org.jetbrains.kotlin.idea.frontend.api.ValidityTokenOwner
abstract class KtAnalysisSessionComponent : ValidityTokenOwner {
public abstract class KtAnalysisSessionComponent : ValidityTokenOwner {
protected abstract val analysisSession: KtAnalysisSession
}
@@ -7,6 +7,6 @@ package org.jetbrains.kotlin.idea.frontend.api.components
import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession
interface KtAnalysisSessionMixIn {
val analysisSession: KtAnalysisSession
public interface KtAnalysisSessionMixIn {
public val analysisSession: KtAnalysisSession
}
@@ -10,19 +10,19 @@ import org.jetbrains.kotlin.psi.KtBinaryExpression
import org.jetbrains.kotlin.psi.KtCallExpression
import org.jetbrains.kotlin.psi.KtUnaryExpression
abstract class KtCallResolver : KtAnalysisSessionComponent() {
abstract fun resolveCall(call: KtCallExpression): KtCall?
abstract fun resolveCall(call: KtBinaryExpression): KtCall?
abstract fun resolveCall(call: KtUnaryExpression): KtCall?
public abstract class KtCallResolver : KtAnalysisSessionComponent() {
public abstract fun resolveCall(call: KtCallExpression): KtCall?
public abstract fun resolveCall(call: KtBinaryExpression): KtCall?
public abstract fun resolveCall(call: KtUnaryExpression): KtCall?
}
interface KtCallResolverMixIn : KtAnalysisSessionMixIn {
fun KtCallExpression.resolveCall(): KtCall? =
public interface KtCallResolverMixIn : KtAnalysisSessionMixIn {
public fun KtCallExpression.resolveCall(): KtCall? =
analysisSession.callResolver.resolveCall(this)
fun KtBinaryExpression.resolveCall(): KtCall? =
public fun KtBinaryExpression.resolveCall(): KtCall? =
analysisSession.callResolver.resolveCall(this)
fun KtUnaryExpression.resolveCall(): KtCall? =
public fun KtUnaryExpression.resolveCall(): KtCall? =
analysisSession.callResolver.resolveCall(this)
}
@@ -8,11 +8,11 @@ package org.jetbrains.kotlin.idea.frontend.api.components
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSimpleConstantValue
import org.jetbrains.kotlin.psi.KtExpression
abstract class KtCompileTimeConstantProvider : KtAnalysisSessionComponent() {
abstract fun evaluate(expression: KtExpression): KtSimpleConstantValue<*>?
public abstract class KtCompileTimeConstantProvider : KtAnalysisSessionComponent() {
public abstract fun evaluate(expression: KtExpression): KtSimpleConstantValue<*>?
}
interface KtCompileTimeConstantProviderMixIn : KtAnalysisSessionMixIn {
fun KtExpression.evaluate(): KtSimpleConstantValue<*>? =
public interface KtCompileTimeConstantProviderMixIn : KtAnalysisSessionMixIn {
public fun KtExpression.evaluate(): KtSimpleConstantValue<*>? =
analysisSession.compileTimeConstantProvider.evaluate(this)
}
@@ -10,8 +10,8 @@ import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
abstract class KtCompletionCandidateChecker : KtAnalysisSessionComponent() {
abstract fun checkExtensionFitsCandidate(
public abstract class KtCompletionCandidateChecker : KtAnalysisSessionComponent() {
public abstract fun checkExtensionFitsCandidate(
firSymbolForCandidate: KtCallableSymbol,
originalFile: KtFile,
nameExpression: KtSimpleNameExpression,
@@ -19,14 +19,14 @@ abstract class KtCompletionCandidateChecker : KtAnalysisSessionComponent() {
): KtExtensionApplicabilityResult
}
enum class KtExtensionApplicabilityResult(val isApplicable: Boolean) {
public enum class KtExtensionApplicabilityResult(public val isApplicable: Boolean) {
ApplicableAsExtensionCallable(isApplicable = true),
ApplicableAsFunctionalVariableCall(isApplicable = true),
NonApplicable(isApplicable = false),
}
interface KtCompletionCandidateCheckerMixIn : KtAnalysisSessionMixIn {
fun KtCallableSymbol.checkExtensionIsSuitable(
public interface KtCompletionCandidateCheckerMixIn : KtAnalysisSessionMixIn {
public fun KtCallableSymbol.checkExtensionIsSuitable(
originalPsiFile: KtFile,
psiFakeCompletionExpression: KtSimpleNameExpression,
psiReceiverExpression: KtExpression?,
@@ -10,20 +10,20 @@ import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtFile
abstract class KtDiagnosticProvider : KtAnalysisSessionComponent() {
abstract fun getDiagnosticsForElement(element: KtElement, filter: KtDiagnosticCheckerFilter): Collection<KtDiagnosticWithPsi<*>>
abstract fun collectDiagnosticsForFile(ktFile: KtFile, filter: KtDiagnosticCheckerFilter): Collection<KtDiagnosticWithPsi<*>>
public abstract class KtDiagnosticProvider : KtAnalysisSessionComponent() {
public abstract fun getDiagnosticsForElement(element: KtElement, filter: KtDiagnosticCheckerFilter): Collection<KtDiagnosticWithPsi<*>>
public abstract fun collectDiagnosticsForFile(ktFile: KtFile, filter: KtDiagnosticCheckerFilter): Collection<KtDiagnosticWithPsi<*>>
}
interface KtDiagnosticProviderMixIn : KtAnalysisSessionMixIn {
fun KtElement.getDiagnostics(filter: KtDiagnosticCheckerFilter): Collection<KtDiagnostic> =
public interface KtDiagnosticProviderMixIn : KtAnalysisSessionMixIn {
public fun KtElement.getDiagnostics(filter: KtDiagnosticCheckerFilter): Collection<KtDiagnostic> =
analysisSession.diagnosticProvider.getDiagnosticsForElement(this, filter)
fun KtFile.collectDiagnosticsForFile(filter: KtDiagnosticCheckerFilter): Collection<KtDiagnosticWithPsi<*>> =
public fun KtFile.collectDiagnosticsForFile(filter: KtDiagnosticCheckerFilter): Collection<KtDiagnosticWithPsi<*>> =
analysisSession.diagnosticProvider.collectDiagnosticsForFile(this, filter)
}
enum class KtDiagnosticCheckerFilter {
public enum class KtDiagnosticCheckerFilter {
ONLY_COMMON_CHECKERS,
ONLY_EXTENDED_CHECKERS,
EXTENDED_AND_COMMON_CHECKERS,
@@ -10,14 +10,14 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtCallableSymbol
import org.jetbrains.kotlin.psi.KtReturnExpression
import org.jetbrains.kotlin.psi.KtWhenExpression
abstract class KtExpressionInfoProvider : KtAnalysisSessionComponent() {
abstract fun getReturnExpressionTargetSymbol(returnExpression: KtReturnExpression): KtCallableSymbol?
abstract fun getWhenMissingCases(whenExpression: KtWhenExpression): List<WhenMissingCase>
public abstract class KtExpressionInfoProvider : KtAnalysisSessionComponent() {
public abstract fun getReturnExpressionTargetSymbol(returnExpression: KtReturnExpression): KtCallableSymbol?
public abstract fun getWhenMissingCases(whenExpression: KtWhenExpression): List<WhenMissingCase>
}
interface KtExpressionInfoProviderMixIn : KtAnalysisSessionMixIn {
fun KtReturnExpression.getReturnTargetSymbol(): KtCallableSymbol? =
public interface KtExpressionInfoProviderMixIn : KtAnalysisSessionMixIn {
public fun KtReturnExpression.getReturnTargetSymbol(): KtCallableSymbol? =
analysisSession.expressionInfoProvider.getReturnExpressionTargetSymbol(this)
fun KtWhenExpression.getMissingCases(): List<WhenMissingCase> = analysisSession.expressionInfoProvider.getWhenMissingCases(this)
public fun KtWhenExpression.getMissingCases(): List<WhenMissingCase> = analysisSession.expressionInfoProvider.getWhenMissingCases(this)
}
@@ -10,33 +10,33 @@ import org.jetbrains.kotlin.idea.frontend.api.types.KtType
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtExpression
abstract class KtExpressionTypeProvider : KtAnalysisSessionComponent() {
abstract fun getReturnTypeForKtDeclaration(declaration: KtDeclaration): KtType
abstract fun getKtExpressionType(expression: KtExpression): KtType
abstract fun getExpectedType(expression: PsiElement): KtType?
abstract fun isDefinitelyNull(expression: KtExpression): Boolean
abstract fun isDefinitelyNotNull(expression: KtExpression): Boolean
public abstract class KtExpressionTypeProvider : KtAnalysisSessionComponent() {
public abstract fun getReturnTypeForKtDeclaration(declaration: KtDeclaration): KtType
public abstract fun getKtExpressionType(expression: KtExpression): KtType
public abstract fun getExpectedType(expression: PsiElement): KtType?
public abstract fun isDefinitelyNull(expression: KtExpression): Boolean
public abstract fun isDefinitelyNotNull(expression: KtExpression): Boolean
}
interface KtExpressionTypeProviderMixIn : KtAnalysisSessionMixIn {
fun KtExpression.getKtType(): KtType =
public interface KtExpressionTypeProviderMixIn : KtAnalysisSessionMixIn {
public fun KtExpression.getKtType(): KtType =
analysisSession.expressionTypeProvider.getKtExpressionType(this)
fun KtDeclaration.getReturnKtType(): KtType =
public fun KtDeclaration.getReturnKtType(): KtType =
analysisSession.expressionTypeProvider.getReturnTypeForKtDeclaration(this)
/**
* Returns the expected [KtType] of this [PsiElement] if it is an expression. The returned value should not be a
* [org.jetbrains.kotlin.idea.frontend.api.types.KtClassErrorType].
*/
fun PsiElement.getExpectedType(): KtType? =
public fun PsiElement.getExpectedType(): KtType? =
analysisSession.expressionTypeProvider.getExpectedType(this)
/**
* Returns `true` if this expression is definitely null, based on declared nullability and smart cast types derived from
* data-flow analysis facts. Examples:
* ```
* fun <T : Any> foo(t: T, nt: T?, s: String, ns: String?) {
* public fun <T : Any> foo(t: T, nt: T?, s: String, ns: String?) {
* t // t.isDefinitelyNull() == false && t.isDefinitelyNotNull() == true
* nt // nt.isDefinitelyNull() == false && nt.isDefinitelyNotNull() == false
* s // s.isDefinitelyNull() == false && s.isDefinitelyNotNull() == true
@@ -54,12 +54,12 @@ interface KtExpressionTypeProviderMixIn : KtAnalysisSessionMixIn {
* Note that only nullability from "stable" smart cast types is considered. The
* [spec](https://kotlinlang.org/spec/type-inference.html#smart-cast-sink-stability) provides an explanation on smart cast stability.
*/
fun KtExpression.isDefinitelyNull(): Boolean =
public fun KtExpression.isDefinitelyNull(): Boolean =
analysisSession.expressionTypeProvider.isDefinitelyNull(this)
/**
* Returns `true` if this expression is definitely not null. See [isDefinitelyNull] for examples.
*/
fun KtExpression.isDefinitelyNotNull(): Boolean =
public fun KtExpression.isDefinitelyNotNull(): Boolean =
analysisSession.expressionTypeProvider.isDefinitelyNotNull(this)
}
@@ -8,15 +8,15 @@ package org.jetbrains.kotlin.idea.frontend.api.components
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtEnumEntrySymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtNamedClassOrObjectSymbol
abstract class KtInheritorsProvider : KtAnalysisSessionComponent() {
abstract fun getInheritorsOfSealedClass(classSymbol: KtNamedClassOrObjectSymbol): List<KtNamedClassOrObjectSymbol>
abstract fun getEnumEntries(classSymbol: KtNamedClassOrObjectSymbol): List<KtEnumEntrySymbol>
public abstract class KtInheritorsProvider : KtAnalysisSessionComponent() {
public abstract fun getInheritorsOfSealedClass(classSymbol: KtNamedClassOrObjectSymbol): List<KtNamedClassOrObjectSymbol>
public abstract fun getEnumEntries(classSymbol: KtNamedClassOrObjectSymbol): List<KtEnumEntrySymbol>
}
interface KtInheritorsProviderMixIn : KtAnalysisSessionMixIn {
fun KtNamedClassOrObjectSymbol.getSealedClassInheritors(): List<KtNamedClassOrObjectSymbol> =
analysisSession.inheritorsProvider.getInheritorsOfSealedClass(this)
public interface KtInheritorsProviderMixIn : KtAnalysisSessionMixIn {
public fun KtNamedClassOrObjectSymbol.getSealedClassInheritors(): List<KtNamedClassOrObjectSymbol> =
analysisSession.inheritorsProvider.getInheritorsOfSealedClass(this)
fun KtNamedClassOrObjectSymbol.getEnumEntries(): List<KtEnumEntrySymbol> =
analysisSession.inheritorsProvider.getEnumEntries(this)
public fun KtNamedClassOrObjectSymbol.getEnumEntries(): List<KtEnumEntrySymbol> =
analysisSession.inheritorsProvider.getEnumEntries(this)
}
@@ -9,24 +9,28 @@ import org.jetbrains.kotlin.util.ImplementationStatus
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtCallableSymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtClassOrObjectSymbol
abstract class KtOverrideInfoProvider : KtAnalysisSessionComponent() {
abstract fun isVisible(memberSymbol: KtCallableSymbol, classSymbol: KtClassOrObjectSymbol): Boolean
abstract fun getImplementationStatus(memberSymbol: KtCallableSymbol, parentClassSymbol: KtClassOrObjectSymbol): ImplementationStatus?
abstract fun getOriginalOverriddenSymbol(symbol: KtCallableSymbol): KtCallableSymbol?
abstract fun getOriginalContainingClassForOverride(symbol: KtCallableSymbol): KtClassOrObjectSymbol?
public abstract class KtOverrideInfoProvider : KtAnalysisSessionComponent() {
public abstract fun isVisible(memberSymbol: KtCallableSymbol, classSymbol: KtClassOrObjectSymbol): Boolean
public abstract fun getImplementationStatus(
memberSymbol: KtCallableSymbol,
parentClassSymbol: KtClassOrObjectSymbol
): ImplementationStatus?
public abstract fun getOriginalOverriddenSymbol(symbol: KtCallableSymbol): KtCallableSymbol?
public abstract fun getOriginalContainingClassForOverride(symbol: KtCallableSymbol): KtClassOrObjectSymbol?
}
interface KtMemberSymbolProviderMixin : KtAnalysisSessionMixIn {
public interface KtMemberSymbolProviderMixin : KtAnalysisSessionMixIn {
/** Checks if the given symbol (possibly a symbol inherited from a super class) is visible in the given class. */
fun KtCallableSymbol.isVisibleInClass(classSymbol: KtClassOrObjectSymbol): Boolean =
public fun KtCallableSymbol.isVisibleInClass(classSymbol: KtClassOrObjectSymbol): Boolean =
analysisSession.overrideInfoProvider.isVisible(this, classSymbol)
/**
* Gets the [ImplementationStatus] of the [this] member symbol in the given [parentClassSymbol]. Or null if this symbol is not a
* member.
*/
fun KtCallableSymbol.getImplementationStatus(parentClassSymbol: KtClassOrObjectSymbol): ImplementationStatus? =
public fun KtCallableSymbol.getImplementationStatus(parentClassSymbol: KtClassOrObjectSymbol): ImplementationStatus? =
analysisSession.overrideInfoProvider.getImplementationStatus(this, parentClassSymbol)
/**
@@ -34,11 +38,11 @@ interface KtMemberSymbolProviderMixin : KtAnalysisSessionMixIn {
* classes. For example, consider
*
* ```
* interface A<T> {
* fun foo(t:T)
* public interface A<T> {
* public fun foo(t:T)
* }
*
* interface B: A<String> {
* public interface B: A<String> {
* }
* ```
*
@@ -49,12 +53,12 @@ interface KtMemberSymbolProviderMixin : KtAnalysisSessionMixIn {
* Such situation can also happens for intersection symbols (in case of multiple super types containing symbols with identical signature
* after specialization) and delegation.
*/
val KtCallableSymbol.originalOverriddenSymbol: KtCallableSymbol?
public val KtCallableSymbol.originalOverriddenSymbol: KtCallableSymbol?
get() = analysisSession.overrideInfoProvider.getOriginalOverriddenSymbol(this)
/**
* Gets the class symbol where the given callable symbol is declared. See [originalOverriddenSymbol] for more details.
*/
val KtCallableSymbol.originalContainingClassForOverride: KtClassOrObjectSymbol?
public val KtCallableSymbol.originalContainingClassForOverride: KtClassOrObjectSymbol?
get() = analysisSession.overrideInfoProvider.getOriginalContainingClassForOverride(this)
}
@@ -11,22 +11,22 @@ import org.jetbrains.kotlin.psi.KtDoubleColonExpression
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtTypeReference
abstract class KtPsiTypeProvider : KtAnalysisSessionComponent() {
abstract fun getPsiTypeForKtExpression(expression: KtExpression, mode: TypeMappingMode): PsiType
abstract fun getPsiTypeForKtTypeReference(ktTypeReference: KtTypeReference, mode: TypeMappingMode): PsiType
abstract fun getPsiTypeForReceiverOfDoubleColonExpression(
public abstract class KtPsiTypeProvider : KtAnalysisSessionComponent() {
public abstract fun getPsiTypeForKtExpression(expression: KtExpression, mode: TypeMappingMode): PsiType
public abstract fun getPsiTypeForKtTypeReference(ktTypeReference: KtTypeReference, mode: TypeMappingMode): PsiType
public abstract fun getPsiTypeForReceiverOfDoubleColonExpression(
ktDoubleColonExpression: KtDoubleColonExpression,
mode: TypeMappingMode
): PsiType?
}
interface KtPsiTypeProviderMixIn : KtAnalysisSessionMixIn {
fun KtExpression.getPsiType(mode: TypeMappingMode = TypeMappingMode.DEFAULT): PsiType =
public interface KtPsiTypeProviderMixIn : KtAnalysisSessionMixIn {
public fun KtExpression.getPsiType(mode: TypeMappingMode = TypeMappingMode.DEFAULT): PsiType =
analysisSession.psiTypeProvider.getPsiTypeForKtExpression(this, mode)
fun KtTypeReference.getPsiType(mode: TypeMappingMode = TypeMappingMode.DEFAULT): PsiType =
public fun KtTypeReference.getPsiType(mode: TypeMappingMode = TypeMappingMode.DEFAULT): PsiType =
analysisSession.psiTypeProvider.getPsiTypeForKtTypeReference(this, mode)
fun KtDoubleColonExpression.getReceiverPsiType(mode: TypeMappingMode = TypeMappingMode.DEFAULT): PsiType? =
public fun KtDoubleColonExpression.getReceiverPsiType(mode: TypeMappingMode = TypeMappingMode.DEFAULT): PsiType? =
analysisSession.psiTypeProvider.getPsiTypeForReceiverOfDoubleColonExpression(this, mode)
}
@@ -9,13 +9,13 @@ import org.jetbrains.kotlin.idea.frontend.api.KtSymbolBasedReference
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol
import org.jetbrains.kotlin.idea.references.KtReference
interface KtReferenceResolveMixIn : KtAnalysisSessionMixIn {
fun KtReference.resolveToSymbols(): Collection<KtSymbol> {
public interface KtReferenceResolveMixIn : KtAnalysisSessionMixIn {
public fun KtReference.resolveToSymbols(): Collection<KtSymbol> {
check(this is KtSymbolBasedReference) { "To get reference symbol the one should be KtSymbolBasedReference" }
return analysisSession.resolveToSymbols()
}
fun KtReference.resolveToSymbol(): KtSymbol? {
public fun KtReference.resolveToSymbol(): KtSymbol? {
check(this is KtSymbolBasedReference) { "To get reference symbol the one should be KtSymbolBasedReference but was ${this::class}" }
return resolveToSymbols().singleOrNull()
}
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtEnumEntrySymbol
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtFile
enum class ShortenOption {
public enum class ShortenOption {
/** Skip shortening references to this symbol. */
DO_NOT_SHORTEN,
@@ -26,8 +26,8 @@ enum class ShortenOption {
SHORTEN_AND_STAR_IMPORT
}
abstract class KtReferenceShortener : KtAnalysisSessionComponent() {
abstract fun collectShortenings(
public abstract class KtReferenceShortener : KtAnalysisSessionComponent() {
public abstract fun collectShortenings(
file: KtFile,
selection: TextRange,
classShortenOption: (KtClassLikeSymbol) -> ShortenOption,
@@ -35,8 +35,8 @@ abstract class KtReferenceShortener : KtAnalysisSessionComponent() {
): ShortenCommand
}
interface KtReferenceShortenerMixIn : KtAnalysisSessionMixIn {
companion object {
public interface KtReferenceShortenerMixIn : KtAnalysisSessionMixIn {
public companion object {
private val defaultClassShortenOption: (KtClassLikeSymbol) -> ShortenOption = {
if (it.classIdIfNonLocal?.isNestedClass == true) {
ShortenOption.SHORTEN_IF_ALREADY_IMPORTED
@@ -55,7 +55,7 @@ interface KtReferenceShortenerMixIn : KtAnalysisSessionMixIn {
* Collects possible references to shorten. By default, it shortens a fully-qualified members to the outermost class and does not
* shorten enum entries.
*/
fun collectPossibleReferenceShortenings(
public fun collectPossibleReferenceShortenings(
file: KtFile,
selection: TextRange = file.textRange,
classShortenOption: (KtClassLikeSymbol) -> ShortenOption = defaultClassShortenOption,
@@ -63,7 +63,7 @@ interface KtReferenceShortenerMixIn : KtAnalysisSessionMixIn {
): ShortenCommand =
analysisSession.referenceShortener.collectShortenings(file, selection, classShortenOption, callableShortenOption)
fun collectPossibleReferenceShorteningsInElement(
public fun collectPossibleReferenceShorteningsInElement(
element: KtElement,
classShortenOption: (KtClassLikeSymbol) -> ShortenOption = defaultClassShortenOption,
callableShortenOption: (KtCallableSymbol) -> ShortenOption = defaultCallableShortenOption
@@ -76,7 +76,7 @@ interface KtReferenceShortenerMixIn : KtAnalysisSessionMixIn {
)
}
interface ShortenCommand {
fun invokeShortening()
val isEmpty: Boolean
public interface ShortenCommand {
public fun invokeShortening()
public val isEmpty: Boolean
}
@@ -17,56 +17,56 @@ import org.jetbrains.kotlin.idea.frontend.api.types.KtType
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtFile
abstract class KtScopeProvider : KtAnalysisSessionComponent() {
abstract fun getMemberScope(classSymbol: KtSymbolWithMembers): KtMemberScope
abstract fun getStaticMemberScope(symbol: KtSymbolWithMembers): KtScope
public abstract class KtScopeProvider : KtAnalysisSessionComponent() {
public abstract fun getMemberScope(classSymbol: KtSymbolWithMembers): KtMemberScope
public abstract fun getStaticMemberScope(symbol: KtSymbolWithMembers): KtScope
abstract fun getDeclaredMemberScope(classSymbol: KtSymbolWithMembers): KtDeclaredMemberScope
abstract fun getFileScope(fileSymbol: KtFileSymbol): KtDeclarationScope<KtSymbolWithDeclarations>
abstract fun getPackageScope(packageSymbol: KtPackageSymbol): KtPackageScope
abstract fun getCompositeScope(subScopes: List<KtScope>): KtCompositeScope
public abstract fun getDeclaredMemberScope(classSymbol: KtSymbolWithMembers): KtDeclaredMemberScope
public abstract fun getFileScope(fileSymbol: KtFileSymbol): KtDeclarationScope<KtSymbolWithDeclarations>
public abstract fun getPackageScope(packageSymbol: KtPackageSymbol): KtPackageScope
public abstract fun getCompositeScope(subScopes: List<KtScope>): KtCompositeScope
abstract fun getTypeScope(type: KtType): KtScope?
public abstract fun getTypeScope(type: KtType): KtScope?
abstract fun getScopeContextForPosition(
public abstract fun getScopeContextForPosition(
originalFile: KtFile,
positionInFakeFile: KtElement
): KtScopeContext
}
interface KtScopeProviderMixIn : KtAnalysisSessionMixIn {
fun KtSymbolWithMembers.getMemberScope(): KtMemberScope =
public interface KtScopeProviderMixIn : KtAnalysisSessionMixIn {
public fun KtSymbolWithMembers.getMemberScope(): KtMemberScope =
analysisSession.scopeProvider.getMemberScope(this)
fun KtSymbolWithMembers.getDeclaredMemberScope(): KtDeclaredMemberScope =
public fun KtSymbolWithMembers.getDeclaredMemberScope(): KtDeclaredMemberScope =
analysisSession.scopeProvider.getDeclaredMemberScope(this)
fun KtSymbolWithMembers.getStaticMemberScope(): KtScope =
public fun KtSymbolWithMembers.getStaticMemberScope(): KtScope =
analysisSession.scopeProvider.getStaticMemberScope(this)
fun KtFileSymbol.getFileScope(): KtDeclarationScope<KtSymbolWithDeclarations> =
public fun KtFileSymbol.getFileScope(): KtDeclarationScope<KtSymbolWithDeclarations> =
analysisSession.scopeProvider.getFileScope(this)
fun KtPackageSymbol.getPackageScope(): KtPackageScope =
public fun KtPackageSymbol.getPackageScope(): KtPackageScope =
analysisSession.scopeProvider.getPackageScope(this)
fun List<KtScope>.asCompositeScope(): KtCompositeScope =
public fun List<KtScope>.asCompositeScope(): KtCompositeScope =
analysisSession.scopeProvider.getCompositeScope(this)
fun KtType.getTypeScope(): KtScope? =
public fun KtType.getTypeScope(): KtScope? =
analysisSession.scopeProvider.getTypeScope(this)
fun KtFile.getScopeContextForPosition(positionInFakeFile: KtElement): KtScopeContext =
public fun KtFile.getScopeContextForPosition(positionInFakeFile: KtElement): KtScopeContext =
analysisSession.scopeProvider.getScopeContextForPosition(this, positionInFakeFile)
fun KtFile.getScopeContextForFile(): KtScopeContext =
public fun KtFile.getScopeContextForFile(): KtScopeContext =
analysisSession.scopeProvider.getScopeContextForPosition(this, this)
}
data class KtScopeContext(val scopes: KtCompositeScope, val implicitReceivers: List<KtImplicitReceiver>)
public data class KtScopeContext(val scopes: KtCompositeScope, val implicitReceivers: List<KtImplicitReceiver>)
class KtImplicitReceiver(
public class KtImplicitReceiver(
override val token: ValidityToken,
val type: KtType,
val ownerSymbol: KtSymbol
): ValidityTokenOwner
public val type: KtType,
public val ownerSymbol: KtSymbol
) : ValidityTokenOwner
@@ -9,15 +9,15 @@ import org.jetbrains.kotlin.idea.frontend.api.ImplicitReceiverSmartCast
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
import org.jetbrains.kotlin.psi.KtExpression
abstract class KtSmartCastProvider : KtAnalysisSessionComponent() {
abstract fun getSmartCastedToType(expression: KtExpression): KtType?
abstract fun getImplicitReceiverSmartCast(expression: KtExpression): Collection<ImplicitReceiverSmartCast>
public abstract class KtSmartCastProvider : KtAnalysisSessionComponent() {
public abstract fun getSmartCastedToType(expression: KtExpression): KtType?
public abstract fun getImplicitReceiverSmartCast(expression: KtExpression): Collection<ImplicitReceiverSmartCast>
}
interface KtSmartCastProviderMixIn : KtAnalysisSessionMixIn {
fun KtExpression.getSmartCast(): KtType? =
public interface KtSmartCastProviderMixIn : KtAnalysisSessionMixIn {
public fun KtExpression.getSmartCast(): KtType? =
analysisSession.smartCastProvider.getSmartCastedToType(this)
fun KtExpression.getImplicitReceiverSmartCast(): Collection<ImplicitReceiverSmartCast> =
public fun KtExpression.getImplicitReceiverSmartCast(): Collection<ImplicitReceiverSmartCast> =
analysisSession.smartCastProvider.getImplicitReceiverSmartCast(this)
}
@@ -7,18 +7,18 @@ package org.jetbrains.kotlin.idea.frontend.api.components
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
abstract class KtSubtypingComponent : KtAnalysisSessionComponent() {
abstract fun isEqualTo(first: KtType, second: KtType): Boolean
abstract fun isSubTypeOf(subType: KtType, superType: KtType): Boolean
public abstract class KtSubtypingComponent : KtAnalysisSessionComponent() {
public abstract fun isEqualTo(first: KtType, second: KtType): Boolean
public abstract fun isSubTypeOf(subType: KtType, superType: KtType): Boolean
}
interface KtSubtypingComponentMixIn : KtAnalysisSessionMixIn {
infix fun KtType.isEqualTo(other: KtType): Boolean =
public interface KtSubtypingComponentMixIn : KtAnalysisSessionMixIn {
infix public fun KtType.isEqualTo(other: KtType): Boolean =
analysisSession.subtypingComponent.isEqualTo(this, other)
infix fun KtType.isSubTypeOf(superType: KtType): Boolean =
infix public fun KtType.isSubTypeOf(superType: KtType): Boolean =
analysisSession.subtypingComponent.isSubTypeOf(this, superType)
infix fun KtType.isNotSubTypeOf(superType: KtType): Boolean =
infix public fun KtType.isNotSubTypeOf(superType: KtType): Boolean =
!analysisSession.subtypingComponent.isSubTypeOf(this, superType)
}
@@ -7,17 +7,17 @@ package org.jetbrains.kotlin.idea.frontend.api.components
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithKind
abstract class KtSymbolContainingDeclarationProvider : KtAnalysisSessionComponent() {
abstract fun getContainingDeclaration(symbol: KtSymbolWithKind): KtSymbolWithKind?
public abstract class KtSymbolContainingDeclarationProvider : KtAnalysisSessionComponent() {
public abstract fun getContainingDeclaration(symbol: KtSymbolWithKind): KtSymbolWithKind?
}
interface KtSymbolContainingDeclarationProviderMixIn : KtAnalysisSessionMixIn {
public interface KtSymbolContainingDeclarationProviderMixIn : KtAnalysisSessionMixIn {
/**
* Returns containing declaration for symbol:
* for top-level declarations returns null
* for class members returns containing class
* for local declaration returns declaration it was declared it
*/
fun KtSymbolWithKind.getContainingSymbol(): KtSymbolWithKind? =
public fun KtSymbolWithKind.getContainingSymbol(): KtSymbolWithKind? =
analysisSession.containingDeclarationProvider.getContainingDeclaration(this)
}
@@ -9,14 +9,14 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtCallableSymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtClassOrObjectSymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol
abstract class KtSymbolDeclarationOverridesProvider : KtAnalysisSessionComponent() {
abstract fun <T : KtSymbol> getAllOverriddenSymbols(callableSymbol: T): List<KtCallableSymbol>
abstract fun <T : KtSymbol> getDirectlyOverriddenSymbols(callableSymbol: T): List<KtCallableSymbol>
public abstract class KtSymbolDeclarationOverridesProvider : KtAnalysisSessionComponent() {
public abstract fun <T : KtSymbol> getAllOverriddenSymbols(callableSymbol: T): List<KtCallableSymbol>
public abstract fun <T : KtSymbol> getDirectlyOverriddenSymbols(callableSymbol: T): List<KtCallableSymbol>
abstract fun getIntersectionOverriddenSymbols(symbol: KtCallableSymbol): Collection<KtCallableSymbol>
public abstract fun getIntersectionOverriddenSymbols(symbol: KtCallableSymbol): Collection<KtCallableSymbol>
}
interface KtSymbolDeclarationOverridesProviderMixIn : KtAnalysisSessionMixIn {
public interface KtSymbolDeclarationOverridesProviderMixIn : KtAnalysisSessionMixIn {
/**
* Return a list of **all** symbols which are overridden by symbol
*
@@ -26,7 +26,7 @@ interface KtSymbolDeclarationOverridesProviderMixIn : KtAnalysisSessionMixIn {
*
* @see getDirectlyOverriddenSymbols
*/
fun KtCallableSymbol.getAllOverriddenSymbols(): List<KtCallableSymbol> =
public fun KtCallableSymbol.getAllOverriddenSymbols(): List<KtCallableSymbol> =
analysisSession.symbolDeclarationOverridesProvider.getAllOverriddenSymbols(this)
/**
@@ -38,9 +38,9 @@ interface KtSymbolDeclarationOverridesProviderMixIn : KtAnalysisSessionMixIn {
*
* @see getAllOverriddenSymbols
*/
fun KtCallableSymbol.getDirectlyOverriddenSymbols(): List<KtCallableSymbol> =
public fun KtCallableSymbol.getDirectlyOverriddenSymbols(): List<KtCallableSymbol> =
analysisSession.symbolDeclarationOverridesProvider.getDirectlyOverriddenSymbols(this)
fun KtCallableSymbol.getIntersectionOverriddenSymbols(): Collection<KtCallableSymbol> =
public fun KtCallableSymbol.getIntersectionOverriddenSymbols(): Collection<KtCallableSymbol> =
analysisSession.symbolDeclarationOverridesProvider.getIntersectionOverriddenSymbols(this)
}
@@ -13,28 +13,28 @@ import org.jetbrains.kotlin.idea.frontend.api.types.KtType
* @see KtType
* @see KtSymbolDeclarationRendererProvider.render
*/
data class KtTypeRendererOptions(
public data class KtTypeRendererOptions(
/**
* Render type name without package name for not local types
*/
val shortQualifiedNames: Boolean = false,
public val shortQualifiedNames: Boolean = false,
/**
* Render function types FunctionN using Kotlin function type syntax
* @see Function
* @sample Function0<Int> returns () -> Int
* Render public function types public functionN using Kotlin public function type syntax
* @see public function
* @sample public function0<Int> returns () -> Int
*/
val renderFunctionType: Boolean = true,
public val renderFunctionType: Boolean = true,
/**
* When met type with unresolved qualifier, render it as it is resolved
* When `true` will render as `UnresolvedQualifier`
* When `false` will render as "ERROR_TYPE <symbol not found for UnresolvedQualifier>"
*/
val renderUnresolvedTypeAsResolved: Boolean = true
public val renderUnresolvedTypeAsResolved: Boolean = true
) {
companion object {
val DEFAULT = KtTypeRendererOptions()
val SHORT_NAMES = DEFAULT.copy(shortQualifiedNames = true)
public companion object {
public val DEFAULT: KtTypeRendererOptions = KtTypeRendererOptions()
public val SHORT_NAMES: KtTypeRendererOptions = DEFAULT.copy(shortQualifiedNames = true)
}
}
@@ -43,7 +43,7 @@ data class KtTypeRendererOptions(
* @see KtSymbol
* @see KtSymbolDeclarationRendererProvider.render
*/
data class KtDeclarationRendererOptions(
public data class KtDeclarationRendererOptions(
/**
* Set of modifiers that needed to be rendered
* @see RendererModifier
@@ -55,7 +55,7 @@ data class KtDeclarationRendererOptions(
*/
val typeRendererOptions: KtTypeRendererOptions = KtTypeRendererOptions.DEFAULT,
/**
* Render Unit return type for functions
* Render Unit return type for public functions
*/
val renderUnitReturnType: Boolean = false,
/**
@@ -72,24 +72,24 @@ data class KtDeclarationRendererOptions(
val approximateTypes: Boolean = false,
/**
* Declaration header is something like `abstract class`, `fun`, or `private interface` in a declaration.
* Declaration header is something like `public abstract class`, `public fun`, or `private public interface ` in a declaration.
*/
val renderDeclarationHeader: Boolean = true,
/**
* Whether to forcefully add `override` modifier when rendering functions or properties. Note that the [modifiers] option still
* Whether to forcefully add `override` modifier when rendering public functions or properties. Note that the [modifiers] option still
* controls whether `override` is rendered. That is, if [modifiers] don't contain `override`, then this flag does not have any effect.
*/
val forceRenderingOverrideModifier: Boolean = false,
val renderDefaultParameterValue: Boolean = true,
) {
companion object {
val DEFAULT = KtDeclarationRendererOptions()
public companion object {
public val DEFAULT: KtDeclarationRendererOptions = KtDeclarationRendererOptions()
}
}
enum class RendererModifier(val includeByDefault: Boolean) {
public enum class RendererModifier(public val includeByDefault: Boolean) {
VISIBILITY(true),
MODALITY(true),
OVERRIDE(true),
@@ -106,29 +106,29 @@ enum class RendererModifier(val includeByDefault: Boolean) {
OPERATOR(true)
;
companion object {
val ALL = values().toSet()
public companion object {
public val ALL: Set<RendererModifier> = values().toSet()
}
}
abstract class KtSymbolDeclarationRendererProvider : KtAnalysisSessionComponent() {
abstract fun render(symbol: KtSymbol, options: KtDeclarationRendererOptions): String
abstract fun render(type: KtType, options: KtTypeRendererOptions): String
public abstract class KtSymbolDeclarationRendererProvider : KtAnalysisSessionComponent() {
public abstract fun render(symbol: KtSymbol, options: KtDeclarationRendererOptions): String
public abstract fun render(type: KtType, options: KtTypeRendererOptions): String
}
/**
* Provides services for rendering Symbols and Types into the Kotlin strings
*/
interface KtSymbolDeclarationRendererMixIn : KtAnalysisSessionMixIn {
public interface KtSymbolDeclarationRendererMixIn : KtAnalysisSessionMixIn {
/**
* Render symbol into the representable Kotlin string
*/
fun KtSymbol.render(options: KtDeclarationRendererOptions = KtDeclarationRendererOptions.DEFAULT): String =
public fun KtSymbol.render(options: KtDeclarationRendererOptions = KtDeclarationRendererOptions.DEFAULT): String =
analysisSession.symbolDeclarationRendererProvider.render(this, options)
/**
* Render kotlin type into the representable Kotlin type string
*/
fun KtType.render(options: KtTypeRendererOptions = KtTypeRendererOptions.DEFAULT): String =
public fun KtType.render(options: KtTypeRendererOptions = KtTypeRendererOptions.DEFAULT): String =
analysisSession.symbolDeclarationRendererProvider.render(this, options)
}
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.idea.frontend.api.components
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer
interface KtSymbolsMixIn : KtAnalysisSessionMixIn {
public interface KtSymbolsMixIn : KtAnalysisSessionMixIn {
@Suppress("DEPRECATION")
fun <S : KtSymbol> KtSymbolPointer<S>.restoreSymbol(): S? = restoreSymbol(analysisSession)
public fun <S : KtSymbol> KtSymbolPointer<S>.restoreSymbol(): S? = restoreSymbol(analysisSession)
}
@@ -14,44 +14,44 @@ import org.jetbrains.kotlin.idea.frontend.api.types.KtTypeNullability
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.types.Variance
abstract class KtTypeCreator : KtAnalysisSessionComponent() {
abstract fun buildClassType(builder: KtClassTypeBuilder): KtClassType
public abstract class KtTypeCreator : KtAnalysisSessionComponent() {
public abstract fun buildClassType(builder: KtClassTypeBuilder): KtClassType
}
interface KtTypeCreatorMixIn : KtAnalysisSessionMixIn
public interface KtTypeCreatorMixIn : KtAnalysisSessionMixIn
inline fun KtTypeCreatorMixIn.buildClassType(
public inline fun KtTypeCreatorMixIn.buildClassType(
classId: ClassId,
build: KtClassTypeBuilder.() -> Unit = {}
): KtClassType =
analysisSession.typesCreator.buildClassType(KtClassTypeBuilder.ByClassId(classId).apply(build))
inline fun KtTypeCreatorMixIn.buildClassType(
public inline fun KtTypeCreatorMixIn.buildClassType(
symbol: KtClassOrObjectSymbol,
build: KtClassTypeBuilder.() -> Unit = {}
): KtClassType =
analysisSession.typesCreator.buildClassType(KtClassTypeBuilder.BySymbol(symbol).apply(build))
sealed class KtTypeBuilder
public sealed class KtTypeBuilder
sealed class KtClassTypeBuilder : KtTypeBuilder() {
public sealed class KtClassTypeBuilder : KtTypeBuilder() {
private val _arguments = mutableListOf<KtTypeArgument>()
var nullability: KtTypeNullability = KtTypeNullability.NON_NULLABLE
public var nullability: KtTypeNullability = KtTypeNullability.NON_NULLABLE
val arguments: List<KtTypeArgument> get() = _arguments
public val arguments: List<KtTypeArgument> get() = _arguments
fun argument(argument: KtTypeArgument) {
public fun argument(argument: KtTypeArgument) {
_arguments += argument
}
fun argument(type: KtType, variance: Variance = Variance.INVARIANT) {
public fun argument(type: KtType, variance: Variance = Variance.INVARIANT) {
_arguments += KtTypeArgumentWithVariance(type, variance, type.token)
}
class ByClassId(val classId: ClassId) : KtClassTypeBuilder()
class BySymbol(val symbol: KtClassOrObjectSymbol) : KtClassTypeBuilder()
public class ByClassId(public val classId: ClassId) : KtClassTypeBuilder()
public class BySymbol(public val symbol: KtClassOrObjectSymbol) : KtClassTypeBuilder()
}
@@ -11,43 +11,43 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtTypeAliasSymbol
import org.jetbrains.kotlin.idea.frontend.api.types.*
import org.jetbrains.kotlin.name.ClassId
abstract class KtTypeInfoProvider : KtAnalysisSessionComponent() {
abstract fun canBeNull(type: KtType): Boolean
public abstract class KtTypeInfoProvider : KtAnalysisSessionComponent() {
public abstract fun canBeNull(type: KtType): Boolean
}
interface KtTypeInfoProviderMixIn : KtAnalysisSessionMixIn {
public interface KtTypeInfoProviderMixIn : KtAnalysisSessionMixIn {
/**
* Returns true if a value of this type can potentially be null. This means this type is not a subtype of [Any]. However, it does not
* mean one can assign `null` to a variable of this type because it may be unknown if this type can accept `null`. For example, a value
* Returns true if a public value of this type can potentially be null. This means this type is not a subtype of [Any]. However, it does not
* mean one can assign `null` to a variable of this type because it may be unknown if this type can accept `null`. For example, a public value
* of type `T:Any?` can potentially be null. But one can not assign `null` to such a variable because the instantiated type may not be
* nullable.
*/
val KtType.canBeNull: Boolean get() = analysisSession.typeInfoProvider.canBeNull(this)
public val KtType.canBeNull: Boolean get() = analysisSession.typeInfoProvider.canBeNull(this)
/** Returns true if the type is explicitly marked as nullable. This means it's safe to assign `null` to a variable with this type. */
val KtType.isMarkedNullable: Boolean get() = (this as? KtTypeWithNullability)?.nullability == KtTypeNullability.NULLABLE
public val KtType.isMarkedNullable: Boolean get() = (this as? KtTypeWithNullability)?.nullability == KtTypeNullability.NULLABLE
val KtType.isUnit: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.UNIT)
val KtType.isInt: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.INT)
val KtType.isLong: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.LONG)
val KtType.isShort: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.SHORT)
val KtType.isByte: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.BYTE)
val KtType.isFloat: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.FLOAT)
val KtType.isDouble: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.DOUBLE)
val KtType.isChar: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.CHAR)
val KtType.isBoolean: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.BOOLEAN)
val KtType.isString: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.STRING)
val KtType.isCharSequence: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.CHAR_SEQUENCE)
val KtType.isAny: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.ANY)
val KtType.isNothing: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.NOTHING)
public val KtType.isUnit: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.UNIT)
public val KtType.isInt: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.INT)
public val KtType.isLong: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.LONG)
public val KtType.isShort: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.SHORT)
public val KtType.isByte: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.BYTE)
public val KtType.isFloat: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.FLOAT)
public val KtType.isDouble: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.DOUBLE)
public val KtType.isChar: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.CHAR)
public val KtType.isBoolean: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.BOOLEAN)
public val KtType.isString: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.STRING)
public val KtType.isCharSequence: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.CHAR_SEQUENCE)
public val KtType.isAny: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.ANY)
public val KtType.isNothing: Boolean get() = isClassTypeWithClassId(DefaultTypeClassIds.NOTHING)
val KtType.isUInt: Boolean get() = isClassTypeWithClassId(StandardNames.FqNames.uInt)
val KtType.isULong: Boolean get() = isClassTypeWithClassId(StandardNames.FqNames.uLong)
val KtType.isUShort: Boolean get() = isClassTypeWithClassId(StandardNames.FqNames.uShort)
val KtType.isUByte: Boolean get() = isClassTypeWithClassId(StandardNames.FqNames.uByte)
public val KtType.isUInt: Boolean get() = isClassTypeWithClassId(StandardNames.FqNames.uInt)
public val KtType.isULong: Boolean get() = isClassTypeWithClassId(StandardNames.FqNames.uLong)
public val KtType.isUShort: Boolean get() = isClassTypeWithClassId(StandardNames.FqNames.uShort)
public val KtType.isUByte: Boolean get() = isClassTypeWithClassId(StandardNames.FqNames.uByte)
/** Gets the class symbol backing the given type, if available. */
val KtType.expandedClassSymbol: KtClassOrObjectSymbol?
public val KtType.expandedClassSymbol: KtClassOrObjectSymbol?
get() {
return when (this) {
is KtNonErrorClassType -> when (val classSymbol = classSymbol) {
@@ -58,18 +58,18 @@ interface KtTypeInfoProviderMixIn : KtAnalysisSessionMixIn {
}
}
fun KtType.isClassTypeWithClassId(classId: ClassId): Boolean {
public fun KtType.isClassTypeWithClassId(classId: ClassId): Boolean {
if (this !is KtNonErrorClassType) return false
return this.classId == classId
}
val KtType.isPrimitive: Boolean
public val KtType.isPrimitive: Boolean
get() {
if (this !is KtNonErrorClassType) return false
return this.classId in DefaultTypeClassIds.PRIMITIVES
}
val KtType.defaultInitializer: String?
public val KtType.defaultInitializer: String?
get() = when {
isMarkedNullable -> "null"
isInt || isLong || isShort || isByte -> "0"
@@ -87,19 +87,19 @@ interface KtTypeInfoProviderMixIn : KtAnalysisSessionMixIn {
}
}
object DefaultTypeClassIds {
val UNIT = ClassId.topLevel(StandardNames.FqNames.unit.toSafe())
val INT = ClassId.topLevel(StandardNames.FqNames._int.toSafe())
val LONG = ClassId.topLevel(StandardNames.FqNames._long.toSafe())
val SHORT = ClassId.topLevel(StandardNames.FqNames._short.toSafe())
val BYTE = ClassId.topLevel(StandardNames.FqNames._byte.toSafe())
val FLOAT = ClassId.topLevel(StandardNames.FqNames._float.toSafe())
val DOUBLE = ClassId.topLevel(StandardNames.FqNames._double.toSafe())
val CHAR = ClassId.topLevel(StandardNames.FqNames._char.toSafe())
val BOOLEAN = ClassId.topLevel(StandardNames.FqNames._boolean.toSafe())
val STRING = ClassId.topLevel(StandardNames.FqNames.string.toSafe())
val CHAR_SEQUENCE = ClassId.topLevel(StandardNames.FqNames.charSequence.toSafe())
val ANY = ClassId.topLevel(StandardNames.FqNames.any.toSafe())
val NOTHING = ClassId.topLevel(StandardNames.FqNames.nothing.toSafe())
val PRIMITIVES = setOf(INT, LONG, SHORT, BYTE, FLOAT, DOUBLE, CHAR, BOOLEAN)
public object DefaultTypeClassIds {
public val UNIT: ClassId = ClassId.topLevel(StandardNames.FqNames.unit.toSafe())
public val INT: ClassId = ClassId.topLevel(StandardNames.FqNames._int.toSafe())
public val LONG: ClassId = ClassId.topLevel(StandardNames.FqNames._long.toSafe())
public val SHORT: ClassId = ClassId.topLevel(StandardNames.FqNames._short.toSafe())
public val BYTE: ClassId = ClassId.topLevel(StandardNames.FqNames._byte.toSafe())
public val FLOAT: ClassId = ClassId.topLevel(StandardNames.FqNames._float.toSafe())
public val DOUBLE: ClassId = ClassId.topLevel(StandardNames.FqNames._double.toSafe())
public val CHAR: ClassId = ClassId.topLevel(StandardNames.FqNames._char.toSafe())
public val BOOLEAN: ClassId = ClassId.topLevel(StandardNames.FqNames._boolean.toSafe())
public val STRING: ClassId = ClassId.topLevel(StandardNames.FqNames.string.toSafe())
public val CHAR_SEQUENCE: ClassId = ClassId.topLevel(StandardNames.FqNames.charSequence.toSafe())
public val ANY: ClassId = ClassId.topLevel(StandardNames.FqNames.any.toSafe())
public val NOTHING: ClassId = ClassId.topLevel(StandardNames.FqNames.nothing.toSafe())
public val PRIMITIVES: Set<ClassId> = setOf(INT, LONG, SHORT, BYTE, FLOAT, DOUBLE, CHAR, BOOLEAN)
}
@@ -10,18 +10,18 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtNamedClassOrObjectSymbol
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
import org.jetbrains.kotlin.idea.frontend.api.types.KtTypeNullability
abstract class KtTypeProvider : KtAnalysisSessionComponent() {
abstract val builtinTypes: KtBuiltinTypes
public abstract class KtTypeProvider : KtAnalysisSessionComponent() {
public abstract val builtinTypes: KtBuiltinTypes
abstract fun approximateToSuperPublicDenotableType(type: KtType): KtType?
public abstract fun approximateToSuperPublicDenotableType(type: KtType): KtType?
abstract fun buildSelfClassType(symbol: KtNamedClassOrObjectSymbol): KtType
public abstract fun buildSelfClassType(symbol: KtNamedClassOrObjectSymbol): KtType
abstract fun withNullability(type: KtType, newNullability: KtTypeNullability): KtType
public abstract fun withNullability(type: KtType, newNullability: KtTypeNullability): KtType
}
interface KtTypeProviderMixIn : KtAnalysisSessionMixIn {
val builtinTypes: KtBuiltinTypes
public interface KtTypeProviderMixIn : KtAnalysisSessionMixIn {
public val builtinTypes: KtBuiltinTypes
get() = analysisSession.typeProvider.builtinTypes
/**
@@ -30,36 +30,36 @@ interface KtTypeProviderMixIn : KtAnalysisSessionMixIn {
* Return `null` if the type do not need approximation and can be rendered as is
* Otherwise, for type `T` return type `S` such `T <: S` and `T` and every it type argument is [org.jetbrains.kotlin.idea.frontend.api.types.KtDenotableType]`
*/
fun KtType.approximateToSuperPublicDenotable(): KtType? =
public fun KtType.approximateToSuperPublicDenotable(): KtType? =
analysisSession.typeProvider.approximateToSuperPublicDenotableType(this)
fun KtType.approximateToSuperPublicDenotableOrSelf(): KtType = approximateToSuperPublicDenotable() ?: this
public fun KtType.approximateToSuperPublicDenotableOrSelf(): KtType = approximateToSuperPublicDenotable() ?: this
fun KtNamedClassOrObjectSymbol.buildSelfClassType(): KtType =
public fun KtNamedClassOrObjectSymbol.buildSelfClassType(): KtType =
analysisSession.typeProvider.buildSelfClassType(this)
fun KtType.withNullability(newNullability: KtTypeNullability): KtType =
public fun KtType.withNullability(newNullability: KtTypeNullability): KtType =
analysisSession.typeProvider.withNullability(this, newNullability)
}
@Suppress("PropertyName")
abstract class KtBuiltinTypes : ValidityTokenOwner {
abstract val INT: KtType
abstract val LONG: KtType
abstract val SHORT: KtType
abstract val BYTE: KtType
public abstract class KtBuiltinTypes : ValidityTokenOwner {
public abstract val INT: KtType
public abstract val LONG: KtType
public abstract val SHORT: KtType
public abstract val BYTE: KtType
abstract val FLOAT: KtType
abstract val DOUBLE: KtType
public abstract val FLOAT: KtType
public abstract val DOUBLE: KtType
abstract val BOOLEAN: KtType
abstract val CHAR: KtType
abstract val STRING: KtType
public abstract val BOOLEAN: KtType
public abstract val CHAR: KtType
public abstract val STRING: KtType
abstract val UNIT: KtType
abstract val NOTHING: KtType
abstract val ANY: KtType
public abstract val UNIT: KtType
public abstract val NOTHING: KtType
public abstract val ANY: KtType
abstract val NULLABLE_ANY: KtType
abstract val NULLABLE_NOTHING: KtType
public abstract val NULLABLE_ANY: KtType
public abstract val NULLABLE_NOTHING: KtType
}
@@ -10,8 +10,8 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtFileSymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithVisibility
import org.jetbrains.kotlin.psi.KtExpression
abstract class KtVisibilityChecker : KtAnalysisSessionComponent() {
abstract fun isVisible(
public abstract class KtVisibilityChecker : KtAnalysisSessionComponent() {
public abstract fun isVisible(
candidateSymbol: KtSymbolWithVisibility,
useSiteFile: KtFileSymbol,
position: PsiElement,
@@ -19,8 +19,8 @@ abstract class KtVisibilityChecker : KtAnalysisSessionComponent() {
): Boolean
}
interface KtVisibilityCheckerMixIn : KtAnalysisSessionMixIn {
fun isVisible(
public interface KtVisibilityCheckerMixIn : KtAnalysisSessionMixIn {
public fun isVisible(
candidateSymbol: KtSymbolWithVisibility,
useSiteFile: KtFileSymbol,
receiverExpression: KtExpression? = null,
@@ -12,19 +12,19 @@ import org.jetbrains.kotlin.idea.frontend.api.tokens.ValidityToken
import org.jetbrains.kotlin.idea.frontend.api.ValidityTokenOwner
import kotlin.reflect.KClass
interface KtDiagnostic : ValidityTokenOwner {
val severity: Severity
val factoryName: String?
val defaultMessage: String
public interface KtDiagnostic : ValidityTokenOwner {
public val severity: Severity
public val factoryName: String?
public val defaultMessage: String
}
interface KtDiagnosticWithPsi<out PSI: PsiElement> : KtDiagnostic {
val psi: PSI
val textRanges: Collection<TextRange>
val diagnosticClass: KClass<out KtDiagnosticWithPsi<PSI>>
public interface KtDiagnosticWithPsi<out PSI : PsiElement> : KtDiagnostic {
public val psi: PSI
public val textRanges: Collection<TextRange>
public val diagnosticClass: KClass<out KtDiagnosticWithPsi<PSI>>
}
class KtNonBoundToPsiErrorDiagnostic(
public class KtNonBoundToPsiErrorDiagnostic(
override val factoryName: String?,
override val defaultMessage: String,
override val token: ValidityToken,
@@ -32,6 +32,6 @@ class KtNonBoundToPsiErrorDiagnostic(
override val severity: Severity get() = Severity.ERROR
}
fun KtDiagnostic.getDefaultMessageWithFactoryName(): String =
public fun KtDiagnostic.getDefaultMessageWithFactoryName(): String =
if (factoryName == null) defaultMessage
else "[$factoryName] $defaultMessage"
@@ -9,33 +9,33 @@ import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
interface KtImportingScope : KtScope {
val imports: List<Import>
val isDefaultImportingScope: Boolean
public interface KtImportingScope : KtScope {
public val imports: List<Import>
public val isDefaultImportingScope: Boolean
}
interface KtStarImportingScope : KtImportingScope {
public interface KtStarImportingScope : KtImportingScope {
override val imports: List<StarImport>
}
interface KtNonStarImportingScope : KtImportingScope {
public interface KtNonStarImportingScope : KtImportingScope {
override val imports: List<NonStarImport>
}
sealed class Import {
abstract val packageFqName: FqName
abstract val relativeClassName: FqName?
abstract val resolvedClassId: ClassId?
public sealed class Import {
public abstract val packageFqName: FqName
public abstract val relativeClassName: FqName?
public abstract val resolvedClassId: ClassId?
}
class NonStarImport(
override val packageFqName: FqName,
public class NonStarImport(
public override val packageFqName: FqName,
override val relativeClassName: FqName?,
override val resolvedClassId: ClassId?,
val callableName: Name?,
public val callableName: Name?,
) : Import()
class StarImport(
public class StarImport(
override val packageFqName: FqName,
override val relativeClassName: FqName?,
override val resolvedClassId: ClassId?,
@@ -14,12 +14,12 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
interface KtScope : ValidityTokenOwner {
public interface KtScope : ValidityTokenOwner {
/**
* Returns a **subset** of names which current scope may contain.
* In other words `ALL_NAMES(scope)` is a subset of `scope.getAllNames()`
*/
fun getAllPossibleNames(): Set<Name> = withValidityAssertion {
public fun getAllPossibleNames(): Set<Name> = withValidityAssertion {
getPossibleCallableNames() + getPossibleClassifierNames()
}
@@ -27,19 +27,19 @@ interface KtScope : ValidityTokenOwner {
* Returns a **subset** of callable names which current scope may contain.
* In other words `ALL_CALLABLE_NAMES(scope)` is a subset of `scope.getCallableNames()`
*/
fun getPossibleCallableNames(): Set<Name>
public fun getPossibleCallableNames(): Set<Name>
/**
* Returns a **subset** of classifier names which current scope may contain.
* In other words `ALL_CLASSIFIER_NAMES(scope)` is a subset of `scope.getClassifierNames()`
*/
fun getPossibleClassifierNames(): Set<Name>
public fun getPossibleClassifierNames(): Set<Name>
/**
* Return a sequence of all [KtSymbol] which current scope contain
*/
fun getAllSymbols(): Sequence<KtSymbol> = withValidityAssertion {
public fun getAllSymbols(): Sequence<KtSymbol> = withValidityAssertion {
sequence {
yieldAll(getCallableSymbols())
yieldAll(getClassifierSymbols())
@@ -50,50 +50,50 @@ interface KtScope : ValidityTokenOwner {
/**
* Return a sequence of [KtCallableSymbol] which current scope contain if declaration name matches [nameFilter]
*/
fun getCallableSymbols(nameFilter: KtScopeNameFilter = { true }): Sequence<KtCallableSymbol>
public fun getCallableSymbols(nameFilter: KtScopeNameFilter = { true }): Sequence<KtCallableSymbol>
/**
* Return a sequence of [KtClassifierSymbol] which current scope contain if declaration name matches [nameFilter]
*/
fun getClassifierSymbols(nameFilter: KtScopeNameFilter = { true }): Sequence<KtClassifierSymbol>
public fun getClassifierSymbols(nameFilter: KtScopeNameFilter = { true }): Sequence<KtClassifierSymbol>
/**
* Return a sequence of [KtConstructorSymbol] which current scope contain
*/
fun getConstructors(): Sequence<KtConstructorSymbol>
public fun getConstructors(): Sequence<KtConstructorSymbol>
/**
* return true if the scope may contain name, false otherwise.
*
* In other words `(mayContainName(name) == false) => (name !in scope)`; vice versa is not always true
*/
fun mayContainName(name: Name): Boolean = withValidityAssertion {
public fun mayContainName(name: Name): Boolean = withValidityAssertion {
name in getPossibleCallableNames() || name in getPossibleClassifierNames()
}
}
typealias KtScopeNameFilter = (Name) -> Boolean
public typealias KtScopeNameFilter = (Name) -> Boolean
interface KtCompositeScope : KtScope {
val subScopes: List<KtScope>
public interface KtCompositeScope : KtScope {
public val subScopes: List<KtScope>
}
interface KtMemberScope : KtDeclarationScope<KtSymbolWithMembers> {
public interface KtMemberScope : KtDeclarationScope<KtSymbolWithMembers> {
override val owner: KtSymbolWithMembers
}
interface KtDeclaredMemberScope : KtDeclarationScope<KtSymbolWithMembers> {
public interface KtDeclaredMemberScope : KtDeclarationScope<KtSymbolWithMembers> {
override val owner: KtSymbolWithMembers
}
interface KtDeclarationScope<out T : KtSymbolWithDeclarations> : KtScope {
val owner: T
public interface KtDeclarationScope<out T : KtSymbolWithDeclarations> : KtScope {
public val owner: T
}
interface KtPackageScope : KtScope {
val fqName: FqName
public interface KtPackageScope : KtScope {
public val fqName: FqName
fun getPackageSymbols(nameFilter: KtScopeNameFilter = { true }): Sequence<KtPackageSymbol>
public fun getPackageSymbols(nameFilter: KtScopeNameFilter = { true }): Sequence<KtPackageSymbol>
override fun getAllSymbols(): Sequence<KtSymbol> = withValidityAssertion {
super.getAllSymbols() + getPackageSymbols()
@@ -15,8 +15,8 @@ import java.lang.reflect.InvocationTargetException
import kotlin.reflect.KProperty
import kotlin.reflect.jvm.javaGetter
object DebugSymbolRenderer {
fun render(symbol: KtSymbol): String = buildString {
public object DebugSymbolRenderer {
public fun render(symbol: KtSymbol): String = buildString {
val klass = symbol::class
appendLine("${klass.simpleName}:")
klass.members.filterIsInstance<KProperty<*>>().sortedBy { it.name }.forEach { property ->
@@ -10,12 +10,12 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtTypeAndAnnotatio
import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer
import org.jetbrains.kotlin.name.CallableId
abstract class KtCallableSymbol : KtSymbol, KtSymbolWithKind {
abstract val callableIdIfNonLocal: CallableId?
abstract val annotatedType: KtTypeAndAnnotations
public abstract class KtCallableSymbol : KtSymbol, KtSymbolWithKind {
public abstract val callableIdIfNonLocal: CallableId?
public abstract val annotatedType: KtTypeAndAnnotations
abstract val receiverType: KtTypeAndAnnotations?
abstract val isExtension: Boolean
public abstract val receiverType: KtTypeAndAnnotations?
public abstract val isExtension: Boolean
abstract override fun createPointer(): KtSymbolPointer<KtCallableSymbol>
}
@@ -13,48 +13,48 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.types.Variance
sealed class KtClassifierSymbol : KtSymbol, KtPossiblyNamedSymbol
public sealed class KtClassifierSymbol : KtSymbol, KtPossiblyNamedSymbol
val KtClassifierSymbol.nameOrAnonymous: Name
public val KtClassifierSymbol.nameOrAnonymous: Name
get() = name ?: SpecialNames.ANONYMOUS_FUNCTION
abstract class KtTypeParameterSymbol : KtClassifierSymbol(), KtNamedSymbol {
public abstract class KtTypeParameterSymbol : KtClassifierSymbol(), KtNamedSymbol {
abstract override fun createPointer(): KtSymbolPointer<KtTypeParameterSymbol>
abstract val upperBounds: List<KtType>
abstract val variance: Variance
abstract val isReified: Boolean
public abstract val upperBounds: List<KtType>
public abstract val variance: Variance
public abstract val isReified: Boolean
}
sealed class KtClassLikeSymbol : KtClassifierSymbol(), KtSymbolWithKind {
abstract val classIdIfNonLocal: ClassId?
public sealed class KtClassLikeSymbol : KtClassifierSymbol(), KtSymbolWithKind {
public abstract val classIdIfNonLocal: ClassId?
abstract override fun createPointer(): KtSymbolPointer<KtClassLikeSymbol>
}
abstract class KtTypeAliasSymbol : KtClassLikeSymbol(), KtNamedSymbol {
public abstract class KtTypeAliasSymbol : KtClassLikeSymbol(), KtNamedSymbol {
final override val symbolKind: KtSymbolKind get() = KtSymbolKind.TOP_LEVEL
/**
* Returns type from right-hand site of type alias
* If type alias has type parameters, then those type parameters will be present in result type
*/
abstract val expandedType: KtType
public abstract val expandedType: KtType
abstract override fun createPointer(): KtSymbolPointer<KtTypeAliasSymbol>
}
sealed class KtClassOrObjectSymbol : KtClassLikeSymbol(),
public sealed class KtClassOrObjectSymbol : KtClassLikeSymbol(),
KtAnnotatedSymbol,
KtSymbolWithMembers {
abstract val classKind: KtClassKind
abstract val superTypes: List<KtTypeAndAnnotations>
public abstract val classKind: KtClassKind
public abstract val superTypes: List<KtTypeAndAnnotations>
abstract override fun createPointer(): KtSymbolPointer<KtClassOrObjectSymbol>
}
abstract class KtAnonymousObjectSymbol : KtClassOrObjectSymbol() {
public abstract class KtAnonymousObjectSymbol : KtClassOrObjectSymbol() {
final override val classKind: KtClassKind get() = KtClassKind.ANONYMOUS_OBJECT
final override val classIdIfNonLocal: ClassId? get() = null
final override val symbolKind: KtSymbolKind get() = KtSymbolKind.LOCAL
@@ -63,25 +63,25 @@ abstract class KtAnonymousObjectSymbol : KtClassOrObjectSymbol() {
abstract override fun createPointer(): KtSymbolPointer<KtAnonymousObjectSymbol>
}
abstract class KtNamedClassOrObjectSymbol : KtClassOrObjectSymbol(),
public abstract class KtNamedClassOrObjectSymbol : KtClassOrObjectSymbol(),
KtSymbolWithTypeParameters,
KtSymbolWithModality,
KtSymbolWithVisibility,
KtNamedSymbol {
abstract val isInner: Boolean
abstract val isData: Boolean
abstract val isInline: Boolean
abstract val isFun: Boolean
public abstract val isInner: Boolean
public abstract val isData: Boolean
public abstract val isInline: Boolean
public abstract val isFun: Boolean
abstract val isExternal: Boolean
public abstract val isExternal: Boolean
abstract val companionObject: KtNamedClassOrObjectSymbol?
public abstract val companionObject: KtNamedClassOrObjectSymbol?
abstract override fun createPointer(): KtSymbolPointer<KtNamedClassOrObjectSymbol>
}
enum class KtClassKind {
public enum class KtClassKind {
CLASS,
ENUM_CLASS,
ENUM_ENTRY,
@@ -91,5 +91,5 @@ enum class KtClassKind {
INTERFACE,
ANONYMOUS_OBJECT;
val isObject: Boolean get() = this == OBJECT || this == COMPANION_OBJECT || this == ANONYMOUS_OBJECT
public val isObject: Boolean get() = this == OBJECT || this == COMPANION_OBJECT || this == ANONYMOUS_OBJECT
}
@@ -8,6 +8,6 @@ package org.jetbrains.kotlin.idea.frontend.api.symbols
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtAnnotatedSymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer
abstract class KtFileSymbol : KtAnnotatedSymbol {
public abstract class KtFileSymbol : KtAnnotatedSymbol {
abstract override fun createPointer(): KtSymbolPointer<KtFileSymbol>
}
@@ -11,20 +11,20 @@ import org.jetbrains.kotlin.name.CallableId
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
abstract class KtFunctionLikeSymbol : KtCallableSymbol(), KtSymbolWithKind {
abstract val valueParameters: List<KtValueParameterSymbol>
public abstract class KtFunctionLikeSymbol : KtCallableSymbol(), KtSymbolWithKind {
public abstract val valueParameters: List<KtValueParameterSymbol>
abstract override fun createPointer(): KtSymbolPointer<KtFunctionLikeSymbol>
}
abstract class KtAnonymousFunctionSymbol : KtFunctionLikeSymbol() {
public abstract class KtAnonymousFunctionSymbol : KtFunctionLikeSymbol() {
final override val symbolKind: KtSymbolKind get() = KtSymbolKind.LOCAL
final override val callableIdIfNonLocal: CallableId? get() = null
abstract override fun createPointer(): KtSymbolPointer<KtAnonymousFunctionSymbol>
}
abstract class KtFunctionSymbol : KtFunctionLikeSymbol(),
public abstract class KtFunctionSymbol : KtFunctionLikeSymbol(),
KtNamedSymbol,
KtPossibleMemberSymbol,
KtSymbolWithTypeParameters,
@@ -32,24 +32,24 @@ abstract class KtFunctionSymbol : KtFunctionLikeSymbol(),
KtSymbolWithVisibility,
KtAnnotatedSymbol {
abstract val isSuspend: Boolean
abstract val isOperator: Boolean
abstract val isExternal: Boolean
abstract val isInline: Boolean
abstract val isOverride: Boolean
abstract val isInfix: Boolean
abstract val isStatic: Boolean
public abstract val isSuspend: Boolean
public abstract val isOperator: Boolean
public abstract val isExternal: Boolean
public abstract val isInline: Boolean
public abstract val isOverride: Boolean
public abstract val isInfix: Boolean
public abstract val isStatic: Boolean
abstract override fun createPointer(): KtSymbolPointer<KtFunctionSymbol>
}
abstract class KtConstructorSymbol : KtFunctionLikeSymbol(),
public abstract class KtConstructorSymbol : KtFunctionLikeSymbol(),
KtPossibleMemberSymbol,
KtAnnotatedSymbol,
KtSymbolWithVisibility,
KtSymbolWithTypeParameters {
abstract val isPrimary: Boolean
abstract val containingClassIdIfNonLocal: ClassId?
public abstract val isPrimary: Boolean
public abstract val containingClassIdIfNonLocal: ClassId?
final override val callableIdIfNonLocal: CallableId? get() = null
final override val symbolKind: KtSymbolKind get() = KtSymbolKind.MEMBER
@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.idea.frontend.api.symbols
import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer
import org.jetbrains.kotlin.name.FqName
abstract class KtPackageSymbol : KtSymbol {
abstract val fqName: FqName
public abstract class KtPackageSymbol : KtSymbol {
public abstract val fqName: FqName
abstract override fun createPointer(): KtSymbolPointer<KtPackageSymbol>
}
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.*
import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer
import org.jetbrains.kotlin.name.CallableId
sealed class KtPropertyAccessorSymbol : KtCallableSymbol(),
public sealed class KtPropertyAccessorSymbol : KtCallableSymbol(),
KtPossibleMemberSymbol,
KtSymbolWithModality,
KtSymbolWithVisibility,
@@ -20,22 +20,22 @@ sealed class KtPropertyAccessorSymbol : KtCallableSymbol(),
final override val isExtension: Boolean get() = false
final override val receiverType: KtTypeAndAnnotations? get() = null
abstract val isDefault: Boolean
abstract val isInline: Boolean
abstract val isOverride: Boolean
abstract val hasBody: Boolean
public abstract val isDefault: Boolean
public abstract val isInline: Boolean
public abstract val isOverride: Boolean
public abstract val hasBody: Boolean
final override val symbolKind: KtSymbolKind get() = KtSymbolKind.ACCESSOR
abstract override fun createPointer(): KtSymbolPointer<KtPropertyAccessorSymbol>
}
abstract class KtPropertyGetterSymbol : KtPropertyAccessorSymbol() {
public abstract class KtPropertyGetterSymbol : KtPropertyAccessorSymbol() {
abstract override fun createPointer(): KtSymbolPointer<KtPropertyGetterSymbol>
}
abstract class KtPropertySetterSymbol : KtPropertyAccessorSymbol() {
abstract val parameter: KtValueParameterSymbol
public abstract class KtPropertySetterSymbol : KtPropertyAccessorSymbol() {
public abstract val parameter: KtValueParameterSymbol
abstract override fun createPointer(): KtSymbolPointer<KtPropertySetterSymbol>
}
@@ -9,8 +9,8 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.idea.frontend.api.ValidityTokenOwner
import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer
interface KtSymbol : ValidityTokenOwner {
val origin: KtSymbolOrigin
public interface KtSymbol : ValidityTokenOwner {
public val origin: KtSymbolOrigin
/**
* [PsiElement] which corresponds to given [KtSymbol]
@@ -19,9 +19,9 @@ interface KtSymbol : ValidityTokenOwner {
*
* For [KtSymbolOrigin.LIBRARY] the generated by Kotlin class file source element is returned
*/
val psi: PsiElement?
public val psi: PsiElement?
fun createPointer(): KtSymbolPointer<KtSymbol>
public fun createPointer(): KtSymbolPointer<KtSymbol>
}
/**
@@ -29,7 +29,7 @@ interface KtSymbol : ValidityTokenOwner {
*
* @see KtSymbol.psi
*/
inline fun <reified PSI : PsiElement> KtSymbol.psi(): PSI =
public inline fun <reified PSI : PsiElement> KtSymbol.psi(): PSI =
psi as PSI
/**
@@ -37,13 +37,13 @@ inline fun <reified PSI : PsiElement> KtSymbol.psi(): PSI =
*
* @see KtSymbol.psi
*/
inline fun <reified PSI : PsiElement> KtSymbol.psiSafe(): PSI? =
public inline fun <reified PSI : PsiElement> KtSymbol.psiSafe(): PSI? =
psi as? PSI
/**
* A place where [KtSymbol] came from
*/
enum class KtSymbolOrigin {
public enum class KtSymbolOrigin {
/**
* Declaration from Kotlin sources
*/
@@ -12,8 +12,8 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
abstract class KtSymbolProvider : KtAnalysisSessionComponent() {
open fun getSymbol(psi: KtDeclaration): KtSymbol = when (psi) {
public abstract class KtSymbolProvider : KtAnalysisSessionComponent() {
public open fun getSymbol(psi: KtDeclaration): KtSymbol = when (psi) {
is KtParameter -> getParameterSymbol(psi)
is KtNamedFunction -> getFunctionLikeSymbol(psi)
is KtConstructor<*> -> getConstructorSymbol(psi)
@@ -30,34 +30,34 @@ abstract class KtSymbolProvider : KtAnalysisSessionComponent() {
else -> error("Cannot build symbol for ${psi::class}")
}
abstract fun getParameterSymbol(psi: KtParameter): KtValueParameterSymbol
abstract fun getFileSymbol(psi: KtFile): KtFileSymbol
abstract fun getFunctionLikeSymbol(psi: KtNamedFunction): KtFunctionLikeSymbol
abstract fun getConstructorSymbol(psi: KtConstructor<*>): KtConstructorSymbol
abstract fun getTypeParameterSymbol(psi: KtTypeParameter): KtTypeParameterSymbol
abstract fun getTypeAliasSymbol(psi: KtTypeAlias): KtTypeAliasSymbol
abstract fun getEnumEntrySymbol(psi: KtEnumEntry): KtEnumEntrySymbol
abstract fun getAnonymousFunctionSymbol(psi: KtNamedFunction): KtAnonymousFunctionSymbol
abstract fun getAnonymousFunctionSymbol(psi: KtFunctionLiteral): KtAnonymousFunctionSymbol
abstract fun getVariableSymbol(psi: KtProperty): KtVariableSymbol
abstract fun getAnonymousObjectSymbol(psi: KtObjectLiteralExpression): KtAnonymousObjectSymbol
abstract fun getClassOrObjectSymbol(psi: KtClassOrObject): KtClassOrObjectSymbol
abstract fun getNamedClassOrObjectSymbol(psi: KtClassOrObject): KtNamedClassOrObjectSymbol
abstract fun getPropertyAccessorSymbol(psi: KtPropertyAccessor): KtPropertyAccessorSymbol
public abstract fun getParameterSymbol(psi: KtParameter): KtValueParameterSymbol
public abstract fun getFileSymbol(psi: KtFile): KtFileSymbol
public abstract fun getFunctionLikeSymbol(psi: KtNamedFunction): KtFunctionLikeSymbol
public abstract fun getConstructorSymbol(psi: KtConstructor<*>): KtConstructorSymbol
public abstract fun getTypeParameterSymbol(psi: KtTypeParameter): KtTypeParameterSymbol
public abstract fun getTypeAliasSymbol(psi: KtTypeAlias): KtTypeAliasSymbol
public abstract fun getEnumEntrySymbol(psi: KtEnumEntry): KtEnumEntrySymbol
public abstract fun getAnonymousFunctionSymbol(psi: KtNamedFunction): KtAnonymousFunctionSymbol
public abstract fun getAnonymousFunctionSymbol(psi: KtFunctionLiteral): KtAnonymousFunctionSymbol
public abstract fun getVariableSymbol(psi: KtProperty): KtVariableSymbol
public abstract fun getAnonymousObjectSymbol(psi: KtObjectLiteralExpression): KtAnonymousObjectSymbol
public abstract fun getClassOrObjectSymbol(psi: KtClassOrObject): KtClassOrObjectSymbol
public abstract fun getNamedClassOrObjectSymbol(psi: KtClassOrObject): KtNamedClassOrObjectSymbol
public abstract fun getPropertyAccessorSymbol(psi: KtPropertyAccessor): KtPropertyAccessorSymbol
abstract fun getClassOrObjectSymbolByClassId(classId: ClassId): KtClassOrObjectSymbol?
public abstract fun getClassOrObjectSymbolByClassId(classId: ClassId): KtClassOrObjectSymbol?
abstract fun getTopLevelCallableSymbols(packageFqName: FqName, name: Name): Sequence<KtSymbol>
public abstract fun getTopLevelCallableSymbols(packageFqName: FqName, name: Name): Sequence<KtSymbol>
@Suppress("PropertyName")
abstract val ROOT_PACKAGE_SYMBOL: KtPackageSymbol
public abstract val ROOT_PACKAGE_SYMBOL: KtPackageSymbol
}
interface KtSymbolProviderMixIn : KtAnalysisSessionMixIn {
fun KtDeclaration.getSymbol(): KtSymbol =
public interface KtSymbolProviderMixIn : KtAnalysisSessionMixIn {
public fun KtDeclaration.getSymbol(): KtSymbol =
analysisSession.symbolProvider.getSymbol(this)
fun KtParameter.getParameterSymbol(): KtValueParameterSymbol =
public fun KtParameter.getParameterSymbol(): KtValueParameterSymbol =
analysisSession.symbolProvider.getParameterSymbol(this)
/**
@@ -66,55 +66,55 @@ interface KtSymbolProviderMixIn : KtAnalysisSessionMixIn {
* If [KtNamedFunction.getName] is `null` then returns [KtAnonymousFunctionSymbol]
* Otherwise, returns [KtFunctionSymbol]
*/
fun KtNamedFunction.getFunctionLikeSymbol(): KtFunctionLikeSymbol =
public fun KtNamedFunction.getFunctionLikeSymbol(): KtFunctionLikeSymbol =
analysisSession.symbolProvider.getFunctionLikeSymbol(this)
fun KtConstructor<*>.getConstructorSymbol(): KtConstructorSymbol =
public fun KtConstructor<*>.getConstructorSymbol(): KtConstructorSymbol =
analysisSession.symbolProvider.getConstructorSymbol(this)
fun KtTypeParameter.getTypeParameterSymbol(): KtTypeParameterSymbol =
public fun KtTypeParameter.getTypeParameterSymbol(): KtTypeParameterSymbol =
analysisSession.symbolProvider.getTypeParameterSymbol(this)
fun KtTypeAlias.getTypeAliasSymbol(): KtTypeAliasSymbol =
public fun KtTypeAlias.getTypeAliasSymbol(): KtTypeAliasSymbol =
analysisSession.symbolProvider.getTypeAliasSymbol(this)
fun KtEnumEntry.getEnumEntrySymbol(): KtEnumEntrySymbol =
public fun KtEnumEntry.getEnumEntrySymbol(): KtEnumEntrySymbol =
analysisSession.symbolProvider.getEnumEntrySymbol(this)
fun KtNamedFunction.getAnonymousFunctionSymbol(): KtAnonymousFunctionSymbol =
public fun KtNamedFunction.getAnonymousFunctionSymbol(): KtAnonymousFunctionSymbol =
analysisSession.symbolProvider.getAnonymousFunctionSymbol(this)
fun KtFunctionLiteral.getAnonymousFunctionSymbol(): KtAnonymousFunctionSymbol =
public fun KtFunctionLiteral.getAnonymousFunctionSymbol(): KtAnonymousFunctionSymbol =
analysisSession.symbolProvider.getAnonymousFunctionSymbol(this)
fun KtProperty.getVariableSymbol(): KtVariableSymbol =
public fun KtProperty.getVariableSymbol(): KtVariableSymbol =
analysisSession.symbolProvider.getVariableSymbol(this)
fun KtObjectLiteralExpression.getAnonymousObjectSymbol(): KtAnonymousObjectSymbol =
public fun KtObjectLiteralExpression.getAnonymousObjectSymbol(): KtAnonymousObjectSymbol =
analysisSession.symbolProvider.getAnonymousObjectSymbol(this)
fun KtClassOrObject.getClassOrObjectSymbol(): KtClassOrObjectSymbol =
public fun KtClassOrObject.getClassOrObjectSymbol(): KtClassOrObjectSymbol =
analysisSession.symbolProvider.getClassOrObjectSymbol(this)
fun KtClassOrObject.getNamedClassOrObjectSymbol(): KtNamedClassOrObjectSymbol =
public fun KtClassOrObject.getNamedClassOrObjectSymbol(): KtNamedClassOrObjectSymbol =
analysisSession.symbolProvider.getNamedClassOrObjectSymbol(this)
fun KtPropertyAccessor.getPropertyAccessorSymbol(): KtPropertyAccessorSymbol =
public fun KtPropertyAccessor.getPropertyAccessorSymbol(): KtPropertyAccessorSymbol =
analysisSession.symbolProvider.getPropertyAccessorSymbol(this)
fun KtFile.getFileSymbol(): KtFileSymbol =
public fun KtFile.getFileSymbol(): KtFileSymbol =
analysisSession.symbolProvider.getFileSymbol(this)
/**
* @return symbol with specified [this@getClassOrObjectSymbolByClassId] or `null` in case such symbol is not found
*/
fun ClassId.getCorrespondingToplevelClassOrObjectSymbol(): KtClassOrObjectSymbol? =
public fun ClassId.getCorrespondingToplevelClassOrObjectSymbol(): KtClassOrObjectSymbol? =
analysisSession.symbolProvider.getClassOrObjectSymbolByClassId(this)
fun FqName.getContainingCallableSymbolsWithName(name: Name): Sequence<KtSymbol> =
public fun FqName.getContainingCallableSymbolsWithName(name: Name): Sequence<KtSymbol> =
analysisSession.symbolProvider.getTopLevelCallableSymbols(this, name)
@Suppress("PropertyName")
val ROOT_PACKAGE_SYMBOL: KtPackageSymbol
public val ROOT_PACKAGE_SYMBOL: KtPackageSymbol
get() = analysisSession.symbolProvider.ROOT_PACKAGE_SYMBOL
}
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
sealed class KtVariableLikeSymbol : KtCallableSymbol(), KtNamedSymbol, KtSymbolWithKind {
public sealed class KtVariableLikeSymbol : KtCallableSymbol(), KtNamedSymbol, KtSymbolWithKind {
abstract override fun createPointer(): KtSymbolPointer<KtVariableLikeSymbol>
}
@@ -28,8 +28,8 @@ sealed class KtVariableLikeSymbol : KtCallableSymbol(), KtNamedSymbol, KtSymbolW
*
* Symbol at caret will be resolved to a [KtBackingFieldSymbol]
*/
abstract class KtBackingFieldSymbol : KtVariableLikeSymbol() {
abstract val owningProperty: KtKotlinPropertySymbol
public abstract class KtBackingFieldSymbol : KtVariableLikeSymbol() {
public abstract val owningProperty: KtKotlinPropertySymbol
final override val name: Name get() = fieldName
final override val psi: PsiElement? get() = null
@@ -41,29 +41,29 @@ abstract class KtBackingFieldSymbol : KtVariableLikeSymbol() {
abstract override fun createPointer(): KtSymbolPointer<KtVariableLikeSymbol>
companion object {
public companion object {
private val fieldName = Name.identifier("field")
}
}
abstract class KtEnumEntrySymbol : KtVariableLikeSymbol(), KtSymbolWithMembers, KtSymbolWithKind {
public abstract class KtEnumEntrySymbol : KtVariableLikeSymbol(), KtSymbolWithMembers, KtSymbolWithKind {
final override val symbolKind: KtSymbolKind get() = KtSymbolKind.MEMBER
final override val isExtension: Boolean get() = false
final override val receiverType: KtTypeAndAnnotations? get() = null
abstract val containingEnumClassIdIfNonLocal: ClassId?
public abstract val containingEnumClassIdIfNonLocal: ClassId?
abstract override fun createPointer(): KtSymbolPointer<KtEnumEntrySymbol>
}
sealed class KtVariableSymbol : KtVariableLikeSymbol() {
abstract val isVal: Boolean
public sealed class KtVariableSymbol : KtVariableLikeSymbol() {
public abstract val isVal: Boolean
abstract override fun createPointer(): KtSymbolPointer<KtVariableSymbol>
}
abstract class KtJavaFieldSymbol :
public abstract class KtJavaFieldSymbol :
KtVariableSymbol(),
KtSymbolWithModality,
KtSymbolWithVisibility,
@@ -71,56 +71,56 @@ abstract class KtJavaFieldSymbol :
final override val symbolKind: KtSymbolKind get() = KtSymbolKind.MEMBER
final override val isExtension: Boolean get() = false
final override val receiverType: KtTypeAndAnnotations? get() = null
abstract val isStatic: Boolean
public abstract val isStatic: Boolean
abstract override fun createPointer(): KtSymbolPointer<KtJavaFieldSymbol>
}
sealed class KtPropertySymbol : KtVariableSymbol(),
public sealed class KtPropertySymbol : KtVariableSymbol(),
KtPossibleMemberSymbol,
KtSymbolWithModality,
KtSymbolWithVisibility,
KtAnnotatedSymbol,
KtSymbolWithKind {
abstract val hasGetter: Boolean
abstract val hasSetter: Boolean
public abstract val hasGetter: Boolean
public abstract val hasSetter: Boolean
abstract val getter: KtPropertyGetterSymbol?
abstract val setter: KtPropertySetterSymbol?
public abstract val getter: KtPropertyGetterSymbol?
public abstract val setter: KtPropertySetterSymbol?
abstract val hasBackingField: Boolean
public abstract val hasBackingField: Boolean
abstract val isOverride: Boolean
abstract val isStatic: Boolean
public abstract val isOverride: Boolean
public abstract val isStatic: Boolean
abstract val initializer: KtConstantValue?
public abstract val initializer: KtConstantValue?
abstract override fun createPointer(): KtSymbolPointer<KtPropertySymbol>
}
abstract class KtKotlinPropertySymbol : KtPropertySymbol() {
abstract val isLateInit: Boolean
public abstract class KtKotlinPropertySymbol : KtPropertySymbol() {
public abstract val isLateInit: Boolean
abstract val isConst: Boolean
public abstract val isConst: Boolean
abstract override fun createPointer(): KtSymbolPointer<KtKotlinPropertySymbol>
}
abstract class KtSyntheticJavaPropertySymbol : KtPropertySymbol() {
public abstract class KtSyntheticJavaPropertySymbol : KtPropertySymbol() {
final override val hasBackingField: Boolean get() = true
final override val hasGetter: Boolean get() = true
final override val symbolKind: KtSymbolKind get() = KtSymbolKind.MEMBER
abstract override val getter: KtPropertyGetterSymbol
abstract val javaGetterName: Name
abstract val javaSetterName: Name?
public abstract val javaGetterName: Name
public abstract val javaSetterName: Name?
abstract override fun createPointer(): KtSymbolPointer<KtSyntheticJavaPropertySymbol>
}
abstract class KtLocalVariableSymbol : KtVariableSymbol(), KtSymbolWithKind {
public abstract class KtLocalVariableSymbol : KtVariableSymbol(), KtSymbolWithKind {
final override val callableIdIfNonLocal: CallableId? get() = null
final override val isExtension: Boolean get() = false
final override val receiverType: KtTypeAndAnnotations? get() = null
@@ -128,14 +128,14 @@ abstract class KtLocalVariableSymbol : KtVariableSymbol(), KtSymbolWithKind {
abstract override fun createPointer(): KtSymbolPointer<KtLocalVariableSymbol>
}
abstract class KtValueParameterSymbol : KtVariableLikeSymbol(), KtSymbolWithKind, KtAnnotatedSymbol {
public abstract class KtValueParameterSymbol : KtVariableLikeSymbol(), KtSymbolWithKind, KtAnnotatedSymbol {
final override val symbolKind: KtSymbolKind get() = KtSymbolKind.LOCAL
final override val callableIdIfNonLocal: CallableId? get() = null
final override val isExtension: Boolean get() = false
final override val receiverType: KtTypeAndAnnotations? get() = null
abstract val hasDefaultValue: Boolean
abstract val isVararg: Boolean
public abstract val hasDefaultValue: Boolean
public abstract val isVararg: Boolean
abstract override fun createPointer(): KtSymbolPointer<KtValueParameterSymbol>
}
@@ -11,18 +11,18 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.psi.KtCallElement
abstract class KtAnnotationCall : ValidityTokenOwner {
abstract val classId: ClassId?
abstract val useSiteTarget: AnnotationUseSiteTarget?
abstract val psi: KtCallElement?
abstract val arguments: List<KtNamedConstantValue>
public abstract class KtAnnotationCall : ValidityTokenOwner {
public abstract val classId: ClassId?
public abstract val useSiteTarget: AnnotationUseSiteTarget?
public abstract val psi: KtCallElement?
public abstract val arguments: List<KtNamedConstantValue>
}
data class KtNamedConstantValue(val name: String, val expression: KtConstantValue)
public data class KtNamedConstantValue(val name: String, val expression: KtConstantValue)
interface KtAnnotatedSymbol : KtSymbol {
val annotations: List<KtAnnotationCall>
public interface KtAnnotatedSymbol : KtSymbol {
public val annotations: List<KtAnnotationCall>
fun containsAnnotation(classId: ClassId): Boolean
val annotationClassIds: Collection<ClassId>
public fun containsAnnotation(classId: ClassId): Boolean
public val annotationClassIds: Collection<ClassId>
}
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.idea.frontend.api.symbols.markers
import org.jetbrains.kotlin.types.ConstantValueKind
sealed class KtConstantValue
object KtUnsupportedConstantValue : KtConstantValue()
public sealed class KtConstantValue
public object KtUnsupportedConstantValue : KtConstantValue()
data class KtSimpleConstantValue<T>(val constantValueKind: ConstantValueKind<T>, val value: T) : KtConstantValue()
public data class KtSimpleConstantValue<T>(val constantValueKind: ConstantValueKind<T>, val value: T) : KtConstantValue()
@@ -7,6 +7,6 @@ package org.jetbrains.kotlin.idea.frontend.api.symbols.markers
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
interface KtPossibleMemberSymbol {
val dispatchType: KtType?
public interface KtPossibleMemberSymbol {
public val dispatchType: KtType?
}
@@ -10,11 +10,11 @@ import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
interface KtSymbolWithKind : KtSymbol {
val symbolKind: KtSymbolKind
public interface KtSymbolWithKind : KtSymbol {
public val symbolKind: KtSymbolKind
}
enum class KtSymbolKind {
public enum class KtSymbolKind {
TOP_LEVEL, MEMBER, LOCAL, ACCESSOR
}
@@ -7,6 +7,6 @@ package org.jetbrains.kotlin.idea.frontend.api.symbols.markers
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol
interface KtSymbolWithMembers : KtSymbolWithDeclarations
public interface KtSymbolWithMembers : KtSymbolWithDeclarations
interface KtSymbolWithDeclarations : KtSymbol
public interface KtSymbolWithDeclarations : KtSymbol
@@ -7,6 +7,6 @@ package org.jetbrains.kotlin.idea.frontend.api.symbols.markers
import org.jetbrains.kotlin.descriptors.Modality
interface KtSymbolWithModality {
val modality: Modality
public interface KtSymbolWithModality {
public val modality: Modality
}
@@ -8,10 +8,10 @@ package org.jetbrains.kotlin.idea.frontend.api.symbols.markers
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.descriptors.Visibility
interface KtSymbolWithVisibility {
val visibility: Visibility
public interface KtSymbolWithVisibility {
public val visibility: Visibility
}
fun Visibility.isPrivateOrPrivateToThis(): Boolean =
public fun Visibility.isPrivateOrPrivateToThis(): Boolean =
this == Visibilities.Private || this == Visibilities.PrivateToThis
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.idea.frontend.api.ValidityTokenOwner
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtCallableSymbol
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
abstract class KtTypeAndAnnotations : ValidityTokenOwner {
abstract val type: KtType
abstract val annotations: List<KtAnnotationCall>
public abstract class KtTypeAndAnnotations : ValidityTokenOwner {
public abstract val type: KtType
public abstract val annotations: List<KtAnnotationCall>
}
@@ -10,14 +10,14 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtTypeParameterSymbol
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
import org.jetbrains.kotlin.name.Name
interface KtPossiblyNamedSymbol : KtSymbol {
val name: Name?
public interface KtPossiblyNamedSymbol : KtSymbol {
public val name: Name?
}
interface KtNamedSymbol : KtPossiblyNamedSymbol {
abstract override val name: Name
public interface KtNamedSymbol : KtPossiblyNamedSymbol {
override val name: Name
}
interface KtSymbolWithTypeParameters {
val typeParameters: List<KtTypeParameterSymbol>
public interface KtSymbolWithTypeParameters {
public val typeParameters: List<KtTypeParameterSymbol>
}
@@ -5,5 +5,5 @@
package org.jetbrains.kotlin.idea.frontend.api.symbols.pointers
class CanNotCreateSymbolPointerForLocalLibraryDeclarationException(description: String) :
public class CanNotCreateSymbolPointerForLocalLibraryDeclarationException(description: String) :
IllegalStateException("Could not create a symbol pointer for local symbol $description")
@@ -13,7 +13,8 @@ import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtObjectLiteralExpression
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
class KtPsiBasedSymbolPointer<S : KtSymbol>(private val psiPointer: SmartPsiElementPointer<out KtDeclaration>) : KtSymbolPointer<S>() {
public class KtPsiBasedSymbolPointer<S : KtSymbol>(private val psiPointer: SmartPsiElementPointer<out KtDeclaration>) :
KtSymbolPointer<S>() {
override fun restoreSymbol(analysisSession: KtAnalysisSession): S? {
val psi = psiPointer.element ?: return null
@@ -21,10 +22,10 @@ class KtPsiBasedSymbolPointer<S : KtSymbol>(private val psiPointer: SmartPsiElem
return with(analysisSession) { psi.getSymbol() } as S?
}
companion object {
fun <S : KtSymbol> createForSymbolFromSource(symbol: S): KtPsiBasedSymbolPointer<S>? {
public companion object {
public fun <S : KtSymbol> createForSymbolFromSource(symbol: S): KtPsiBasedSymbolPointer<S>? {
if (symbol.origin == KtSymbolOrigin.LIBRARY) return null
val psi = when(val psi = symbol.psi) {
val psi = when (val psi = symbol.psi) {
is KtDeclaration -> psi
is KtObjectLiteralExpression -> psi.objectDeclaration
else -> null
@@ -23,16 +23,17 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol
*
* @see org.jetbrains.kotlin.idea.frontend.api.ReadActionConfinementValidityToken
*/
abstract class KtSymbolPointer<out S : KtSymbol> {
public abstract class KtSymbolPointer<out S : KtSymbol> {
/**
* @return restored symbol (possibly the new symbol instance) if one is still valid, `null` otherwise
*
* Consider using [org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession.restoreSymbol]
*/
@Deprecated("Consider using org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession.restoreSymbol")
abstract fun restoreSymbol(analysisSession: KtAnalysisSession): S?
public abstract fun restoreSymbol(analysisSession: KtAnalysisSession): S?
}
inline fun <S : KtSymbol> symbolPointer(crossinline getSymbol: (KtAnalysisSession) -> S?) = object : KtSymbolPointer<S>() {
override fun restoreSymbol(analysisSession: KtAnalysisSession): S? = getSymbol(analysisSession)
}
public inline fun <S : KtSymbol> symbolPointer(crossinline getSymbol: (KtAnalysisSession) -> S?): KtSymbolPointer<S> =
object : KtSymbolPointer<S>() {
override fun restoreSymbol(analysisSession: KtAnalysisSession): S? = getSymbol(analysisSession)
}
@@ -9,7 +9,7 @@ import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.idea.fir.low.level.api.api.createProjectWideOutOfBlockModificationTracker
import kotlin.reflect.KClass
class AlwaysAccessibleValidityToken(project: Project) : ValidityToken() {
public class AlwaysAccessibleValidityToken(project: Project) : ValidityToken() {
private val modificationTracker = project.createProjectWideOutOfBlockModificationTracker()
private val onCreatedTimeStamp = modificationTracker.modificationCount
@@ -31,7 +31,7 @@ class AlwaysAccessibleValidityToken(project: Project) : ValidityToken() {
}
}
object AlwaysAccessibleValidityTokenFactory : ValidityTokenFactory() {
public object AlwaysAccessibleValidityTokenFactory : ValidityTokenFactory() {
override val identifier: KClass<out ValidityToken> = AlwaysAccessibleValidityToken::class
override fun create(project: Project): ValidityToken =
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.idea.fir.low.level.api.api.createProjectWideOutOfBlo
import org.jetbrains.kotlin.idea.frontend.api.*
import kotlin.reflect.KClass
class ReadActionConfinementValidityToken(project: Project) : ValidityToken() {
public class ReadActionConfinementValidityToken(project: Project) : ValidityToken() {
private val modificationTracker = project.createProjectWideOutOfBlockModificationTracker()
private val onCreatedTimeStamp = modificationTracker.modificationCount
@@ -48,13 +48,13 @@ class ReadActionConfinementValidityToken(project: Project) : ValidityToken() {
}
companion object {
public companion object {
@HackToForceAllowRunningAnalyzeOnEDT
val allowOnEdt: ThreadLocal<Boolean> = ThreadLocal.withInitial { false }
public val allowOnEdt: ThreadLocal<Boolean> = ThreadLocal.withInitial { false }
}
}
object ReadActionConfinementValidityTokenFactory : ValidityTokenFactory() {
public object ReadActionConfinementValidityTokenFactory : ValidityTokenFactory() {
override val identifier: KClass<out ValidityToken> = ReadActionConfinementValidityToken::class
override fun create(project: Project): ValidityToken = ReadActionConfinementValidityToken(project)
@@ -73,7 +73,7 @@ object ReadActionConfinementValidityTokenFactory : ValidityTokenFactory() {
}
@RequiresOptIn("All frontend related work should not be allowed to be ran from EDT thread. Only use it as a temporary solution")
annotation class HackToForceAllowRunningAnalyzeOnEDT
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.
@@ -82,7 +82,7 @@ annotation class HackToForceAllowRunningAnalyzeOnEDT
* @see ReadActionConfinementValidityToken
*/
@HackToForceAllowRunningAnalyzeOnEDT
inline fun <T> hackyAllowRunningOnEdt(action: () -> T): T {
public inline fun <T> hackyAllowRunningOnEdt(action: () -> T): T {
if (ReadActionConfinementValidityToken.allowOnEdt.get()) return action()
ReadActionConfinementValidityToken.allowOnEdt.set(true)
try {
@@ -8,25 +8,25 @@ package org.jetbrains.kotlin.idea.frontend.api.tokens
import com.intellij.openapi.project.Project
import kotlin.reflect.KClass
abstract class ValidityToken {
abstract fun isValid(): Boolean
abstract fun getInvalidationReason(): String
public abstract class ValidityToken {
public abstract fun isValid(): Boolean
public abstract fun getInvalidationReason(): String
abstract fun isAccessible(): Boolean
abstract fun getInaccessibilityReason(): String
public abstract fun isAccessible(): Boolean
public abstract fun getInaccessibilityReason(): String
}
abstract class ValidityTokenFactory {
abstract val identifier: KClass<out ValidityToken>
abstract fun create(project: Project): ValidityToken
public abstract class ValidityTokenFactory {
public abstract val identifier: KClass<out ValidityToken>
public abstract fun create(project: Project): ValidityToken
open fun beforeEnteringAnalysisContext() {}
open fun afterLeavingAnalysisContext() {}
public open fun beforeEnteringAnalysisContext() {}
public open fun afterLeavingAnalysisContext() {}
}
@Suppress("NOTHING_TO_INLINE")
inline fun ValidityToken.assertIsValidAndAccessible() {
public inline fun ValidityToken.assertIsValidAndAccessible() {
if (!isValid()) {
throw InvalidEntityAccessException("Access to invalid $this: ${getInvalidationReason()}")
}
@@ -35,8 +35,8 @@ inline fun ValidityToken.assertIsValidAndAccessible() {
}
}
abstract class BadEntityAccessException() : IllegalStateException()
public abstract class BadEntityAccessException() : IllegalStateException()
class InvalidEntityAccessException(override val message: String) : BadEntityAccessException()
class InaccessibleEntityAccessException(override val message: String) : BadEntityAccessException()
public class InvalidEntityAccessException(override val message: String) : BadEntityAccessException()
public class InaccessibleEntityAccessException(override val message: String) : BadEntityAccessException()
@@ -12,73 +12,73 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtTypeParameterSymbol
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
sealed interface KtType : ValidityTokenOwner {
fun asStringForDebugging(): String
public sealed interface KtType : ValidityTokenOwner {
public fun asStringForDebugging(): String
}
interface KtTypeWithNullability : KtType {
val nullability: KtTypeNullability
public interface KtTypeWithNullability : KtType {
public val nullability: KtTypeNullability
}
enum class KtTypeNullability(val isNullable: Boolean) {
public enum class KtTypeNullability(public val isNullable: Boolean) {
NULLABLE(true), NON_NULLABLE(false);
companion object {
fun create(isNullable: Boolean) = if (isNullable) NULLABLE else NON_NULLABLE
public companion object {
public fun create(isNullable: Boolean): KtTypeNullability = if (isNullable) NULLABLE else NON_NULLABLE
}
}
sealed class KtClassType : KtType {
public sealed class KtClassType : KtType {
override fun toString(): String = asStringForDebugging()
}
sealed class KtNonErrorClassType : KtClassType(), KtTypeWithNullability {
abstract val classId: ClassId
abstract val classSymbol: KtClassLikeSymbol
abstract val typeArguments: List<KtTypeArgument>
public sealed class KtNonErrorClassType : KtClassType(), KtTypeWithNullability {
public abstract val classId: ClassId
public abstract val classSymbol: KtClassLikeSymbol
public abstract val typeArguments: List<KtTypeArgument>
}
abstract class KtFunctionalType : KtNonErrorClassType() {
abstract val isSuspend: Boolean
abstract val arity: Int
abstract val receiverType: KtType?
abstract val hasReceiver: Boolean
abstract val parameterTypes: List<KtType>
abstract val returnType: KtType
public abstract class KtFunctionalType : KtNonErrorClassType() {
public abstract val isSuspend: Boolean
public abstract val arity: Int
public abstract val receiverType: KtType?
public abstract val hasReceiver: Boolean
public abstract val parameterTypes: List<KtType>
public abstract val returnType: KtType
}
abstract class KtUsualClassType : KtNonErrorClassType()
public abstract class KtUsualClassType : KtNonErrorClassType()
abstract class KtClassErrorType : KtClassType() {
abstract val error: String
public abstract class KtClassErrorType : KtClassType() {
public abstract val error: String
}
abstract class KtTypeParameterType : KtTypeWithNullability {
abstract val name: Name
abstract val symbol: KtTypeParameterSymbol
public abstract class KtTypeParameterType : KtTypeWithNullability {
public abstract val name: Name
public abstract val symbol: KtTypeParameterSymbol
}
abstract class KtCapturedType : KtType {
public abstract class KtCapturedType : KtType {
override fun toString(): String = asStringForDebugging()
}
abstract class KtDefinitelyNotNullType : KtType, KtTypeWithNullability {
abstract val original: KtType
public abstract class KtDefinitelyNotNullType : KtType, KtTypeWithNullability {
public abstract val original: KtType
final override val nullability: KtTypeNullability get() = KtTypeNullability.NON_NULLABLE
override fun toString(): String = asStringForDebugging()
}
abstract class KtFlexibleType : KtType {
abstract val lowerBound: KtType
abstract val upperBound: KtType
public abstract class KtFlexibleType : KtType {
public abstract val lowerBound: KtType
public abstract val upperBound: KtType
override fun toString(): String = asStringForDebugging()
}
abstract class KtIntersectionType : KtType {
abstract val conjuncts: List<KtType>
public abstract class KtIntersectionType : KtType {
public abstract val conjuncts: List<KtType>
override fun toString(): String = asStringForDebugging()
}
@@ -1,9 +0,0 @@
/*
* Copyright 2010-2020 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.idea.frontend.api.types
import org.jetbrains.kotlin.idea.frontend.api.*
import org.jetbrains.kotlin.name.ClassId