Skip to content

Commit 931ab48

Browse files
committed
Fixed overflow when referencing itself in for directive search
1 parent be7347f commit 931ab48

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/kotlin/org/domaframework/doma/intellij/inspection/ForDirectiveInspection.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,13 @@ class ForDirectiveInspection(
218218
}
219219
}
220220
val stack = mutableListOf<BlockToken>()
221+
val filterPosition = directiveBlocks.filter { it.position < targetElement.textOffset }
222+
filterPosition.forEach { block ->
223+
when (block.type) {
224+
BlockType.FOR, BlockType.IF -> stack.add(block)
225+
BlockType.END -> if (stack.isNotEmpty()) stack.removeAt(stack.lastIndex)
226+
}
227+
}
221228
directiveBlocks.forEach { block ->
222229
when (block.type) {
223230
BlockType.FOR, BlockType.IF -> stack.add(block)

0 commit comments

Comments
 (0)