本文整理汇总了C#中AstType.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# AstType.AddChild方法的具体用法?C# AstType.AddChild怎么用?C# AstType.AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstType
的用法示例。
在下文中一共展示了AstType.AddChild方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTypeArguments
void AddTypeArguments (ATypeNameExpression texpr, AstType result)
{
if (texpr.TypeArguments == null || texpr.TypeArguments.Args == null)
return;
var loc = LocationsBag.GetLocations (texpr.TypeArguments);
if (loc != null && loc.Count >= 2)
result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 2]), 1), AstType.Roles.LChevron);
int i = 0;
foreach (var arg in texpr.TypeArguments.Args) {
result.AddChild (ConvertToType (arg), AstType.Roles.TypeArgument);
if (loc != null && i < loc.Count - 2)
result.AddChild (new CSharpTokenNode (Convert (loc [i++]), 1), AstType.Roles.Comma);
}
if (loc != null && loc.Count >= 2)
result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 1]), 1), AstType.Roles.RChevron);
}
示例2: AddTypeArguments
void AddTypeArguments (ATypeNameExpression texpr, AstType result)
{
if (!texpr.HasTypeArguments)
return;
foreach (var arg in texpr.TypeArguments.Args) {
result.AddChild (ConvertToType (arg), AstType.Roles.TypeArgument);
}
}
示例3: AddTypeArguments
void AddTypeArguments(ATypeNameExpression texpr, AstType result)
{
var unbound = texpr.TypeArguments as UnboundTypeArguments;
if (unbound != null) {
var loc2 = LocationsBag.GetLocations(texpr.TypeArguments);
if (loc2 == null)
return;
int j = 0;
if (j < loc2.Count)
result.AddChild(new CSharpTokenNode(Convert(loc2 [j++]), Roles.LChevron), Roles.LChevron);
while (j < loc2.Count - 1) {
result.AddChild (new SimpleType (), Roles.TypeArgument);
result.AddChild(new CSharpTokenNode(Convert(loc2 [j++]), Roles.LChevron), Roles.Comma);
}
if (j < loc2.Count) {
result.AddChild (new SimpleType (), Roles.TypeArgument);
result.AddChild(new CSharpTokenNode(Convert(loc2 [j++]), Roles.RChevron), Roles.RChevron);
}
return;
}
if (texpr.TypeArguments == null || texpr.TypeArguments.Args == null)
return;
var loc = LocationsBag.GetLocations(texpr.TypeArguments);
if (loc != null && loc.Count >= 2)
result.AddChild(new CSharpTokenNode(Convert(loc [loc.Count - 2]), Roles.LChevron), Roles.LChevron);
int i = 0;
foreach (var arg in texpr.TypeArguments.Args) {
result.AddChild(ConvertToType(arg), Roles.TypeArgument);
if (loc != null && i < loc.Count - 2)
result.AddChild(new CSharpTokenNode(Convert(loc [i++]), Roles.Comma), Roles.Comma);
}
if (loc != null && loc.Count >= 2)
result.AddChild(new CSharpTokenNode(Convert(loc [loc.Count - 1]), Roles.RChevron), Roles.RChevron);
}
示例4: AddTypeArguments
/// <summary>
/// Adds type arguments to the result type.
/// </summary>
/// <param name="result">The result AST node (a SimpleType or MemberType)</param>
/// <param name="typeDef">The type definition that owns the type parameters</param>
/// <param name="typeArguments">The list of type arguments</param>
/// <param name="startIndex">Index of first type argument to add</param>
/// <param name="endIndex">Index after last type argument to add</param>
void AddTypeArguments(AstType result, ITypeDefinition typeDef, IList<IType> typeArguments, int startIndex, int endIndex)
{
Debug.Assert(endIndex <= typeDef.TypeParameterCount);
for (int i = startIndex; i < endIndex; i++) {
if (ConvertUnboundTypeArguments && typeArguments[i].Kind == TypeKind.UnboundTypeArgument) {
result.AddChild(new SimpleType(typeDef.TypeParameters[i].Name), Roles.TypeArgument);
} else {
result.AddChild(ConvertType(typeArguments[i]), Roles.TypeArgument);
}
}
}
示例5: AddTypeArguments
/// <summary>
/// Adds type arguments to the result type.
/// </summary>
/// <param name="result">The result AST node (a SimpleType or MemberType)</param>
/// <param name="typeArguments">The list of type arguments</param>
/// <param name="startIndex">Index of first type argument to add</param>
/// <param name="endIndex">Index after last type argument to add</param>
void AddTypeArguments(AstType result, IList<IType> typeArguments, int startIndex, int endIndex)
{
for (int i = startIndex; i < endIndex; i++) {
result.AddChild(ConvertType(typeArguments[i]), AstType.Roles.TypeArgument);
}
}