Quickfix to add a loop label when 'break' or 'continue' is used in a loop inside 'when'

#KT-7202 Fixed
This commit is contained in:
Dmitry Jemerov
2015-04-29 18:05:45 +02:00
parent 625096466e
commit 6f4cae03fe
11 changed files with 210 additions and 0 deletions
@@ -321,6 +321,9 @@ public class JetPsiFactory(private val project: Project) {
return (createExpression("this@" + labelName) as JetThisExpression).getTargetLabel()!!
}
public fun createLabeledExpression(labelName: String): JetLabeledExpression
= createExpression("$labelName@ 1") as JetLabeledExpression
public fun createFieldIdentifier(fieldName: String): JetExpression {
return createExpression("$" + fieldName)
}
@@ -562,6 +562,8 @@ public class JetPsiUtil {
return true;
}
if (parentExpression instanceof JetLabeledExpression) return false;
// 'x ?: ...' case
if (parentExpression instanceof JetBinaryExpression && parentOperation == JetTokens.ELVIS && currentInner == ((JetBinaryExpression) parentExpression).getRight()) {
return false;