[FIR] LightTree builder: get rid of unwanted asText calls
This commit is contained in:
+2
-8
@@ -156,7 +156,7 @@ abstract class BaseConverter(
|
|||||||
when (node.tokenType) {
|
when (node.tokenType) {
|
||||||
type -> container += node
|
type -> container += node
|
||||||
}
|
}
|
||||||
} ?: listOf()
|
} ?: emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun LighterASTNode?.getChildrenAsArray(): Array<out LighterASTNode?> {
|
fun LighterASTNode?.getChildrenAsArray(): Array<out LighterASTNode?> {
|
||||||
@@ -168,13 +168,7 @@ abstract class BaseConverter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun LighterASTNode?.getFirstChild(): LighterASTNode? {
|
fun LighterASTNode?.getFirstChild(): LighterASTNode? {
|
||||||
val firstChild: LighterASTNode?
|
return getChildrenAsArray().firstOrNull()
|
||||||
try {
|
|
||||||
firstChild = getChildrenAsArray()[0]
|
|
||||||
} catch (e: ArrayIndexOutOfBoundsException) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
return firstChild
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
|
|||||||
+9
-14
@@ -1001,7 +1001,7 @@ class DeclarationsConverter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val isImplicit = constructorDelegationCall.asText.isEmpty()
|
val isImplicit = constructorDelegationCall.textLength == 0
|
||||||
val isThis = thisKeywordPresent //|| (isImplicit && classWrapper.hasPrimaryConstructor)
|
val isThis = thisKeywordPresent //|| (isImplicit && classWrapper.hasPrimaryConstructor)
|
||||||
val delegatedType =
|
val delegatedType =
|
||||||
when {
|
when {
|
||||||
@@ -1785,7 +1785,7 @@ class DeclarationsConverter(
|
|||||||
val firValueArguments = mutableListOf<FirExpression>()
|
val firValueArguments = mutableListOf<FirExpression>()
|
||||||
constructorInvocation.forEachChildren {
|
constructorInvocation.forEachChildren {
|
||||||
when (it.tokenType) {
|
when (it.tokenType) {
|
||||||
CONSTRUCTOR_CALLEE -> if (it.asText.isNotEmpty()) firTypeRef = convertType(it) //is empty in enum entry constructor
|
CONSTRUCTOR_CALLEE -> firTypeRef = convertType(it)
|
||||||
VALUE_ARGUMENT_LIST -> firValueArguments += expressionConverter.convertValueArguments(it)
|
VALUE_ARGUMENT_LIST -> firValueArguments += expressionConverter.convertValueArguments(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1930,12 +1930,6 @@ class DeclarationsConverter(
|
|||||||
*/
|
*/
|
||||||
fun convertType(type: LighterASTNode): FirTypeRef {
|
fun convertType(type: LighterASTNode): FirTypeRef {
|
||||||
val typeRefSource = type.toFirSourceElement()
|
val typeRefSource = type.toFirSourceElement()
|
||||||
if (type.asText.isEmpty()) {
|
|
||||||
return buildErrorTypeRef {
|
|
||||||
source = typeRefSource
|
|
||||||
diagnostic = ConeSimpleDiagnostic("Unwrapped type is null", DiagnosticKind.Syntax)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// There can be MODIFIER_LIST children on the TYPE_REFERENCE node AND the descendant NULLABLE_TYPE nodes.
|
// There can be MODIFIER_LIST children on the TYPE_REFERENCE node AND the descendant NULLABLE_TYPE nodes.
|
||||||
// We aggregate them to get modifiers and annotations. Not only that, there could be multiple modifier lists on each. Examples:
|
// We aggregate them to get modifiers and annotations. Not only that, there could be multiple modifier lists on each. Examples:
|
||||||
@@ -2230,12 +2224,13 @@ class DeclarationsConverter(
|
|||||||
isNoinline = modifiers.hasNoinline()
|
isNoinline = modifiers.hasNoinline()
|
||||||
isVararg = modifiers.hasVararg()
|
isVararg = modifiers.hasVararg()
|
||||||
val isFromPrimaryConstructor = valueParameterDeclaration == ValueParameterDeclaration.PRIMARY_CONSTRUCTOR
|
val isFromPrimaryConstructor = valueParameterDeclaration == ValueParameterDeclaration.PRIMARY_CONSTRUCTOR
|
||||||
annotations += modifiers.annotations.filter {
|
annotations += if (!isFromPrimaryConstructor)
|
||||||
!isFromPrimaryConstructor || it.useSiteTarget == null ||
|
modifiers.annotations
|
||||||
it.useSiteTarget == CONSTRUCTOR_PARAMETER ||
|
else
|
||||||
it.useSiteTarget == RECEIVER ||
|
modifiers.annotations.filter {
|
||||||
it.useSiteTarget == FILE
|
val useSiteTarget = it.useSiteTarget
|
||||||
}
|
useSiteTarget == null || useSiteTarget == CONSTRUCTOR_PARAMETER || useSiteTarget == RECEIVER || useSiteTarget == FILE
|
||||||
|
}
|
||||||
annotations += additionalAnnotations
|
annotations += additionalAnnotations
|
||||||
}
|
}
|
||||||
return ValueParameter(isVal, isVar, modifiers, firValueParameter, destructuringDeclaration)
|
return ValueParameter(isVal, isVar, modifiers, firValueParameter, destructuringDeclaration)
|
||||||
|
|||||||
Reference in New Issue
Block a user