本文整理汇总了C#中SyntaxToken.HasParent方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxToken.HasParent方法的具体用法?C# SyntaxToken.HasParent怎么用?C# SyntaxToken.HasParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxToken
的用法示例。
在下文中一共展示了SyntaxToken.HasParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitToken
public override void VisitToken(SyntaxToken token)
{
var s = token.ToString();
switch (token.Kind())
{
case SyntaxKind.UsingKeyword:
s = "@" + token.ToString() + " ";
break;
case SyntaxKind.ClassKeyword:
if ((token.Parent as ClassDeclarationSyntax).IsHiddenClassDeclaration())
{
s = "";
}
else
{
s = @"<script type='text/javascript' name='";
}
break;
case SyntaxKind.IdentifierToken:
var p = (token.Parent as ClassDeclarationSyntax);
if (p == null)
{ }
else
{
if (p.IsHiddenClassDeclaration())
{
s = "";
}
else
{
s = token.ToString() + "'>" + newLine;
}
}
var p1 = token.HasParent<IdentifierNameSyntax, SimpleBaseTypeSyntax, BaseListSyntax>();
s = Reset_If_Not_Null(p1, s);
var p3 = token.Parent as MethodDeclarationSyntax;
s = Reset_If_IsHiddenMethodDeclaration(p3, s);
var p11 = token.HasParent<IdentifierNameSyntax, TypeArgumentListSyntax>();
s = Reset_If_Not_Null(p11, s);
var p14 = token.HasParent<IdentifierNameSyntax, VariableDeclarationSyntax>();
if (p14 == null)
{
}
else
{
s = "var ";
}
var p141 = token.HasParent<IdentifierNameSyntax, ParameterSyntax>();
s = Reset_If_Not_Null(p141, s);
break;
case SyntaxKind.SemicolonToken:
s += newLine;
break;
case SyntaxKind.ColonToken:
var p4 = token.HasParent<BaseListSyntax, ClassDeclarationSyntax>();
s = Reset_If_Not_Null(p4, s);
break;
case SyntaxKind.CommaToken:
var p41 = token.Parent as TypeArgumentListSyntax;
s = Reset_If_Not_Null(p41, s);
break;
case SyntaxKind.OpenBraceToken:
s = s + newLine;
var p5 = token.Parent as ClassDeclarationSyntax;
s = Reset_If_Not_Null(p5, s);
var p2 = token.HasParent<BlockSyntax, MethodDeclarationSyntax>();
s = Reset_If_IsHiddenMethodDeclaration(p2, s);
break;
case SyntaxKind.CloseBraceToken:
s = s + newLine + newLine;
var p6 = token.HasParent<BlockSyntax, MethodDeclarationSyntax>();
s = Reset_If_IsHiddenMethodDeclaration(p6, s);
var p55 = token.Parent as ClassDeclarationSyntax;
if (p55 == null)
{ }
else
{
s = "</script>";
}
//.........这里部分代码省略.........
示例2: VisitToken
public override void VisitToken(SyntaxToken token)
{
var s = "";
if (token.IsKind(SyntaxKind.OpenBraceToken))
{
var up = token.HasParent<BlockSyntax, MethodDeclarationSyntax>();
if (up == null) { }
else
{
if (up.IsHiddenMethodDeclaration())
{ }
else
{
s = token.ToString();
}
}
}
else if (token.IsKind(SyntaxKind.CloseBraceToken))
{
var up = token.Parent as ClassDeclarationSyntax;
if (up == null)
{
}
else
{
if (up.IsHiddenClassDeclaration())
{ }
else
{
s = "</script>";
}
}
var up1 = token.HasParent<BlockSyntax, MethodDeclarationSyntax>();
if (up1 == null) { }
else
{
if (up1.IsHiddenMethodDeclaration())
{ }
else
{
s = token.ToString();
}
}
}
else if (token.IsKind(SyntaxKind.OpenParenToken))
{
var up = token.HasParent<ParameterListSyntax, MethodDeclarationSyntax>();
if (up == null)
{
}
else
{
if (up.IsHiddenMethodDeclaration())
{ }
else
{
s = token.ToString();
}
}
}
else if (token.IsKind(SyntaxKind.CloseParenToken))
{
var up = token.HasParent<ParameterListSyntax, MethodDeclarationSyntax>();
if (up == null)
{
}
else
{
if (up.IsHiddenMethodDeclaration())
{ }
else
{
s = token.ToString();
}
}
}
else if (token.IsKind(SyntaxKind.SemicolonToken))
{
var up = token.Parent as FieldDeclarationSyntax;
if (up == null)
{
}
else
{
s = token.ToString() + newLine;
}
}
_2JS.Append(s);
base.VisitToken(token);
}