NPE in Surround with Action on empty line

This commit is contained in:
Natalia Ukhorskaya
2015-04-13 14:40:16 +03:00
parent 38c154ace4
commit 34205c3ff0
4 changed files with 18 additions and 0 deletions
@@ -73,6 +73,8 @@ public class CodeInsightUtils {
startOffset = element1.getTextRange().getStartOffset();
endOffset = element2.getTextRange().getEndOffset();
if (startOffset >= endOffset) return PsiElement.EMPTY_ARRAY;
PsiElement parent = PsiTreeUtil.findCommonParent(element1, element2);
if (parent == null) return PsiElement.EMPTY_ARRAY;
while (true) {
@@ -0,0 +1,5 @@
fun foo() {
val a = ""
<caret>
a
}
@@ -0,0 +1,5 @@
fun foo() {
val a = ""
a
}
@@ -43,6 +43,12 @@ public class SurroundWithTestGenerated extends AbstractSurroundWithTest {
doTestWithIfSurrounder(fileName);
}
@TestMetadata("emptyLine.kt")
public void testEmptyLine() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/surroundWith/if/emptyLine.kt");
doTestWithIfSurrounder(fileName);
}
@TestMetadata("severalStatements.kt")
public void testSeveralStatements() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/surroundWith/if/severalStatements.kt");