internal ArgumentReference( QualifiedModuleName qualifiedName, Declaration parentScopingDeclaration, Declaration parentNonScopingDeclaration, string identifierName, Selection argumentSelection, ParserRuleContext context, VBAParser.ArgumentListContext argumentListContext, ArgumentListArgumentType argumentType, int argumentPosition, ParameterDeclaration referencedParameter, IEnumerable <IParseTreeAnnotation> annotations = null) : base( qualifiedName, parentScopingDeclaration, parentNonScopingDeclaration, identifierName, argumentSelection, context, referencedParameter, false, false, annotations) { ArgumentType = argumentType; ArgumentPosition = argumentPosition; ArgumentListContext = argumentListContext; NumberOfArguments = ArgumentListContext?.argument()?.Length ?? 0; ArgumentListSelection = argumentListContext?.GetSelection() ?? Selection.Empty; }
private void RewriteCall(VBAParser.ArgumentListContext argList, QualifiedModuleName module, IRewriteSession rewriteSession) { var rewriter = rewriteSession.CheckOutModuleRewriter(module); var args = argList.argument().Select((s, i) => new { Index = i, Text = s.GetText() }).ToList(); for (var i = 0; i < _model.Parameters.Count; i++) { if (argList.argument().Length <= i) { break; } var arg = argList.argument()[i]; rewriter.Replace(arg, args.Single(s => s.Index == _model.Parameters[i].Index).Text); } }
private static RewriterInfo GetRewriterInfo(VBAParser.ArgumentContext arg, VBAParser.ArgumentListContext argList) { if (argList == null) { throw new ArgumentNullException(nameof(argList), @"Context is null. Expecting a VBAParser.ArgumentListContext instance."); } var items = argList.argument(); var itemIndex = items.ToList().IndexOf(arg); if (items.Length == 1) { return(new RewriterInfo(argList.Start.TokenIndex, argList.Stop.TokenIndex)); } return(GetRewriterInfoForTargetRemovedFromListStmt(arg.Start, itemIndex, argList.argument())); }
private void RewriteCall(VBAParser.ArgumentListContext argList, ICodeModule module) { var rewriter = _model.State.GetRewriter(module.Parent); var args = argList.argument().Select((s, i) => new { Index = i, Text = s.GetText() }).ToList(); for (var i = 0; i < _model.Parameters.Count; i++) { if (argList.argument().Count <= i) { break; } var arg = argList.argument()[i]; rewriter.Replace(arg, args.Single(s => s.Index == _model.Parameters[i].Index).Text); } _rewriters.Add(rewriter); }
private static void RemoveArgumentRange( int startArgumentIndex, int stopArgumentIndex, VBAParser.ArgumentListContext argumentList, IModuleRewriter rewriter) { var(startTokenIndex, stopTokenIndex) = TokenIndexRange(startArgumentIndex, stopArgumentIndex, argumentList.argument()); rewriter.RemoveRange(startTokenIndex, stopTokenIndex); }