protected override void RemoveArgumentKeepingPossibleSideEffects(int argIndexToRemove, string methodName) { Expression expression = base.Argument(argIndexToRemove); Node argRootExp = expression.FindExpressionRoot(); LexicalInfo invExpStart = MethodSignatureChangerBase.FindExpressionStart(expression.FindRootStatement()); this.MoveArgumentExpressionOutsideCall(expression, argRootExp, invExpStart); this.AddStatementSeparatorAfterJustMovedArgumentExpression(expression, invExpStart); this.AddVariableDeclarationToHoldArgumentExpression(expression, argRootExp, base.VariableNameFor(methodName, expression)); this.RemoveArgumentSeparator(argIndexToRemove); }
private void MoveArgumentExpressionOutsideCall(Expression argument, Node argRootExp, LexicalInfo invExpStart) { LexicalInfo updateId = MethodSignatureChangerBase.FindExpressionStart(base.Invocation); base.UpdateCollector.Move(new SourceRange(argRootExp.SourcePosition(), argument.EndSourceLocation.OffsetedBy(0, 2).SourcePosition()), invExpStart.SourcePosition(), updateId, null).InclusiveRange = false; }
private static SourceRange ExtraSourceCodeRangeToCleanup(Expression argument, Expression previousArg, Expression nextArg) { if (previousArg != null) { return(new SourceRange(previousArg.EndSourceLocation.OffsetedBy(0, 1).SourcePosition(), MethodSignatureChangerBase.FindExpressionStart(argument).OffsetedBy(0, -1).SourcePosition())); } return(new SourceRange(argument.EndSourceLocation.OffsetedBy(0, 1).SourcePosition(), MethodSignatureChangerBase.FindExpressionStart(nextArg).OffsetedBy(0, -1).SourcePosition())); }