DeprecatedSymbolUsageFix: can drop more arguments when function literal argument exist

This commit is contained in:
Valentin Kipyatkov
2015-05-22 17:13:33 +03:00
parent 2e2701aa61
commit a9e00a3264
7 changed files with 73 additions and 7 deletions
@@ -230,6 +230,9 @@ public abstract class DeprecatedSymbolUsageFixBase(
// TODO: process introduced variables too
introduceNamedArguments(result)
// TODO: process introduced variables too
restoreFunctionLiteralArguments(result)
//TODO: do this earlier
dropArgumentsForDefaultValues(result)
@@ -250,9 +253,6 @@ public abstract class DeprecatedSymbolUsageFixBase(
// TODO: process introduced variables too
simplifySpreadArrayOfArguments(result)
// TODO: process introduced variables too
restoreFunctionLiteralArguments(result)
// clean up user data
//TODO: not correct - we do not process introduced declarations before!!!
result.forEachDescendantOfType<JetExpression> {
@@ -541,6 +541,12 @@ public abstract class DeprecatedSymbolUsageFixBase(
argument as JetValueArgument
val argumentList = argument.getParent() as JetValueArgumentList
argumentList.removeArgument(argument)
if (argumentList.getArguments().isEmpty()) {
val callExpression = argumentList.getParent() as JetCallExpression
if (callExpression.getFunctionLiteralArguments().isNotEmpty()) {
argumentList.delete()
}
}
}
}