本文整理汇总了C#中SyntaxListBuilder.?.ToListNode方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxListBuilder.?.ToListNode方法的具体用法?C# SyntaxListBuilder.?.ToListNode怎么用?C# SyntaxListBuilder.?.ToListNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxListBuilder
的用法示例。
在下文中一共展示了SyntaxListBuilder.?.ToListNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
private SyntaxToken Create(ref TokenInfo info, SyntaxListBuilder leading, SyntaxListBuilder trailing, SyntaxDiagnosticInfo[] errors)
{
Debug.Assert(info.Kind != SyntaxKind.IdentifierToken || info.StringValue != null);
var leadingNode = leading?.ToListNode();
var trailingNode = trailing?.ToListNode();
SyntaxToken token;
if (info.RequiresTextForXmlEntity)
{
token = SyntaxFactory.Token(leadingNode, info.Kind, info.Text, info.StringValue, trailingNode);
}
else
{
switch (info.Kind)
{
case SyntaxKind.IdentifierToken:
token = SyntaxFactory.Identifier(info.ContextualKind, leadingNode, info.Text, info.StringValue, trailingNode);
break;
case SyntaxKind.NumericLiteralToken:
switch (info.ValueKind)
{
case SpecialType.System_Int32:
token = SyntaxFactory.Literal(leadingNode, info.Text, info.IntValue, trailingNode);
break;
case SpecialType.System_UInt32:
token = SyntaxFactory.Literal(leadingNode, info.Text, info.UintValue, trailingNode);
break;
case SpecialType.System_Int64:
token = SyntaxFactory.Literal(leadingNode, info.Text, info.LongValue, trailingNode);
break;
case SpecialType.System_UInt64:
token = SyntaxFactory.Literal(leadingNode, info.Text, info.UlongValue, trailingNode);
break;
case SpecialType.System_Single:
token = SyntaxFactory.Literal(leadingNode, info.Text, info.FloatValue, trailingNode);
break;
case SpecialType.System_Double:
token = SyntaxFactory.Literal(leadingNode, info.Text, info.DoubleValue, trailingNode);
break;
case SpecialType.System_Decimal:
token = SyntaxFactory.Literal(leadingNode, info.Text, info.DecimalValue, trailingNode);
break;
default:
throw ExceptionUtilities.UnexpectedValue(info.ValueKind);
}
break;
case SyntaxKind.InterpolatedStringToken:
// we do not record a separate "value" for an interpolated string token, as it must be rescanned during parsing.
token = SyntaxFactory.Literal(leadingNode, info.Text, info.Kind, info.Text, trailingNode);
break;
case SyntaxKind.StringLiteralToken:
token = SyntaxFactory.Literal(leadingNode, info.Text, info.Kind, info.StringValue, trailingNode);
break;
case SyntaxKind.CharacterLiteralToken:
token = SyntaxFactory.Literal(leadingNode, info.Text, info.CharValue, trailingNode);
break;
case SyntaxKind.XmlTextLiteralNewLineToken:
token = SyntaxFactory.XmlTextNewLine(leadingNode, info.Text, info.StringValue, trailingNode);
break;
case SyntaxKind.XmlTextLiteralToken:
token = SyntaxFactory.XmlTextLiteral(leadingNode, info.Text, info.StringValue, trailingNode);
break;
case SyntaxKind.XmlEntityLiteralToken:
token = SyntaxFactory.XmlEntity(leadingNode, info.Text, info.StringValue, trailingNode);
break;
case SyntaxKind.EndOfDocumentationCommentToken:
case SyntaxKind.EndOfFileToken:
token = SyntaxFactory.Token(leadingNode, info.Kind, trailingNode);
break;
case SyntaxKind.None:
token = SyntaxFactory.BadToken(leadingNode, info.Text, trailingNode);
break;
default:
Debug.Assert(SyntaxFacts.IsPunctuationOrKeyword(info.Kind));
token = SyntaxFactory.Token(leadingNode, info.Kind, trailingNode);
break;
}
}
if (errors != null && (_options.DocumentationMode >= DocumentationMode.Diagnose || !InDocumentationComment))
{
token = token.WithDiagnosticsGreen(errors);
}
return token;
}