[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) {
|
||||
type -> container += node
|
||||
}
|
||||
} ?: listOf()
|
||||
} ?: emptyList()
|
||||
}
|
||||
|
||||
fun LighterASTNode?.getChildrenAsArray(): Array<out LighterASTNode?> {
|
||||
@@ -168,13 +168,7 @@ abstract class BaseConverter(
|
||||
}
|
||||
|
||||
fun LighterASTNode?.getFirstChild(): LighterASTNode? {
|
||||
val firstChild: LighterASTNode?
|
||||
try {
|
||||
firstChild = getChildrenAsArray()[0]
|
||||
} catch (e: ArrayIndexOutOfBoundsException) {
|
||||
return null
|
||||
}
|
||||
return firstChild
|
||||
return getChildrenAsArray().firstOrNull()
|
||||
}
|
||||
|
||||
@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 delegatedType =
|
||||
when {
|
||||
@@ -1785,7 +1785,7 @@ class DeclarationsConverter(
|
||||
val firValueArguments = mutableListOf<FirExpression>()
|
||||
constructorInvocation.forEachChildren {
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -1930,12 +1930,6 @@ class DeclarationsConverter(
|
||||
*/
|
||||
fun convertType(type: LighterASTNode): FirTypeRef {
|
||||
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.
|
||||
// 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()
|
||||
isVararg = modifiers.hasVararg()
|
||||
val isFromPrimaryConstructor = valueParameterDeclaration == ValueParameterDeclaration.PRIMARY_CONSTRUCTOR
|
||||
annotations += modifiers.annotations.filter {
|
||||
!isFromPrimaryConstructor || it.useSiteTarget == null ||
|
||||
it.useSiteTarget == CONSTRUCTOR_PARAMETER ||
|
||||
it.useSiteTarget == RECEIVER ||
|
||||
it.useSiteTarget == FILE
|
||||
}
|
||||
annotations += if (!isFromPrimaryConstructor)
|
||||
modifiers.annotations
|
||||
else
|
||||
modifiers.annotations.filter {
|
||||
val useSiteTarget = it.useSiteTarget
|
||||
useSiteTarget == null || useSiteTarget == CONSTRUCTOR_PARAMETER || useSiteTarget == RECEIVER || useSiteTarget == FILE
|
||||
}
|
||||
annotations += additionalAnnotations
|
||||
}
|
||||
return ValueParameter(isVal, isVar, modifiers, firValueParameter, destructuringDeclaration)
|
||||
|
||||
Reference in New Issue
Block a user