本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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));
}
示例5: IsVerbatimStringLiteral
public bool IsVerbatimStringLiteral(SyntaxToken token)
=> token.IsVerbatimStringLiteral();
示例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));
}