stop at file level when going up the tree in KtPsiUtil.areParenthesesNecessary() (EA-86495 - NPE: KtPsiUtil.areParenthesesNecessary)

This commit is contained in:
Dmitry Jemerov
2016-08-11 20:02:15 +02:00
parent ef791fedde
commit 7ee72f2ebc
@@ -480,7 +480,7 @@ public class KtPsiUtil {
PsiElement current = parentElement;
while (!(current instanceof KtBlockExpression || current instanceof KtDeclaration || current instanceof KtStatementExpression)) {
while (!(current instanceof KtBlockExpression || current instanceof KtDeclaration || current instanceof KtStatementExpression || current instanceof KtFile)) {
if (current.getTextRange().getEndOffset() != currentInner.getTextRange().getEndOffset()) {
return !(current instanceof KtParenthesizedExpression) && !(current instanceof KtValueArgumentList); // if current expression is "guarded" by parenthesis, no extra parenthesis is necessary
}