本文整理汇总了C#中DirectionExpression.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# DirectionExpression.AddChild方法的具体用法?C# DirectionExpression.AddChild怎么用?C# DirectionExpression.AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectionExpression
的用法示例。
在下文中一共展示了DirectionExpression.AddChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertArgument
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);
}
示例2: ConvertArgument
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);
}
示例3: AddArguments
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);
}