Delete extra files with util methods (raw FIR)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
01daa90f5c
commit
f3299c4636
-2
@@ -18,8 +18,6 @@ import org.jetbrains.kotlin.fir.types.impl.*
|
|||||||
import org.jetbrains.kotlin.lexer.KtToken
|
import org.jetbrains.kotlin.lexer.KtToken
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens.*
|
import org.jetbrains.kotlin.lexer.KtTokens.*
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.ConverterUtil.isExpression
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.ConverterUtil.nameAsSafeName
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
open class BaseConverter(
|
open class BaseConverter(
|
||||||
|
|||||||
+103
-66
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.lightTree.converter
|
|||||||
|
|
||||||
import com.intellij.lang.LighterASTNode
|
import com.intellij.lang.LighterASTNode
|
||||||
import com.intellij.psi.tree.IElementType
|
import com.intellij.psi.tree.IElementType
|
||||||
|
import com.intellij.psi.tree.TokenSet
|
||||||
import org.jetbrains.kotlin.KtNodeType
|
import org.jetbrains.kotlin.KtNodeType
|
||||||
import org.jetbrains.kotlin.KtNodeTypes
|
import org.jetbrains.kotlin.KtNodeTypes
|
||||||
import org.jetbrains.kotlin.KtNodeTypes.*
|
import org.jetbrains.kotlin.KtNodeTypes.*
|
||||||
@@ -16,10 +17,12 @@ import org.jetbrains.kotlin.fir.FirFunctionTarget
|
|||||||
import org.jetbrains.kotlin.fir.FirLabel
|
import org.jetbrains.kotlin.fir.FirLabel
|
||||||
import org.jetbrains.kotlin.fir.FirReference
|
import org.jetbrains.kotlin.fir.FirReference
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
|
import org.jetbrains.kotlin.fir.builder.generateResolvedAccessExpression
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.*
|
import org.jetbrains.kotlin.fir.declarations.impl.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
import org.jetbrains.kotlin.fir.expressions.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||||
|
import org.jetbrains.kotlin.fir.lightTree.fir.DestructuringDeclaration
|
||||||
import org.jetbrains.kotlin.fir.lightTree.fir.TypeConstraint
|
import org.jetbrains.kotlin.fir.lightTree.fir.TypeConstraint
|
||||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||||
import org.jetbrains.kotlin.fir.references.FirExplicitThisReference
|
import org.jetbrains.kotlin.fir.references.FirExplicitThisReference
|
||||||
@@ -29,6 +32,7 @@ import org.jetbrains.kotlin.fir.symbols.CallableId
|
|||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.impl.*
|
import org.jetbrains.kotlin.fir.types.impl.*
|
||||||
import org.jetbrains.kotlin.lexer.KtSingleValueToken
|
import org.jetbrains.kotlin.lexer.KtSingleValueToken
|
||||||
@@ -42,73 +46,106 @@ import org.jetbrains.kotlin.psi.stubs.elements.KtConstantExpressionElementType
|
|||||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStringTemplateExpressionElementType
|
import org.jetbrains.kotlin.psi.stubs.elements.KtStringTemplateExpressionElementType
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
object ConverterUtil {
|
private val expressionSet = listOf(
|
||||||
private val expressionSet = listOf(
|
REFERENCE_EXPRESSION,
|
||||||
REFERENCE_EXPRESSION,
|
DOT_QUALIFIED_EXPRESSION,
|
||||||
DOT_QUALIFIED_EXPRESSION,
|
LAMBDA_EXPRESSION,
|
||||||
LAMBDA_EXPRESSION,
|
FUN
|
||||||
FUN
|
)
|
||||||
)
|
|
||||||
|
|
||||||
fun String?.nameAsSafeName(defaultName: String = ""): Name {
|
val qualifiedAccessTokens = TokenSet.create(DOT_QUALIFIED_EXPRESSION, SAFE_ACCESS_EXPRESSION)
|
||||||
return when {
|
|
||||||
this != null -> Name.identifier(this.replace("`", ""))
|
|
||||||
defaultName.isNotEmpty() -> Name.identifier(defaultName)
|
|
||||||
else -> SpecialNames.NO_NAME_PROVIDED
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun LighterASTNode.getAsStringWithoutBacktick(): String {
|
fun String?.nameAsSafeName(defaultName: String = ""): Name {
|
||||||
return this.toString().replace("`", "")
|
return when {
|
||||||
}
|
this != null -> Name.identifier(this.replace("`", ""))
|
||||||
|
defaultName.isNotEmpty() -> Name.identifier(defaultName)
|
||||||
fun LighterASTNode.isExpression(): Boolean {
|
else -> SpecialNames.NO_NAME_PROVIDED
|
||||||
return when (this.tokenType) {
|
}
|
||||||
is KtNodeType,
|
}
|
||||||
is KtConstantExpressionElementType,
|
|
||||||
is KtStringTemplateExpressionElementType,
|
fun String.getOperationSymbol(): IElementType {
|
||||||
in expressionSet -> true
|
KotlinExpressionParsing.ALL_OPERATIONS.types.forEach {
|
||||||
else -> false
|
if (it is KtSingleValueToken && it.value == this) return it
|
||||||
}
|
}
|
||||||
}
|
if (this == "as?") return KtTokens.AS_SAFE
|
||||||
|
return KtTokens.IDENTIFIER
|
||||||
fun FirTypeParameterContainer.joinTypeParameters(typeConstraints: List<TypeConstraint>) {
|
}
|
||||||
typeConstraints.forEach { typeConstraint ->
|
|
||||||
this.typeParameters.forEach { typeParameter ->
|
fun LighterASTNode.getAsStringWithoutBacktick(): String {
|
||||||
if (typeConstraint.identifier == typeParameter.name.identifier) {
|
return this.toString().replace("`", "")
|
||||||
(typeParameter as FirTypeParameterImpl).bounds += typeConstraint.firTypeRef
|
}
|
||||||
typeParameter.annotations += typeConstraint.firTypeRef.annotations
|
|
||||||
typeParameter.annotations += typeConstraint.annotations
|
fun LighterASTNode.isExpression(): Boolean {
|
||||||
}
|
return when (this.tokenType) {
|
||||||
}
|
is KtNodeType,
|
||||||
}
|
is KtConstantExpressionElementType,
|
||||||
}
|
is KtStringTemplateExpressionElementType,
|
||||||
|
in expressionSet -> true
|
||||||
fun <T : FirCallWithArgumentList> T.extractArgumentsFrom(container: List<FirExpression>, stubMode: Boolean): T {
|
else -> false
|
||||||
if (!stubMode || this is FirAnnotationCall) {
|
}
|
||||||
this.arguments += container
|
}
|
||||||
}
|
|
||||||
return this
|
fun FirTypeParameterContainer.joinTypeParameters(typeConstraints: List<TypeConstraint>) {
|
||||||
}
|
typeConstraints.forEach { typeConstraint ->
|
||||||
|
this.typeParameters.forEach { typeParameter ->
|
||||||
inline fun isClassLocal(classNode: LighterASTNode, getParent: LighterASTNode.() -> LighterASTNode?): Boolean {
|
if (typeConstraint.identifier == typeParameter.name.identifier) {
|
||||||
var currentNode: LighterASTNode? = classNode
|
(typeParameter as FirTypeParameterImpl).bounds += typeConstraint.firTypeRef
|
||||||
while (currentNode != null) {
|
typeParameter.annotations += typeConstraint.firTypeRef.annotations
|
||||||
val tokenType = currentNode.tokenType
|
typeParameter.annotations += typeConstraint.annotations
|
||||||
val parent = currentNode.getParent()
|
}
|
||||||
if (tokenType == PROPERTY || tokenType == FUN) {
|
}
|
||||||
val grandParent = parent?.getParent()
|
}
|
||||||
when {
|
}
|
||||||
parent?.tokenType == KT_FILE -> return true
|
|
||||||
parent?.tokenType == CLASS_BODY && !(grandParent?.tokenType == OBJECT_DECLARATION && grandParent?.getParent()?.tokenType == OBJECT_LITERAL) -> return true
|
fun <T : FirCallWithArgumentList> T.extractArgumentsFrom(container: List<FirExpression>, stubMode: Boolean): T {
|
||||||
parent?.tokenType == BLOCK && grandParent?.tokenType == SCRIPT -> return true
|
if (!stubMode || this is FirAnnotationCall) {
|
||||||
}
|
this.arguments += container
|
||||||
}
|
}
|
||||||
if (tokenType == BLOCK) {
|
return this
|
||||||
return true
|
}
|
||||||
}
|
|
||||||
currentNode = parent
|
inline fun isClassLocal(classNode: LighterASTNode, getParent: LighterASTNode.() -> LighterASTNode?): Boolean {
|
||||||
}
|
var currentNode: LighterASTNode? = classNode
|
||||||
return false
|
while (currentNode != null) {
|
||||||
|
val tokenType = currentNode.tokenType
|
||||||
|
val parent = currentNode.getParent()
|
||||||
|
if (tokenType == PROPERTY || tokenType == FUN) {
|
||||||
|
val grandParent = parent?.getParent()
|
||||||
|
when {
|
||||||
|
parent?.tokenType == KT_FILE -> return true
|
||||||
|
parent?.tokenType == CLASS_BODY && !(grandParent?.tokenType == OBJECT_DECLARATION && grandParent?.getParent()?.tokenType == OBJECT_LITERAL) -> return true
|
||||||
|
parent?.tokenType == BLOCK && grandParent?.tokenType == SCRIPT -> return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tokenType == BLOCK) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
currentNode = parent
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun generateDestructuringBlock(
|
||||||
|
session: FirSession,
|
||||||
|
multiDeclaration: DestructuringDeclaration,
|
||||||
|
container: FirVariable<*>,
|
||||||
|
tmpVariable: Boolean
|
||||||
|
): FirExpression {
|
||||||
|
return FirBlockImpl(session, null).apply {
|
||||||
|
if (tmpVariable) {
|
||||||
|
statements += container
|
||||||
|
}
|
||||||
|
val isVar = multiDeclaration.isVar
|
||||||
|
for ((index, entry) in multiDeclaration.entries.withIndex()) {
|
||||||
|
statements += FirVariableImpl(
|
||||||
|
session, null, entry.name,
|
||||||
|
entry.returnTypeRef, isVar,
|
||||||
|
FirComponentCallImpl(session, null, index + 1, generateResolvedAccessExpression(session, null, container)),
|
||||||
|
FirVariableSymbol(entry.name) // TODO?
|
||||||
|
).apply {
|
||||||
|
annotations += entry.annotations
|
||||||
|
symbol.bind(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-7
@@ -22,12 +22,6 @@ import org.jetbrains.kotlin.fir.declarations.impl.*
|
|||||||
import org.jetbrains.kotlin.fir.expressions.*
|
import org.jetbrains.kotlin.fir.expressions.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.fir.lightTree.LightTree2Fir
|
import org.jetbrains.kotlin.fir.lightTree.LightTree2Fir
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.ConverterUtil.extractArgumentsFrom
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.ConverterUtil.getAsStringWithoutBacktick
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.ConverterUtil.isExpression
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.ConverterUtil.joinTypeParameters
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.ConverterUtil.nameAsSafeName
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.ConverterUtil.isClassLocal
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.fir.*
|
import org.jetbrains.kotlin.fir.lightTree.fir.*
|
||||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.Modifier
|
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.Modifier
|
||||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeModifier
|
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeModifier
|
||||||
@@ -403,7 +397,7 @@ class DeclarationsConverter(
|
|||||||
//parse properties
|
//parse properties
|
||||||
properties += primaryConstructorWrapper.valueParameters
|
properties += primaryConstructorWrapper.valueParameters
|
||||||
.filter { it.hasValOrVar() }
|
.filter { it.hasValOrVar() }
|
||||||
.map { it.toFirProperty(callableIdForName(it.firValueParameter.name)) }
|
.map { it.toFirProperty(session, callableIdForName(it.firValueParameter.name)) }
|
||||||
firClass.addDeclarations(properties)
|
firClass.addDeclarations(properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-8
@@ -20,13 +20,6 @@ import org.jetbrains.kotlin.fir.expressions.*
|
|||||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.fir.labels.FirLabelImpl
|
import org.jetbrains.kotlin.fir.labels.FirLabelImpl
|
||||||
import org.jetbrains.kotlin.fir.lightTree.LightTree2Fir
|
import org.jetbrains.kotlin.fir.lightTree.LightTree2Fir
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.ConverterUtil.extractArgumentsFrom
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.ConverterUtil.getAsStringWithoutBacktick
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.ConverterUtil.isExpression
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.ConverterUtil.nameAsSafeName
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.utils.generateDestructuringBlock
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.utils.getOperationSymbol
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.utils.qualifiedAccessTokens
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.fir.ValueParameter
|
import org.jetbrains.kotlin.fir.lightTree.fir.ValueParameter
|
||||||
import org.jetbrains.kotlin.fir.lightTree.fir.WhenEntry
|
import org.jetbrains.kotlin.fir.lightTree.fir.WhenEntry
|
||||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||||
@@ -66,7 +59,8 @@ class ExpressionsConverter(
|
|||||||
return when (expression.tokenType) {
|
return when (expression.tokenType) {
|
||||||
LAMBDA_EXPRESSION -> {
|
LAMBDA_EXPRESSION -> {
|
||||||
val lambdaTree = LightTree2Fir.buildLightTreeLambdaExpression(expression.asText)
|
val lambdaTree = LightTree2Fir.buildLightTreeLambdaExpression(expression.asText)
|
||||||
ExpressionsConverter(session, stubMode, lambdaTree, declarationsConverter, context).convertLambdaExpression(lambdaTree.root)
|
ExpressionsConverter(session, stubMode, lambdaTree, declarationsConverter, context)
|
||||||
|
.convertLambdaExpression(lambdaTree.root)
|
||||||
}
|
}
|
||||||
BINARY_EXPRESSION -> convertBinaryExpression(expression)
|
BINARY_EXPRESSION -> convertBinaryExpression(expression)
|
||||||
BINARY_WITH_TYPE -> convertBinaryWithType(expression)
|
BINARY_WITH_TYPE -> convertBinaryWithType(expression)
|
||||||
|
|||||||
-65
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.fir.lightTree.converter.utils
|
|
||||||
|
|
||||||
import com.intellij.psi.tree.IElementType
|
|
||||||
import com.intellij.psi.tree.TokenSet
|
|
||||||
import org.jetbrains.kotlin.KtNodeTypes.DOT_QUALIFIED_EXPRESSION
|
|
||||||
import org.jetbrains.kotlin.KtNodeTypes.SAFE_ACCESS_EXPRESSION
|
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
|
||||||
import org.jetbrains.kotlin.fir.builder.RawFirBuilder
|
|
||||||
import org.jetbrains.kotlin.fir.builder.generateNotNullOrOther
|
|
||||||
import org.jetbrains.kotlin.fir.builder.generateResolvedAccessExpression
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirVariableImpl
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirVariable
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirWhenExpression
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.impl.FirBlockImpl
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.impl.FirComponentCallImpl
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.impl.FirFunctionCallImpl
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.impl.FirThrowExpressionImpl
|
|
||||||
import org.jetbrains.kotlin.fir.lightTree.fir.DestructuringDeclaration
|
|
||||||
import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference
|
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
|
||||||
import org.jetbrains.kotlin.lexer.KtSingleValueToken
|
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens.AS_SAFE
|
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens.IDENTIFIER
|
|
||||||
import org.jetbrains.kotlin.parsing.KotlinExpressionParsing
|
|
||||||
|
|
||||||
val qualifiedAccessTokens = TokenSet.create(DOT_QUALIFIED_EXPRESSION, SAFE_ACCESS_EXPRESSION)
|
|
||||||
|
|
||||||
fun String.getOperationSymbol(): IElementType {
|
|
||||||
KotlinExpressionParsing.ALL_OPERATIONS.types.forEach {
|
|
||||||
if (it is KtSingleValueToken && it.value == this) return it
|
|
||||||
}
|
|
||||||
if (this == "as?") return AS_SAFE
|
|
||||||
return IDENTIFIER
|
|
||||||
}
|
|
||||||
|
|
||||||
fun generateDestructuringBlock(
|
|
||||||
session: FirSession,
|
|
||||||
multiDeclaration: DestructuringDeclaration,
|
|
||||||
container: FirVariable<*>,
|
|
||||||
tmpVariable: Boolean
|
|
||||||
): FirExpression {
|
|
||||||
return FirBlockImpl(session, null).apply {
|
|
||||||
if (tmpVariable) {
|
|
||||||
statements += container
|
|
||||||
}
|
|
||||||
val isVar = multiDeclaration.isVar
|
|
||||||
for ((index, entry) in multiDeclaration.entries.withIndex()) {
|
|
||||||
statements += FirVariableImpl(
|
|
||||||
session, null, entry.name,
|
|
||||||
entry.returnTypeRef, isVar,
|
|
||||||
FirComponentCallImpl(session, null, index + 1, generateResolvedAccessExpression(session, null, container)),
|
|
||||||
FirVariableSymbol(entry.name) // TODO?
|
|
||||||
).apply {
|
|
||||||
annotations += entry.annotations
|
|
||||||
symbol.bind(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
|||||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirVariable
|
import org.jetbrains.kotlin.fir.expressions.FirVariable
|
||||||
import org.jetbrains.kotlin.fir.expressions.impl.FirErrorExpressionImpl
|
import org.jetbrains.kotlin.fir.expressions.impl.FirErrorExpressionImpl
|
||||||
import org.jetbrains.kotlin.fir.lightTree.converter.utils.generateDestructuringBlock
|
import org.jetbrains.kotlin.fir.lightTree.converter.generateDestructuringBlock
|
||||||
|
|
||||||
data class DestructuringDeclaration(
|
data class DestructuringDeclaration(
|
||||||
val isVar: Boolean,
|
val isVar: Boolean,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.lightTree.fir
|
package org.jetbrains.kotlin.fir.lightTree.fir
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter
|
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter
|
||||||
@@ -32,15 +33,15 @@ class ValueParameter(
|
|||||||
return isVal || isVar
|
return isVal || isVar
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toFirProperty(callableId: CallableId): FirProperty {
|
fun toFirProperty(session: FirSession, callableId: CallableId): FirProperty {
|
||||||
val name = this.firValueParameter.name
|
val name = this.firValueParameter.name
|
||||||
var type = this.firValueParameter.returnTypeRef
|
var type = this.firValueParameter.returnTypeRef
|
||||||
if (type is FirImplicitTypeRef) {
|
if (type is FirImplicitTypeRef) {
|
||||||
type = FirErrorTypeRefImpl(this.firValueParameter.session, null, "Incomplete code")
|
type = FirErrorTypeRefImpl(session, null, "Incomplete code")
|
||||||
}
|
}
|
||||||
|
|
||||||
return FirMemberPropertyImpl(
|
return FirMemberPropertyImpl(
|
||||||
this.firValueParameter.session,
|
session,
|
||||||
null,
|
null,
|
||||||
FirPropertySymbol(callableId),
|
FirPropertySymbol(callableId),
|
||||||
name,
|
name,
|
||||||
@@ -54,14 +55,14 @@ class ValueParameter(
|
|||||||
receiverTypeRef = null,
|
receiverTypeRef = null,
|
||||||
returnTypeRef = type,
|
returnTypeRef = type,
|
||||||
isVar = this.isVar,
|
isVar = this.isVar,
|
||||||
initializer = FirQualifiedAccessExpressionImpl(this.firValueParameter.session, null).apply {
|
initializer = FirQualifiedAccessExpressionImpl(session, null).apply {
|
||||||
calleeReference = FirPropertyFromParameterCallableReference(
|
calleeReference = FirPropertyFromParameterCallableReference(
|
||||||
this@ValueParameter.firValueParameter.session, null, name, this@ValueParameter.firValueParameter.symbol
|
session, null, name, this@ValueParameter.firValueParameter.symbol
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
getter = FirDefaultPropertyGetter(this.firValueParameter.session, null, type, modifiers.getVisibility()),
|
getter = FirDefaultPropertyGetter(session, null, type, modifiers.getVisibility()),
|
||||||
setter = if (this.isVar) FirDefaultPropertySetter(
|
setter = if (this.isVar) FirDefaultPropertySetter(
|
||||||
this.firValueParameter.session,
|
session,
|
||||||
null,
|
null,
|
||||||
type,
|
type,
|
||||||
modifiers.getVisibility()
|
modifiers.getVisibility()
|
||||||
|
|||||||
Reference in New Issue
Block a user