JetPsiFactory: refactored method for creating argument + introduced ability to create arbitrary constructs by pattern
This commit is contained in:
@@ -147,7 +147,7 @@ public class AddNameToArgumentFix extends JetIntentionAction<JetValueArgument> {
|
||||
private static JetValueArgument getParsedArgumentWithName(@NotNull String name, @NotNull JetValueArgument argument) {
|
||||
JetExpression argumentExpression = argument.getArgumentExpression();
|
||||
assert argumentExpression != null : "Argument should be already parsed.";
|
||||
return JetPsiFactory(argument).createArgumentWithName(name, argumentExpression);
|
||||
return JetPsiFactory(argument).createArgument(argumentExpression, name, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-1
@@ -369,7 +369,7 @@ public class JetFunctionCallUsage extends JetUsageInfo<JetCallElement> {
|
||||
changeArgumentName(argumentNameExpression, parameterInfo);
|
||||
//noinspection ConstantConditions
|
||||
newArgument.replace(oldArgument instanceof JetFunctionLiteralArgument
|
||||
? psiFactory.createArgument(oldArgument.getArgumentExpression())
|
||||
? psiFactory.createArgument(oldArgument.getArgumentExpression(), null, false)
|
||||
: oldArgument.asElement());
|
||||
}
|
||||
// TODO: process default arguments in the middle
|
||||
|
||||
@@ -48,7 +48,7 @@ fun JetFunctionLiteralArgument.moveInsideParenthesesAndReplaceWith(
|
||||
|
||||
val psiFactory = JetPsiFactory(getProject())
|
||||
val argument = if (newCallExpression.getValueArgumentsInParentheses().any { it.getArgumentName() != null }) {
|
||||
psiFactory.createArgumentWithName(functionLiteralArgumentName, replacement)
|
||||
psiFactory.createArgument(replacement, functionLiteralArgumentName)
|
||||
}
|
||||
else {
|
||||
psiFactory.createArgument(replacement)
|
||||
|
||||
Reference in New Issue
Block a user