Add null checks to LambdaExtractor.enterAnnotatedLambda

This commit is contained in:
Edwin Jakobs
2020-05-22 21:19:57 +02:00
parent edb92005db
commit e1e920e1e6

View File

@@ -43,11 +43,13 @@ class LambdaExtractor(val ruleNames: List<String>, val lambdaName: String) : Kot
var result: String? = null var result: String? = null
override fun enterAnnotatedLambda(ctx: KotlinParser.AnnotatedLambdaContext?) { override fun enterAnnotatedLambda(ctx: KotlinParser.AnnotatedLambdaContext?) {
val puec = ctx!!.parent!!.parent!!.parent!! as KotlinParser.PostfixUnaryExpressionContext val puec = ctx?.parent?.parent?.parent as? KotlinParser.PostfixUnaryExpressionContext
val identifier = puec.primaryExpression().simpleIdentifier().Identifier().text if (puec != null) {
if (identifier == lambdaName) { val identifier = puec.primaryExpression()?.simpleIdentifier()?.Identifier()?.text
if (result == null) { if (identifier == lambdaName) {
result = ctx.verbatimText(1, 1) if (result == null) {
result = ctx.verbatimText(1, 1)
}
} }
} }
} }