本文整理汇总了C#中SyntaxListBuilder类的典型用法代码示例。如果您正苦于以下问题:C# SyntaxListBuilder类的具体用法?C# SyntaxListBuilder怎么用?C# SyntaxListBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SyntaxListBuilder类属于命名空间,在下文中一共展示了SyntaxListBuilder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertToTriviaList
public static SyntaxNode ConvertToTriviaList(this SyntaxNode[] nodes)
{
var builder = new SyntaxListBuilder(nodes.Length);
for (int i = 0; i < nodes.Length; i++)
{
var node = nodes[i];
var nd = node.GetDiagnostics();
foreach (var token in node.GetTokens())
{
builder.Add(token.GetLeadingTrivia());
if (token.Width > 0)
{
var tk = token.WithLeadingTrivia(null).WithTrailingTrivia(null);
System.Diagnostics.Debug.Assert(tk.HasDiagnostics == token.HasDiagnostics);
if (nd != null && nd.Length > 0)
{
if (token != node)
{
tk = tk.WithAdditionalDiagnostics(nd);
}
nd = null;
}
builder.Add(Syntax.SkippedTokens(tk));
}
builder.Add(token.GetTrailingTrivia());
}
}
return builder.ToListNode();
}
示例2: LookupToken
/// <summary>
/// Look up a well known SyntaxToken for a given XML element tag or attribute.
/// This is a performance optimization to avoid creating duplicate tokens for the same content.
/// </summary>
/// <param name="text">The text of the tag or attribute.</param>
/// <param name="leading">The leading trivia of the token.</param>
/// <returns>The SyntaxToken representing the well-known tag or attribute or null if it's not well-known.</returns>
public static SyntaxToken LookupToken(string text, SyntaxListBuilder leading)
{
if (leading == null)
{
return LookupXmlElementTag(text);
}
if (IsSingleSpaceTrivia(leading))
{
return LookupXmlAttribute(text);
}
return null;
}
示例3: IsSingleSpaceTrivia
private static bool IsSingleSpaceTrivia(SyntaxListBuilder syntax)
{
return syntax.Count == 1 && SyntaxFactory.Space.IsEquivalentTo(syntax[0]);
}
示例4: CollectConstituentTokensAndDiagnostics
/* <summary>
''' Add all the tokens in this node and children to the build token list builder. While doing this, add any
''' diagnostics not on tokens to the given diagnostic info list.
''' </summary>
*/
internal virtual void CollectConstituentTokensAndDiagnostics(SyntaxListBuilder<SyntaxToken> tokenListBuilder, IList<DiagnosticInfo> nonTokenDiagnostics)
{
DiagnosticInfo[] diagnostics = this.GetDiagnostics();
if (diagnostics != null && diagnostics.Length > 0)
{
foreach (var diag in diagnostics)
{
nonTokenDiagnostics.Add(diag);
}
}
// Recurse to subtrees.
for (var i = 0; i < SlotCount; i++)
{
var green = GetSlot(i);
if (green != null)
{
((SyntaxNode)green).CollectConstituentTokensAndDiagnostics(tokenListBuilder, nonTokenDiagnostics);
}
}
}
示例5: List
internal static CSharpSyntaxNode List(SyntaxListBuilder builder)
{
if (builder != null)
{
return builder.ToListNode();
}
return null;
}
示例6: ParseEndOfDirective
private SyntaxToken ParseEndOfDirective(bool ignoreErrors, bool afterPragma = false, bool afterLineNumber = false, bool afterReference = false)
{
var skippedTokens = new SyntaxListBuilder<SyntaxToken>();
// Consume all extranous tokens as leading SkippedTokens trivia.
if (this.CurrentToken.Kind != SyntaxKind.EndOfDirectiveToken &&
this.CurrentToken.Kind != SyntaxKind.EndOfFileToken)
{
skippedTokens = new SyntaxListBuilder<SyntaxToken>(10);
if (!ignoreErrors)
{
ErrorCode errorCode = ErrorCode.ERR_EndOfPPLineExpected;
if (afterPragma)
{
errorCode = ErrorCode.WRN_EndOfPPLineExpected;
}
else if (afterLineNumber)
{
errorCode = ErrorCode.ERR_MissingPPFile;
}
else if (afterReference)
{
errorCode = ErrorCode.ERR_ExpectedPPFile;
}
skippedTokens.Add(this.AddError(this.EatToken().WithoutDiagnosticsGreen(), errorCode));
}
while (this.CurrentToken.Kind != SyntaxKind.EndOfDirectiveToken &&
this.CurrentToken.Kind != SyntaxKind.EndOfFileToken)
{
skippedTokens.Add(this.EatToken().WithoutDiagnosticsGreen());
}
}
// attach text from extraneous tokens as trivia to EndOfDirective token
SyntaxToken endOfDirective = this.CurrentToken.Kind == SyntaxKind.EndOfDirectiveToken
? this.EatToken()
: SyntaxFactory.Token(SyntaxKind.EndOfDirectiveToken);
if (!skippedTokens.IsNull)
{
endOfDirective = endOfDirective.WithLeadingTrivia(SyntaxFactory.SkippedTokensTrivia(skippedTokens.ToList()));
}
return endOfDirective;
}
示例7: XmlContext
public XmlContext(SyntaxListPool pool, XmlElementStartTagSyntax start)
{
_pool = pool;
_start = start;
_content = _pool.Allocate<XmlNodeSyntax>();
}