mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
replace argument list instead of whole call when refactoring
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user