replace argument list instead of whole call when refactoring

This commit is contained in:
Gabriela Araujo Britto
2019-02-15 15:51:20 -08:00
parent eef3da5b6b
commit b6c8382c78

View File

@@ -59,18 +59,15 @@ namespace ts.refactor.convertToNamedParameters {
forEach(functionCalls, call => {
if (call.arguments && call.arguments.length) {
const newArgument = getSynthesizedDeepClone(createNewArguments(functionDeclaration, call.arguments), /*includeTrivia*/ true);
const newCall = updateCallArguments(call, createNodeArray([newArgument]));
suppressLeadingAndTrailingTrivia(newCall, /*recursive*/ false);
changes.replaceNode(getSourceFileOfNode(call), call, newCall);
changes.replaceNodeRange(
getSourceFileOfNode(call),
first(call.arguments),
last(call.arguments),
newArgument,
{ startPosition: textChanges.LeadingTriviaOption.IncludeAll, endPosition: textChanges.TrailingTriviaOption.Include });
}});
}
function updateCallArguments(call: CallExpression | NewExpression, args: NodeArray<Expression>) {
const newCall = getSynthesizedClone(call);
newCall.arguments = args;
return updateNode(newCall, call);
}
function getGroupedReferences(functionNames: Node[], program: Program, cancellationToken: CancellationToken): GroupedReferences {
const functionRefs = flatMap(functionNames, name => FindAllReferences.getReferenceEntriesForNode(-1, name, program, program.getSourceFiles(), cancellationToken));
const groupedReferences = groupReferences(functionRefs);