fix exception on select word when code block has no children (EA-64075 - AIOOBE: CodeBlockOrInitializerSelectioner.findClosingBrace)

This commit is contained in:
Dmitry Jemerov committed 2015-02-03 19:30:25 +01:00
1 parent 5ca34b9263
commit e53b863550
1 file changed
+7 -7
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,14 +31,14 @@ public class CodeBlockOrInitializerSelectioner extends BasicSelectioner {
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
List<TextRange> result = new ArrayList<TextRange>();
result.add(e.getTextRange());
PsiElement[] children = e.getChildren();
int start = findOpeningBrace(children);
int end = findClosingBrace(children, start);
result.add(e.getTextRange());
result.addAll(expandToWholeLine(editorText, new TextRange(start, end)));
if (children.length > 0) {
int start = findOpeningBrace(children);
int end = findClosingBrace(children, start);
result.addAll(expandToWholeLine(editorText, new TextRange(start, end)));
}
return result;
}