Skip to content

Commit 9c4d98a

Browse files
committed
EA-71083 - NPE: BnfFlipChoiceIntention.invoke
1 parent 2414a4b commit 9c4d98a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

support/org/intellij/grammar/intention/BnfFlipChoiceIntention.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public String getText() {
4444
@NotNull
4545
@Override
4646
public String getFamilyName() {
47-
return "Flip Choice Intention";
47+
return "Flip choice intention";
4848
}
4949

5050
@Override
@@ -63,15 +63,15 @@ public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws
6363
}
6464

6565
@Nullable
66-
private Pair<PsiElement, PsiElement> getArguments(PsiFile file, int offset) {
66+
private static Pair<PsiElement, PsiElement> getArguments(PsiFile file, int offset) {
6767
PsiElement element = file.getViewProvider().findElementAt(offset);
6868
final BnfChoice choice = PsiTreeUtil.getParentOfType(element, BnfChoice.class);
6969
if (choice == null) return null;
7070
for (PsiElement cur = choice.getFirstChild(), prev = null; cur != null; cur = cur.getNextSibling()) {
7171
if (!(cur instanceof BnfExpression) ) continue;
7272
int start = prev == null? choice.getTextRange().getStartOffset() : prev.getTextRange().getEndOffset();
7373
int end = cur.getTextRange().getStartOffset();
74-
if (start <= offset && offset <= end) return Pair.create(cur, prev);
74+
if (start <= offset && offset <= end) return prev == null ? null : Pair.create(cur, prev);
7575
prev = cur;
7676
}
7777
return null;

0 commit comments

Comments
 (0)