Esempio n. 1
0
			Expression ConvertArgument (Argument arg)
			{
				if (arg is NamedArgument) {
					var na = (NamedArgument)arg;
					NamedArgumentExpression newArg = new NamedArgumentExpression();
					newArg.AddChild (Identifier.Create (na.Name, Convert (na.Location)), NamedArgumentExpression.Roles.Identifier);
					
					var loc = LocationsBag.GetLocations (na);
					if (loc != null)
						newArg.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), NamedArgumentExpression.Roles.Colon);
					
					if (arg.ArgType == Argument.AType.Out || arg.ArgType == Argument.AType.Ref) {
						DirectionExpression direction = new DirectionExpression ();
						direction.FieldDirection = arg.ArgType == Argument.AType.Out ? FieldDirection.Out : FieldDirection.Ref;
						var argLocation = LocationsBag.GetLocations (arg);
						if (argLocation != null)
							direction.AddChild (new CSharpTokenNode (Convert (argLocation[0]), "123".Length), InvocationExpression.Roles.Keyword);
						direction.AddChild ((Expression)arg.Expr.Accept (this), InvocationExpression.Roles.Expression);
						newArg.AddChild (direction, NamedArgumentExpression.Roles.Expression);
					} else {
						newArg.AddChild ((Expression)na.Expr.Accept (this), NamedArgumentExpression.Roles.Expression);
					}
					return newArg;
				}
				
				if (arg.ArgType == Argument.AType.Out || arg.ArgType == Argument.AType.Ref) {
					DirectionExpression direction = new DirectionExpression ();
					direction.FieldDirection = arg.ArgType == Argument.AType.Out ? FieldDirection.Out : FieldDirection.Ref;
					var argLocation = LocationsBag.GetLocations (arg);
					if (argLocation != null)
						direction.AddChild (new CSharpTokenNode (Convert (argLocation[0]), "123".Length), InvocationExpression.Roles.Keyword);
					direction.AddChild ((Expression)arg.Expr.Accept (this), InvocationExpression.Roles.Expression);
					return direction;
				}
				
				return (Expression)arg.Expr.Accept (this);
			}
Esempio n. 2
0
			Expression ConvertArgument(Argument arg)
			{
				var na = arg as NamedArgument;
				if (na != null) {
					var newArg = new NamedArgumentExpression();
					newArg.AddChild(Identifier.Create(na.Name, Convert(na.Location)), Roles.Identifier);
					
					var loc = LocationsBag.GetLocations(na);
					if (loc != null)
						newArg.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Colon), Roles.Colon);
					
					if (arg.ArgType == Argument.AType.Out || arg.ArgType == Argument.AType.Ref) {
						var direction = new DirectionExpression();
						direction.FieldDirection = arg.ArgType == Argument.AType.Out ? FieldDirection.Out : FieldDirection.Ref;
						var argLocation = LocationsBag.GetLocations(arg);
						if (argLocation != null) {
							var r = arg.ArgType == Argument.AType.Out ? DirectionExpression.OutKeywordRole : DirectionExpression.RefKeywordRole;
							direction.AddChild(new CSharpTokenNode(Convert(argLocation [0]), r), r);
						}
						direction.AddChild((Expression)arg.Expr.Accept(this), Roles.Expression);
						newArg.AddChild(direction, Roles.Expression);
					} else {
						newArg.AddChild(na.Expr != null ? (Expression)na.Expr.Accept(this) : new ErrorExpression("Named argument expression parse error"), Roles.Expression);
					}
					return newArg;
				}
				
				if (arg.ArgType == Argument.AType.Out || arg.ArgType == Argument.AType.Ref) {
					var direction = new DirectionExpression();
					direction.FieldDirection = arg.ArgType == Argument.AType.Out ? FieldDirection.Out : FieldDirection.Ref;
					var argLocation = LocationsBag.GetLocations(arg);
					if (argLocation != null) {
						var r = arg.ArgType == Argument.AType.Out ? DirectionExpression.OutKeywordRole : DirectionExpression.RefKeywordRole;
						direction.AddChild(new CSharpTokenNode(Convert(argLocation [0]), r), r);
					}
					direction.AddChild((Expression)arg.Expr.Accept(this), Roles.Expression);
					return direction;
				}
				
				return (Expression)arg.Expr.Accept(this);
			}
Esempio n. 3
0
			void AddArguments (AbstractCSharpNode parent, object location, Mono.CSharp.Arguments args)
			{
				if (args == null)
					return;
				
				var commaLocations = LocationsBag.GetLocations (args);
				
				for (int i = 0; i < args.Count; i++) {
					Argument arg = args[i];
					if (arg.ArgType == Argument.AType.Out || arg.ArgType == Argument.AType.Ref) {
						DirectionExpression direction = new DirectionExpression ();
						direction.FieldDirection = arg.ArgType == Argument.AType.Out ? FieldDirection.Out : FieldDirection.Ref;
						var argLocation = LocationsBag.GetLocations (arg);
						if (location != null)
							direction.AddChild (new CSharpTokenNode (Convert (argLocation[0]), "123".Length), InvocationExpression.Roles.Keyword);
						direction.AddChild ((INode)arg.Expr.Accept (this), InvocationExpression.Roles.Expression);
						
						parent.AddChild (direction, InvocationExpression.Roles.Argument);
					} else {
						parent.AddChild ((INode)arg.Expr.Accept (this), InvocationExpression.Roles.Argument);
					}
					if (commaLocations != null && i > 0) {
						int idx = commaLocations.Count - i;
						if (idx >= 0)
							parent.AddChild (new CSharpTokenNode (Convert (commaLocations[idx]), 1), InvocationExpression.Roles.Comma);
					}
				}
				if (commaLocations != null && commaLocations.Count > args.Count) 
					parent.AddChild (new CSharpTokenNode (Convert (commaLocations[0]), 1), InvocationExpression.Roles.Comma);
			}