FIR LT: simplify defaultValue() search

This commit is contained in:
Mikhail Glukhikh
2021-01-27 18:43:33 +03:00
parent 8b4f2b269c
commit df68f319bc
@@ -345,14 +345,13 @@ private fun FlyweightCapableTreeStructure<LighterASTNode>.defaultValue(node: Lig
val childrenRef = Ref<Array<LighterASTNode?>>() val childrenRef = Ref<Array<LighterASTNode?>>()
getChildren(node, childrenRef) getChildren(node, childrenRef)
// p : T = v // p : T = v
return childrenRef.get()?.reversed()?.firstOrNull { val children = childrenRef.get()?.reversed() ?: return null
it != null && for (child in children) {
it.tokenType != KtTokens.WHITE_SPACE && if (child == null || child.tokenType == KtTokens.WHITE_SPACE) continue
it.tokenType != KtTokens.EQ && if (child.tokenType == KtNodeTypes.TYPE_REFERENCE || child.tokenType == KtTokens.COLON) return null
it.tokenType != KtNodeTypes.TYPE_REFERENCE && return child
it.tokenType != KtTokens.COLON &&
it.tokenType != KtTokens.IDENTIFIER
} }
return null
} }
fun FlyweightCapableTreeStructure<LighterASTNode>.findChildByType(node: LighterASTNode, type: IElementType): LighterASTNode? { fun FlyweightCapableTreeStructure<LighterASTNode>.findChildByType(node: LighterASTNode, type: IElementType): LighterASTNode? {