KotlinFunctionCallUsage: fix psi tree

#KT-38632
This commit is contained in:
Dmitry Gridin
2020-04-29 14:06:19 +07:00
parent 11a3482970
commit ee0b7426c4
3 changed files with 9 additions and 5 deletions
@@ -305,11 +305,13 @@ class KotlinFunctionCallUsage(
defaultValueForCall != null -> substituteReferences(defaultValueForCall, parameter.defaultValueParameterReferences, psiFactory)
else -> null
}
val argName = (if (isInsideOfCallerBody) null else name)?.let { Name.identifier(it) }
return psiFactory.createArgument(argValue ?: psiFactory.createExpression("0"), argName).apply {
generatedArgumentValue = true
if (argValue == null) {
getArgumentExpression()!!.delete()
getArgumentExpression()?.delete()
} else {
generatedArgumentValue = true
}
}
}
@@ -437,7 +439,9 @@ class KotlinFunctionCallUsage(
}
val oldArgumentList = element.valueArgumentList.sure { "Argument list is expected: " + element.text }
replaceListPsiAndKeepDelimiters(oldArgumentList, newArgumentList) { arguments }
for (argument in replaceListPsiAndKeepDelimiters(oldArgumentList, newArgumentList) { arguments }.arguments) {
if (argument.getArgumentExpression() == null) argument.delete()
}
element.accept(
object : KtTreeVisitorVoid() {
@@ -4,5 +4,5 @@
class A<T>(val n: T, val foo: A<Int>)
fun test() {
val a: A<Int> = A(1, ).foo
val a: A<Int> = A(1,).foo
}
@@ -4,5 +4,5 @@
class A<T>(val n: T, var foo: String)
fun test() {
A(1, ).foo = "1"
A(1,).foo = "1"
}