Partial body resolve: processing of standard "error" function

This commit is contained in:
Valentin Kipyatkov
2014-11-19 17:26:38 +03:00
parent ca8d45259b
commit 992cdd9fe2
7 changed files with 34 additions and 1 deletions
@@ -278,6 +278,14 @@ class PartialBodyResolveFilter(elementToResolve: JetElement, private val body: J
}
}
override fun visitCallExpression(expression: JetCallExpression) {
val name = (expression.getCalleeExpression() as? JetSimpleNameExpression)?.getReferencedName()
if (name != null && name in possiblyNothingFunctionNames) {
result.add(expression)
}
super.visitCallExpression(expression)
}
override fun visitBinaryExpression(expression: JetBinaryExpression) {
if (expression.getOperationToken() == JetTokens.ELVIS) {
// do not search exits after "?:"
@@ -360,5 +368,9 @@ class PartialBodyResolveFilter(elementToResolve: JetElement, private val body: J
private fun JetBlockExpression.lastStatement(): JetExpression?
= getLastChild().siblings(forward = false).filterIsInstance<JetExpression>().firstOrNull()
class object {
private val possiblyNothingFunctionNames = setOf("error") // currently hard-coded
}
}