Uast: Fix for missing local variables in ctor-s bodies
similar to how it is done in `KotlinUBlockExpression`
This commit is contained in:
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
|||||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.utils.SmartList
|
import org.jetbrains.kotlin.utils.SmartList
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||||
import org.jetbrains.uast.*
|
import org.jetbrains.uast.*
|
||||||
import org.jetbrains.uast.kotlin.declarations.KotlinUMethod
|
import org.jetbrains.uast.kotlin.declarations.KotlinUMethod
|
||||||
@@ -157,9 +156,8 @@ open class KotlinConstructorUMethod(
|
|||||||
delegationCall?.let {
|
delegationCall?.let {
|
||||||
add(KotlinUFunctionCallExpression(it, uastParent))
|
add(KotlinUFunctionCallExpression(it, uastParent))
|
||||||
}
|
}
|
||||||
val languagePlugin = uastParent.getLanguagePlugin()
|
|
||||||
bodyExpressions.forEach {
|
bodyExpressions.forEach {
|
||||||
addIfNotNull(languagePlugin.convertOpt(it, uastParent))
|
add(KotlinConverter.convertOrEmpty(it, uastParent))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ class AWithSecondaryInit {
|
|||||||
|
|
||||||
constructor(s: String) {
|
constructor(s: String) {
|
||||||
a = s
|
a = s
|
||||||
|
var local: String = s
|
||||||
|
local.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -151,3 +151,11 @@ UFile (package = )
|
|||||||
UBinaryExpression (operator = =)
|
UBinaryExpression (operator = =)
|
||||||
USimpleNameReferenceExpression (identifier = a)
|
USimpleNameReferenceExpression (identifier = a)
|
||||||
USimpleNameReferenceExpression (identifier = s)
|
USimpleNameReferenceExpression (identifier = s)
|
||||||
|
UDeclarationsExpression
|
||||||
|
ULocalVariable (name = local)
|
||||||
|
USimpleNameReferenceExpression (identifier = s)
|
||||||
|
UQualifiedReferenceExpression
|
||||||
|
USimpleNameReferenceExpression (identifier = local)
|
||||||
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||||
|
UIdentifier (Identifier (toString))
|
||||||
|
USimpleNameReferenceExpression (identifier = toString)
|
||||||
|
|||||||
@@ -75,5 +75,7 @@ public final class AWithSecondaryInit {
|
|||||||
public fun AWithSecondaryInit(@org.jetbrains.annotations.NotNull s: java.lang.String) {
|
public fun AWithSecondaryInit(@org.jetbrains.annotations.NotNull s: java.lang.String) {
|
||||||
<init>()
|
<init>()
|
||||||
a = s
|
a = s
|
||||||
|
var local: java.lang.String = s
|
||||||
|
local.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user