[FIR] Fix calculating offsets of light tree source elements for local declarations

This commit is contained in:
Dmitriy Novozhilov
2020-12-18 15:05:27 +03:00
committed by TeamCityServer
parent 298e27bdac
commit 554fa358e8
2 changed files with 11 additions and 1 deletions
@@ -126,6 +126,16 @@ abstract class BaseConverter(
return tree.getParent(this)
}
fun LighterASTNode.getParents(): Sequence<LighterASTNode> {
var node = this
return sequence {
while (true) {
yield(node)
node = node.getParent() ?: break
}
}
}
fun LighterASTNode?.getChildNodesByType(type: IElementType): List<LighterASTNode> {
return this?.forEachChildrenReturnList { node, container ->
when (node.tokenType) {
@@ -1410,7 +1410,7 @@ class DeclarationsConverter(
return if (!stubMode) {
val blockTree = LightTree2Fir.buildLightTreeBlockExpression(block.asText)
return DeclarationsConverter(
baseSession, baseScopeProvider, stubMode, blockTree, offset = tree.getStartOffset(block), context
baseSession, baseScopeProvider, stubMode, blockTree, offset = offset + tree.getStartOffset(block), context
).convertBlockExpression(blockTree.root)
} else {
val firExpression = buildExpressionStub()