[FIR] Rename PSI version of toFirSourceElement
This commit is contained in:
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||||
import org.jetbrains.kotlin.fir.declarations.addDefaultBoundIfNecessary
|
import org.jetbrains.kotlin.fir.declarations.addDefaultBoundIfNecessary
|
||||||
import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParameterBuilder
|
import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParameterBuilder
|
||||||
import org.jetbrains.kotlin.fir.expressions.builder.buildAnnotationCall
|
|
||||||
import org.jetbrains.kotlin.fir.java.declarations.*
|
import org.jetbrains.kotlin.fir.java.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.resolve.AbstractFirSymbolProvider
|
import org.jetbrains.kotlin.fir.resolve.AbstractFirSymbolProvider
|
||||||
import org.jetbrains.kotlin.fir.resolve.constructType
|
import org.jetbrains.kotlin.fir.resolve.constructType
|
||||||
@@ -30,7 +29,7 @@ import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope
|
|||||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||||
import org.jetbrains.kotlin.fir.toFirSourceElement
|
import org.jetbrains.kotlin.fir.toFirPsiSourceElement
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||||
import org.jetbrains.kotlin.load.java.JavaClassFinder
|
import org.jetbrains.kotlin.load.java.JavaClassFinder
|
||||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||||
@@ -163,7 +162,7 @@ class JavaSymbolProvider(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val firJavaClass = buildJavaClass {
|
val firJavaClass = buildJavaClass {
|
||||||
source = (javaClass as? JavaElementImpl<*>)?.psi?.toFirSourceElement()
|
source = (javaClass as? JavaElementImpl<*>)?.psi?.toFirPsiSourceElement()
|
||||||
session = this@JavaSymbolProvider.session
|
session = this@JavaSymbolProvider.session
|
||||||
symbol = firSymbol
|
symbol = firSymbol
|
||||||
name = javaClass.name
|
name = javaClass.name
|
||||||
@@ -186,7 +185,7 @@ class JavaSymbolProvider(
|
|||||||
val fieldSymbol = FirFieldSymbol(fieldId)
|
val fieldSymbol = FirFieldSymbol(fieldId)
|
||||||
val returnType = javaField.type
|
val returnType = javaField.type
|
||||||
val firJavaField = buildJavaField {
|
val firJavaField = buildJavaField {
|
||||||
source = (javaField as? JavaElementImpl<*>)?.psi?.toFirSourceElement()
|
source = (javaField as? JavaElementImpl<*>)?.psi?.toFirPsiSourceElement()
|
||||||
session = this@JavaSymbolProvider.session
|
session = this@JavaSymbolProvider.session
|
||||||
symbol = fieldSymbol
|
symbol = fieldSymbol
|
||||||
name = fieldName
|
name = fieldName
|
||||||
@@ -207,7 +206,7 @@ class JavaSymbolProvider(
|
|||||||
val returnType = javaMethod.returnType
|
val returnType = javaMethod.returnType
|
||||||
val firJavaMethod = buildJavaMethod {
|
val firJavaMethod = buildJavaMethod {
|
||||||
session = this@JavaSymbolProvider.session
|
session = this@JavaSymbolProvider.session
|
||||||
source = (javaMethod as? JavaElementImpl<*>)?.psi?.toFirSourceElement()
|
source = (javaMethod as? JavaElementImpl<*>)?.psi?.toFirPsiSourceElement()
|
||||||
symbol = methodSymbol
|
symbol = methodSymbol
|
||||||
name = methodName
|
name = methodName
|
||||||
visibility = javaMethod.visibility
|
visibility = javaMethod.visibility
|
||||||
@@ -235,7 +234,7 @@ class JavaSymbolProvider(
|
|||||||
val constructorSymbol = FirConstructorSymbol(constructorId)
|
val constructorSymbol = FirConstructorSymbol(constructorId)
|
||||||
val classTypeParameters = javaClass.typeParameters.convertTypeParameters(javaTypeParameterStack)
|
val classTypeParameters = javaClass.typeParameters.convertTypeParameters(javaTypeParameterStack)
|
||||||
return FirJavaConstructorBuilder().apply {
|
return FirJavaConstructorBuilder().apply {
|
||||||
source = psi?.toFirSourceElement()
|
source = psi?.toFirPsiSourceElement()
|
||||||
session = this@JavaSymbolProvider.session
|
session = this@JavaSymbolProvider.session
|
||||||
symbol = constructorSymbol
|
symbol = constructorSymbol
|
||||||
this.visibility = visibility
|
this.visibility = visibility
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe
|
|||||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||||
import org.jetbrains.kotlin.fir.toFirSourceElement
|
import org.jetbrains.kotlin.fir.toFirPsiSourceElement
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||||
@@ -353,7 +353,7 @@ internal fun JavaValueParameter.toFirValueParameter(
|
|||||||
session: FirSession, index: Int, javaTypeParameterStack: JavaTypeParameterStack
|
session: FirSession, index: Int, javaTypeParameterStack: JavaTypeParameterStack
|
||||||
): FirValueParameter {
|
): FirValueParameter {
|
||||||
return buildJavaValueParameter {
|
return buildJavaValueParameter {
|
||||||
source = (this@toFirValueParameter as? JavaElementImpl<*>)?.psi?.toFirSourceElement()
|
source = (this@toFirValueParameter as? JavaElementImpl<*>)?.psi?.toFirPsiSourceElement()
|
||||||
this.session = session
|
this.session = session
|
||||||
name = this@toFirValueParameter.name ?: Name.identifier("p$index")
|
name = this@toFirValueParameter.name ?: Name.identifier("p$index")
|
||||||
returnTypeRef = type.toFirJavaTypeRef(session, javaTypeParameterStack)
|
returnTypeRef = type.toFirJavaTypeRef(session, javaTypeParameterStack)
|
||||||
|
|||||||
+8
-8
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
|||||||
import org.jetbrains.kotlin.fir.expressions.*
|
import org.jetbrains.kotlin.fir.expressions.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.builder.*
|
import org.jetbrains.kotlin.fir.expressions.builder.*
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||||
import org.jetbrains.kotlin.fir.toFirSourceElement
|
import org.jetbrains.kotlin.fir.toFirPsiSourceElement
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ internal fun KtWhenCondition.toFirWhenCondition(
|
|||||||
convert: KtExpression?.(String) -> FirExpression,
|
convert: KtExpression?.(String) -> FirExpression,
|
||||||
toFirOrErrorTypeRef: KtTypeReference?.() -> FirTypeRef,
|
toFirOrErrorTypeRef: KtTypeReference?.() -> FirTypeRef,
|
||||||
): FirExpression {
|
): FirExpression {
|
||||||
val baseSource = this.toFirSourceElement()
|
val baseSource = this.toFirPsiSourceElement()
|
||||||
val firSubjectExpression = buildWhenSubjectExpression {
|
val firSubjectExpression = buildWhenSubjectExpression {
|
||||||
source = baseSource
|
source = baseSource
|
||||||
whenSubject = subject
|
whenSubject = subject
|
||||||
@@ -35,7 +35,7 @@ internal fun KtWhenCondition.toFirWhenCondition(
|
|||||||
return when (this) {
|
return when (this) {
|
||||||
is KtWhenConditionWithExpression -> {
|
is KtWhenConditionWithExpression -> {
|
||||||
buildOperatorCall {
|
buildOperatorCall {
|
||||||
source = expression?.toFirSourceElement()
|
source = expression?.toFirPsiSourceElement()
|
||||||
operation = FirOperation.EQ
|
operation = FirOperation.EQ
|
||||||
argumentList = buildBinaryArgumentList(
|
argumentList = buildBinaryArgumentList(
|
||||||
firSubjectExpression, expression.convert("No expression in condition with expression")
|
firSubjectExpression, expression.convert("No expression in condition with expression")
|
||||||
@@ -47,13 +47,13 @@ internal fun KtWhenCondition.toFirWhenCondition(
|
|||||||
firRange.generateContainsOperation(
|
firRange.generateContainsOperation(
|
||||||
firSubjectExpression,
|
firSubjectExpression,
|
||||||
isNegated,
|
isNegated,
|
||||||
rangeExpression?.toFirSourceElement(),
|
rangeExpression?.toFirPsiSourceElement(),
|
||||||
operationReference.toFirSourceElement()
|
operationReference.toFirPsiSourceElement()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is KtWhenConditionIsPattern -> {
|
is KtWhenConditionIsPattern -> {
|
||||||
buildTypeOperatorCall {
|
buildTypeOperatorCall {
|
||||||
source = typeReference?.toFirSourceElement()
|
source = typeReference?.toFirPsiSourceElement()
|
||||||
operation = if (isNegated) FirOperation.NOT_IS else FirOperation.IS
|
operation = if (isNegated) FirOperation.NOT_IS else FirOperation.IS
|
||||||
conversionTypeRef = typeReference.toFirOrErrorTypeRef()
|
conversionTypeRef = typeReference.toFirOrErrorTypeRef()
|
||||||
argumentList = buildUnaryArgumentList(firSubjectExpression)
|
argumentList = buildUnaryArgumentList(firSubjectExpression)
|
||||||
@@ -93,13 +93,13 @@ internal fun generateDestructuringBlock(
|
|||||||
toFirOrImplicitTypeRef: KtTypeReference?.() -> FirTypeRef,
|
toFirOrImplicitTypeRef: KtTypeReference?.() -> FirTypeRef,
|
||||||
): FirExpression {
|
): FirExpression {
|
||||||
return buildBlock {
|
return buildBlock {
|
||||||
source = multiDeclaration.toFirSourceElement()
|
source = multiDeclaration.toFirPsiSourceElement()
|
||||||
if (tmpVariable) {
|
if (tmpVariable) {
|
||||||
statements += container
|
statements += container
|
||||||
}
|
}
|
||||||
val isVar = multiDeclaration.isVar
|
val isVar = multiDeclaration.isVar
|
||||||
for ((index, entry) in multiDeclaration.entries.withIndex()) {
|
for ((index, entry) in multiDeclaration.entries.withIndex()) {
|
||||||
val entrySource = entry.toFirSourceElement()
|
val entrySource = entry.toFirPsiSourceElement()
|
||||||
val name = entry.nameAsSafeName
|
val name = entry.nameAsSafeName
|
||||||
statements += buildProperty {
|
statements += buildProperty {
|
||||||
source = entrySource
|
source = entrySource
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class RawFirBuilder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun PsiElement.toFirSourceElement(): FirPsiSourceElement<*> {
|
override fun PsiElement.toFirSourceElement(): FirPsiSourceElement<*> {
|
||||||
return FirPsiSourceElement(this)
|
return this.toFirPsiSourceElement()
|
||||||
}
|
}
|
||||||
|
|
||||||
override val PsiElement.elementType: IElementType
|
override val PsiElement.elementType: IElementType
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ val FirModifier<*>.lightNode: LighterASTNode? get() = (this as? FirLightModifier
|
|||||||
|
|
||||||
val FirModifier<*>.source: FirSourceElement?
|
val FirModifier<*>.source: FirSourceElement?
|
||||||
get() = when (this) {
|
get() = when (this) {
|
||||||
is FirPsiModifier -> this.psi?.toFirSourceElement()
|
is FirPsiModifier -> this.psi?.toFirPsiSourceElement()
|
||||||
is FirLightModifier -> {
|
is FirLightModifier -> {
|
||||||
// TODO pretty sure I got offsets wrong here
|
// TODO pretty sure I got offsets wrong here
|
||||||
val startOffset = tree.getStartOffset(node)
|
val startOffset = tree.getStartOffset(node)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ val FirSourceElement?.psi: PsiElement? get() = (this as? FirPsiSourceElement<*>)
|
|||||||
val FirElement.psi: PsiElement? get() = (source as? FirPsiSourceElement<*>)?.psi
|
val FirElement.psi: PsiElement? get() = (source as? FirPsiSourceElement<*>)?.psi
|
||||||
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun PsiElement.toFirSourceElement(): FirPsiSourceElement<*> = FirPsiSourceElement(this)
|
inline fun PsiElement.toFirPsiSourceElement(): FirPsiSourceElement<*> = FirPsiSourceElement(this)
|
||||||
|
|
||||||
val FirSourceElement?.lightNode: LighterASTNode? get() = (this as? FirLightSourceElement)?.element
|
val FirSourceElement?.lightNode: LighterASTNode? get() = (this as? FirLightSourceElement)?.element
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user