mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-141982 SOE, recursion eliminated
This commit is contained in:
BIN
Binary file not shown.
+11
@@ -16,8 +16,11 @@
|
||||
package com.intellij.psi.codeStyle.autodetect;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.formatting.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class NewLineBlocksIteratorTest extends AbstractNewLineBlocksIteratorTest {
|
||||
|
||||
@NotNull
|
||||
@@ -46,5 +49,13 @@ public class NewLineBlocksIteratorTest extends AbstractNewLineBlocksIteratorTest
|
||||
|
||||
checkNewLineBlocksStartOffsets(newLineBlocksStartOffsets);
|
||||
}
|
||||
|
||||
public void testBigFileWithOnlyErrorElements_DoNotProduceSOE() {
|
||||
configureByFile(getFileName() + ".java");
|
||||
Iterator<Block> iterator = createNewLineBlocksIterator();
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
-12
@@ -71,19 +71,18 @@ public class NewLineBlocksIterator implements Iterator<Block> {
|
||||
}
|
||||
|
||||
private void popUntilTopBlockStartOffsetGreaterOrEqual(final int lineStartOffset) {
|
||||
if (myStack.isEmpty()) return;
|
||||
|
||||
Block current = myStack.peek();
|
||||
TextRange range = current.getTextRange();
|
||||
int currentStartOffset = range.getStartOffset();
|
||||
int currentEndOffset = range.getEndOffset();
|
||||
|
||||
if (currentStartOffset < lineStartOffset) {
|
||||
myStack.pop();
|
||||
if (currentEndOffset > lineStartOffset) {
|
||||
pushAll(current);
|
||||
while (!myStack.isEmpty()) {
|
||||
Block current = myStack.peek();
|
||||
TextRange range = current.getTextRange();
|
||||
if (range.getStartOffset() < lineStartOffset) {
|
||||
myStack.pop();
|
||||
if (range.getEndOffset() > lineStartOffset) {
|
||||
pushAll(current);
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
popUntilTopBlockStartOffsetGreaterOrEqual(lineStartOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user