Files
openide/plugins/kotlin/j2k
Alexey Belkov 5f107cb4c3 [kotlin] J2K: Copy paste: UninitializedPropertyAccessException on pasting incomplete code with variable reference
The problem:

Step 1: `JKSymbolProvider#preBuildTree` runs a visitor over the converted Java PSI,
so it is able to visit every field/parameter and create a `JKUniverseFieldSymbol` for them (with unbound `target`).

Step 2: `JavaToJKTreeBuilder#buildTree` is only able to build a JK tree for certain entry points.
It can't handle some types of incoming PSI elements (for example, `PsiParameterList`),
so we can meet a situation when some incomplete code is copy-pasted, and some PSI nodes will not be
visited by `JavaToJKTreeBuilder`. In the case of fields/parameters, it means that `JKUniverseFieldSymbol#target`
will remain unbound. So, we will get an `UninitializedPropertyAccessException` on accessing it
in conversions or JKCodeBuilder.

^KTIJ-30470 Fixed

GitOrigin-RevId: ebead0d7f3c1a89a8dcbe4367efa6b0a07e79f85
2024-06-28 14:53:17 +00:00
..
2024-06-21 14:43:34 +00:00