本文整理汇总了C#中SyntaxToken.GetTrailingTrivia方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxToken.GetTrailingTrivia方法的具体用法?C# SyntaxToken.GetTrailingTrivia怎么用?C# SyntaxToken.GetTrailingTrivia使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxToken
的用法示例。
在下文中一共展示了SyntaxToken.GetTrailingTrivia方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddToken
// Process a token. and add to the list of triva/tokens we're accumulating.
public void AddToken(SyntaxToken token, bool isFirst, bool isLast)
{
bool isMissing = token.IsMissing;
if (token.HasLeadingTrivia && (isFirst || isMissing || token.GetLeadingTrivia().TriviaListContainsStructuredTrivia()))
{
FinishInProgressTokens();
AddTrivia(token.GetLeadingTrivia());
token = ((SyntaxToken)token.WithLeadingTrivia(null));
}
////if (!preserveExistingDiagnostics)
////{
//// token = token.WithoutDiagnostics();
////}
SyntaxNode trailingTrivia = null;
if (token.HasTrailingTrivia && (isLast || isMissing || token.GetTrailingTrivia().TriviaListContainsStructuredTrivia()))
{
trailingTrivia = token.GetTrailingTrivia();
token = ((SyntaxToken)token.WithTrailingTrivia(null));
}
if (isMissing)
{
// Don't add missing tokens to skipped tokens, but preserve their diagnostics.
////if (token.ContainsDiagnostics())
////{
//// // Move diagnostics on missing token to next token.
//// if (diagnosticsToAdd != null)
//// {
//// diagnosticsToAdd = diagnosticsToAdd.Concat(token.GetDiagnostics());
//// }
//// else
//// {
//// diagnosticsToAdd = token.GetDiagnostics();
//// }
//// addDiagnosticsToFirstTokenOnly = true;
////}
}
else
{
skippedTokensBuilder.Add(token);
}
if (trailingTrivia != null)
{
FinishInProgressTokens();
AddTrivia(trailingTrivia);
}
if (isFirst && addDiagnosticsToFirstTokenOnly)
{
FinishInProgressTokens(); // implicitly adds the diagnostics.
}
}
示例2: TruncateIdentifier
// Ignore everything after the 128th character by setting the value text of the token
// from the prefix. This is for backwards compatibility with Dev 10.
private static SyntaxToken TruncateIdentifier(SyntaxToken identifier)
{
if (identifier.Width > MAX_DIRECTIVE_IDENTIFIER_WIDTH)
{
var leading = identifier.GetLeadingTrivia();
var trailing = identifier.GetTrailingTrivia();
string text = identifier.ToString();
string identifierPart = text.Substring(0, MAX_DIRECTIVE_IDENTIFIER_WIDTH);
identifier = SyntaxFactory.Identifier(SyntaxKind.IdentifierToken, leading, text, identifierPart, trailing);
}
return identifier;
}
示例3: PushToken
private void PushToken(SyntaxToken token)
{
var trailing = token.GetTrailingTrivia();
if (trailing != null)
{
this.Push(trailing);
}
this.Push(token);
var leading = token.GetLeadingTrivia();
if (leading != null)
{
this.Push(leading);
}
}