本文整理汇总了C#中LiteralExpressionSyntax.Kind方法的典型用法代码示例。如果您正苦于以下问题:C# LiteralExpressionSyntax.Kind方法的具体用法?C# LiteralExpressionSyntax.Kind怎么用?C# LiteralExpressionSyntax.Kind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LiteralExpressionSyntax
的用法示例。
在下文中一共展示了LiteralExpressionSyntax.Kind方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitLiteralExpression
public override SyntaxNode VisitLiteralExpression(LiteralExpressionSyntax node)
{
switch (node.Kind())
{
case SyntaxKind.StringLiteralExpression:
return RewriteStringLiteralExpression(node);
case SyntaxKind.CharacterLiteralExpression:
return RewriteCharacterLiteralExpression(node);
}
return node;
}
示例2: VisitLiteralExpression
public override void VisitLiteralExpression(LiteralExpressionSyntax node)
{
switch (node.Kind())
{
case SyntaxKind.TrueLiteralExpression:
VisitSymbol("true");
break;
case SyntaxKind.FalseLiteralExpression:
VisitSymbol("false");
break;
default:
throw new InvalidPreprocessorExpressionException("Expected true or false literal expression");
}
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-codeformatter-dotnet,代码行数:14,代码来源:PreprocessorSymbolTracker.cs
示例3: RewriteCharacterLiteralExpression
private static SyntaxNode RewriteCharacterLiteralExpression(LiteralExpressionSyntax node)
{
Debug.Assert(node.Kind() == SyntaxKind.CharacterLiteralExpression);
if (HasNonAsciiCharacters(node.Token.Text))
{
string convertedText = EscapeNonAsciiCharacters(node.Token.Text);
SyntaxToken t = SyntaxFactory.Literal(node.Token.LeadingTrivia, convertedText, node.Token.ValueText, node.Token.TrailingTrivia);
node = node.WithToken(t);
}
return node;
}
示例4: RewriteStringLiteralExpression
private static SyntaxNode RewriteStringLiteralExpression(LiteralExpressionSyntax node)
{
Debug.Assert(node.Kind() == SyntaxKind.StringLiteralExpression);
if (node.Token.IsVerbatimStringLiteral())
{
// We do not correctly rewrite verbatim string literals yet. Once Issue 39 is
// fixed we can remove this early out.
return node;
}
if (HasNonAsciiCharacters(node.Token.Text))
{
string convertedText = EscapeNonAsciiCharacters(node.Token.Text);
SyntaxToken t = SyntaxFactory.Literal(node.Token.LeadingTrivia, convertedText, node.Token.ValueText, node.Token.TrailingTrivia);
node = node.WithToken(t);
}
return node;
}
示例5: VisitLiteralExpression
public override void VisitLiteralExpression(LiteralExpressionSyntax node)
{
if (node.Kind() == SyntaxKind.StringLiteralExpression)
cb.Append("std::string(").Append(node.ToString()).Append(")");
else
cb.Append(node.ToString());
}
示例6: VisitLiteralExpression
public override SyntaxNode VisitLiteralExpression(LiteralExpressionSyntax node)
{
switch (node.Kind())
{
case SyntaxKind.FalseLiteralExpression:
_output.Write(node, "false");
break;
case SyntaxKind.TrueLiteralExpression:
_output.Write(node, "true");
break;
case SyntaxKind.NullLiteralExpression:
_output.Write(node, "null");
break;
case SyntaxKind.NumericLiteralExpression:
string num = node.GetText().ToString().Trim();//Note:Keep everything, e.g. prefix 0, in C#, it has no meaning, but it means octet in js
if (!char.IsNumber(num[num.Length - 1]))//Note:Remove postfix, since C# has l,m etc as postfix.
{
num = num.Substring(0, num.Length - 1);
}
_output.Write(node, num);
break;
case SyntaxKind.StringLiteralExpression:
string str = node.Token.ValueText.Bracketing(StringPair.DoubleQuote);
if (str[0] == '@')
{
str = str.Substring(1);
this.AppendCompileIssue(node, IssueType.Warning, IssueId.StringPrefixIgnore);
}
_output.Write(node, str);
break;
case SyntaxKind.CharacterLiteralExpression:
_output.Write(node, node.Token.ValueText.Bracketing(StringPair.SingleQuote));
break;
default:
this.AppendCompileIssue(node, IssueType.Error, IssueId.UnknownExpressionType, node.Kind());
break;
}
return node;
}
示例7: VisitLiteralExpression
public override SyntaxNode VisitLiteralExpression(LiteralExpressionSyntax node)
{
node = (LiteralExpressionSyntax)base.VisitLiteralExpression(node);
var token = node.Token;
if ((transformKind == TransformKind.TrueToFalse) && (node.Kind() == SyntaxKind.TrueLiteralExpression))
{
var newToken = SyntaxFactory.Token(token.LeadingTrivia, SyntaxKind.FalseKeyword, token.TrailingTrivia);
return SyntaxFactory.LiteralExpression(SyntaxKind.FalseLiteralExpression, newToken);
}
if ((transformKind == TransformKind.FalseToTrue) && (node.Kind() == SyntaxKind.FalseLiteralExpression))
{
var newToken = SyntaxFactory.Token(token.LeadingTrivia, SyntaxKind.TrueKeyword, token.TrailingTrivia);
return SyntaxFactory.LiteralExpression(SyntaxKind.TrueLiteralExpression, newToken);
}
return node;
}