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


C# SyntaxToken.IsVerbatimStringLiteral方法代码示例

本文整理汇总了C#中SyntaxToken.IsVerbatimStringLiteral方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxToken.IsVerbatimStringLiteral方法的具体用法?C# SyntaxToken.IsVerbatimStringLiteral怎么用?C# SyntaxToken.IsVerbatimStringLiteral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SyntaxToken的用法示例。


在下文中一共展示了SyntaxToken.IsVerbatimStringLiteral方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetClassification

        /// <summary>
        /// Determine the classification type for a given token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <returns>The correct syntactic classification for the token.</returns>
        public static string GetClassification(SyntaxToken token)
        {
            if (SyntaxFacts.IsKeywordKind(token.CSharpKind()))
            {
                return ClassificationTypeNames.Keyword;
            }
            else if (SyntaxFacts.IsPunctuation(token.CSharpKind()))
            {
                return GetClassificationForPunctuation(token);
            }
            else if (token.CSharpKind() == SyntaxKind.IdentifierToken)
            {
                return GetClassificationForIdentifer(token);
            }
            else if (token.CSharpKind() == SyntaxKind.StringLiteralToken || token.CSharpKind() == SyntaxKind.CharacterLiteralToken)
            {
                return token.IsVerbatimStringLiteral()
                    ? ClassificationTypeNames.VerbatimStringLiteral
                    : ClassificationTypeNames.StringLiteral;
            }
            else if (token.CSharpKind() == SyntaxKind.NumericLiteralToken)
            {
                return ClassificationTypeNames.NumericLiteral;
            }

            return null;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:32,代码来源:ClassificationHelpers.cs

示例2: GetClassificationForToken

        /// <summary>
        /// Determine the classification type for a given token.
        /// </summary>
        /// <param name="classificationTypes">A classification service to retrieve classification types.</param>
        /// <param name="token">The token.</param>
        /// <param name="syntaxTree">The tree containing the token (can be null for tokens that are
        /// unparented).</param>
        /// <returns>The correct syntactic classification for the token.</returns>
        public static IClassificationType GetClassificationForToken(this IClassificationTypes classificationTypes, SyntaxToken token, SyntaxTree syntaxTree)
        {
            if (SyntaxFacts.IsKeywordKind(token.Kind))
            {
                return classificationTypes.Keyword;
            }
            else if (token.Kind.IsPunctuation())
            {
                return GetClassificationForPunctuation(classificationTypes, token);
            }
            else if (token.Kind == SyntaxKind.IdentifierToken)
            {
                return GetClassificationForIdentifer(classificationTypes, token, syntaxTree);
            }
            else if (token.Kind == SyntaxKind.StringLiteralToken || token.Kind == SyntaxKind.CharacterLiteralToken)
            {
                return token.IsVerbatimStringLiteral()
                    ? classificationTypes.VerbatimStringLiteral
                    : classificationTypes.StringLiteral;
            }
            else if (token.Kind == SyntaxKind.NumericLiteralToken)
            {
                return classificationTypes.NumericLiteral;
            }

            return null;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:35,代码来源:ClassificationExtensions.cs

示例3: IsVerbatimStringToken

        private static bool IsVerbatimStringToken(SyntaxToken token)
        {
            if (token.IsVerbatimStringLiteral())
            {
                return true;
            }

            switch (token.Kind())
            {
                case SyntaxKind.InterpolatedVerbatimStringStartToken:
                    return true;
                case SyntaxKind.InterpolatedStringStartToken:
                    return false;

                case SyntaxKind.InterpolatedStringEndToken:
                    {
                        var interpolatedString = token.Parent as InterpolatedStringExpressionSyntax;

                        return interpolatedString != null
                            && interpolatedString.StringStartToken.IsKind(SyntaxKind.InterpolatedVerbatimStringStartToken);
                    }

                case SyntaxKind.InterpolatedStringTextToken:
                    {
                        var interpolatedStringText = token.Parent as InterpolatedStringTextSyntax;
                        if (interpolatedStringText == null)
                        {
                            return false;
                        }

                        var interpolatedString = interpolatedStringText.Parent as InterpolatedStringExpressionSyntax;

                        return interpolatedString != null
                            && interpolatedString.StringStartToken.IsKind(SyntaxKind.InterpolatedVerbatimStringStartToken);
                    }
            }

            return false;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:39,代码来源:ClassificationHelpers.cs

示例4: AtEndOfIncompleteStringOrCharLiteral

        private static bool AtEndOfIncompleteStringOrCharLiteral(SyntaxToken token, int position, char lastChar)
        {
            if (!token.IsKind(SyntaxKind.StringLiteralToken, SyntaxKind.CharacterLiteralToken))
            {
                throw new ArgumentException(CSharpWorkspaceResources.Expected_string_or_char_literal, nameof(token));
            }

            int startLength = 1;
            if (token.IsVerbatimStringLiteral())
            {
                startLength = 2;
            }

            return position == token.Span.End &&
                (token.Span.Length == startLength || (token.Span.Length > startLength && token.ToString().Cast<char>().LastOrDefault() != lastChar));
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:16,代码来源:SyntaxTreeExtensions.cs

示例5: IsVerbatimStringLiteral

 public bool IsVerbatimStringLiteral(SyntaxToken token)
     => token.IsVerbatimStringLiteral();
开发者ID:TyOverby,项目名称:roslyn,代码行数:2,代码来源:CSharpSyntaxFactsService.cs

示例6: AtEndOfIncompleteStringOrCharLiteral

        private static bool AtEndOfIncompleteStringOrCharLiteral(SyntaxToken token, int position, char lastChar)
        {
            if (!IsKind(token, SyntaxKind.StringLiteralToken, SyntaxKind.CharacterLiteralToken))
            {
                throw new ArgumentException("ExpectedStringOrCharLiteral", nameof(token));
            }

            int startLength = 1;
            if (token.IsVerbatimStringLiteral())
            {
                startLength = 2;
            }

            return position == token.Span.End &&
                   (token.Span.Length == startLength ||
                    (token.Span.Length > startLength && token.ToString().LastOrDefault() != lastChar));
        }
开发者ID:mjheitland,项目名称:TableTweaker,代码行数:17,代码来源:ReferenceDirectiveCompletionProvider.cs


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