当前位置: 首页>>代码示例>>C#>>正文


C# LiteralExpressionSyntax.Kind方法代码示例

本文整理汇总了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;
            }
开发者ID:chuck-mitchell,项目名称:codeformatter,代码行数:12,代码来源:NonAsciiCharactersAreEscapedInLiteralsRule.cs

示例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;
            }
开发者ID:chuck-mitchell,项目名称:codeformatter,代码行数:15,代码来源:NonAsciiCharactersAreEscapedInLiteralsRule.cs

示例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;
            }
开发者ID:chuck-mitchell,项目名称:codeformatter,代码行数:22,代码来源:NonAsciiCharactersAreEscapedInLiteralsRule.cs

示例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());
 }
开发者ID:ActiveMesa,项目名称:Blackmire,代码行数:7,代码来源:CppImplWalker.cs

示例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;
        }
开发者ID:rexzh,项目名称:SharpJs,代码行数:47,代码来源:Rewriter_Expression.cs

示例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;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:22,代码来源:TransformVisitor.cs


注:本文中的LiteralExpressionSyntax.Kind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。