Exemplo n.º 1
0
 public static SyntaxToken GetNameToken(this NameSyntax nameSyntax)
 {
     while (true)
     {
         if (nameSyntax.CSharpKind() == SyntaxKind.IdentifierName)
         {
             return(((IdentifierNameSyntax)nameSyntax).Identifier);
         }
         else if (nameSyntax.CSharpKind() == SyntaxKind.QualifiedName)
         {
             nameSyntax = ((QualifiedNameSyntax)nameSyntax).Right;
         }
         else if (nameSyntax.CSharpKind() == SyntaxKind.GenericName)
         {
             return(((GenericNameSyntax)nameSyntax).Identifier);
         }
         else if (nameSyntax.CSharpKind() == SyntaxKind.AliasQualifiedName)
         {
             nameSyntax = ((AliasQualifiedNameSyntax)nameSyntax).Name;
         }
         else
         {
             throw new NotSupportedException();
         }
     }
 }