FIR IDE/LC: introduce/use KtTypeMappingMode
This commit is contained in:
committed by
Ilya Kirillov
parent
0da9ef873a
commit
4eec381d1b
+10
-11
@@ -8,12 +8,15 @@ package org.jetbrains.kotlin.analysis.api.components
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiType
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtTypeMappingMode
|
||||
|
||||
public abstract class KtPsiTypeProvider : KtAnalysisSessionComponent() {
|
||||
public abstract fun asPsiType(type: KtType, useSitePosition: PsiElement, mode: TypeMappingMode): PsiType?
|
||||
public abstract fun getOptimalModeForReturnType(type: KtType, isAnnotationMethod: Boolean): TypeMappingMode
|
||||
public abstract fun getOptimalModeForValueParameter(type: KtType): TypeMappingMode
|
||||
public abstract fun asPsiType(
|
||||
type: KtType,
|
||||
useSitePosition: PsiElement,
|
||||
mode: KtTypeMappingMode,
|
||||
isAnnotationMethod: Boolean,
|
||||
): PsiType?
|
||||
}
|
||||
|
||||
public interface KtPsiTypeProviderMixIn : KtAnalysisSessionMixIn {
|
||||
@@ -35,13 +38,9 @@ public interface KtPsiTypeProviderMixIn : KtAnalysisSessionMixIn {
|
||||
*/
|
||||
public fun KtType.asPsiType(
|
||||
useSitePosition: PsiElement,
|
||||
mode: TypeMappingMode = TypeMappingMode.DEFAULT,
|
||||
mode: KtTypeMappingMode = KtTypeMappingMode.DEFAULT,
|
||||
isAnnotationMethod: Boolean = false,
|
||||
): PsiType? =
|
||||
analysisSession.psiTypeProvider.asPsiType(this, useSitePosition, mode)
|
||||
analysisSession.psiTypeProvider.asPsiType(this, useSitePosition, mode, isAnnotationMethod)
|
||||
|
||||
public fun KtType.getOptimalModeForReturnType(isAnnotationMethod: Boolean): TypeMappingMode =
|
||||
analysisSession.psiTypeProvider.getOptimalModeForReturnType(this, isAnnotationMethod)
|
||||
|
||||
public fun KtType.getOptimalModeForValueParameter(): TypeMappingMode =
|
||||
analysisSession.psiTypeProvider.getOptimalModeForValueParameter(this)
|
||||
}
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.types
|
||||
|
||||
public enum class KtTypeMappingMode {
|
||||
/**
|
||||
* kotlin.Int is mapped to I
|
||||
*/
|
||||
DEFAULT,
|
||||
|
||||
/**
|
||||
* kotlin.Int is mapped to I
|
||||
* Type aliases are mapped to their expanded form
|
||||
*/
|
||||
DEFAULT_UAST,
|
||||
|
||||
/**
|
||||
* kotlin.Int is mapped to Ljava/lang/Integer;
|
||||
*/
|
||||
GENERIC_ARGUMENT,
|
||||
|
||||
/**
|
||||
* kotlin.Int is mapped to Ljava/lang/Integer;
|
||||
* No projections allowed in immediate arguments
|
||||
*/
|
||||
SUPER_TYPE,
|
||||
|
||||
/**
|
||||
* Similar to [SUPER_TYPE], except for that Kotlin collections remain as-is.
|
||||
*/
|
||||
SUPER_TYPE_KOTLIN_COLLECTIONS_AS_IS,
|
||||
|
||||
/**
|
||||
* Optimal mode to convert the return type of declarations if it's part of signature.
|
||||
*/
|
||||
RETURN_TYPE,
|
||||
|
||||
/**
|
||||
* Optimal mode to convert the type of value parameter if it's part of signature.
|
||||
*/
|
||||
VALUE_PARAMETER,
|
||||
}
|
||||
Reference in New Issue
Block a user