本文整理汇总了C#中SyntaxNode.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxNode.GetType方法的具体用法?C# SyntaxNode.GetType怎么用?C# SyntaxNode.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxNode
的用法示例。
在下文中一共展示了SyntaxNode.GetType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBlockSpans
private void GetBlockSpans(SyntaxNode node)
{
if (_nodeProviderMap.TryGetValue(node.GetType(), out var providers))
{
foreach (var provider in providers)
{
_cancellationToken.ThrowIfCancellationRequested();
provider.CollectBlockSpans(_document, node, _spans, _cancellationToken);
}
}
}
示例2: GetOutliningSpans
private void GetOutliningSpans(SyntaxNode node)
{
ImmutableArray<AbstractSyntaxNodeOutliner> outliners;
if (_nodeOutlinerMap.TryGetValue(node.GetType(), out outliners))
{
foreach (var outliner in outliners)
{
_cancellationToken.ThrowIfCancellationRequested();
outliner.CollectOutliningSpans(_document.Document, node, _regions, _cancellationToken);
}
}
}
示例3: GetBlockSpans
private void GetBlockSpans(SyntaxNode node)
{
ImmutableArray<AbstractSyntaxStructureProvider> providers;
if (_nodeProviderMap.TryGetValue(node.GetType(), out providers))
{
foreach (var provider in providers)
{
_cancellationToken.ThrowIfCancellationRequested();
provider.CollectBlockSpans(_document, node, _spans, _cancellationToken);
}
}
}
示例4: Visit
public override void Visit(SyntaxNode node)
{
int padding = node.Ancestors().Count();
//To identify leaf nodes vs nodes with children
string prepend = node.ChildNodes().Any() ? "[-]"
: "[.]";
//Get the type of the node
string line = new String(' ', padding) + prepend
+ " " + node.GetType().ToString();
//Write the line
System.Console.WriteLine(line);
base.Visit(node);
}
示例5: IsEnlargersNesting
private static bool IsEnlargersNesting(SyntaxNode statementSyntax)
{
return TypesIncreaseNesting.Any(type => statementSyntax.GetType() == type);
}
示例6: Visit
// Visits all SyntaxNodes.
public override void Visit(SyntaxNode node)
{
// If you need to visit all SyntaxNodes of a particular base type that can never
// appear directly in a syntax tree then this would be the place to check for that.
// For example, TypeDeclarationSyntax is a base type for all the type declarations (like
// ClassDeclarationSyntax and StructDeclarationSyntax) that can appear in a syntax tree.
if (node is TypeDeclarationSyntax)
{
Results.AppendLine();
Results.Append("Visiting ");
Results.Append(node.GetType().Name);
Results.Append(" (Kind = ");
Results.Append(node.Kind.ToString());
Results.Append(")");
}
base.Visit(node);
}
示例7: ThrowUnableToGenerateException
private static void ThrowUnableToGenerateException(string generationStage, SyntaxNode node)
{
string message = string.Format(
"Unable to generate node type {0} as {1}.",
node.GetType().Name,
generationStage);
throw new CodeGenerationException(message, node.Line, node.Column);
}
示例8: LogSyntaxTree
private void LogSyntaxTree(SyntaxNode node, StringBuilder builder, int ident = 0, bool skipSelf = false)
{
string sident = String.Empty;
for (int i = 0; i < ident; ++i)
sident += "\t";
if (!skipSelf)
{
builder.AppendLine (sident + node.GetType() + ": " + node);
ident++;
}
foreach (SyntaxNode childNode in node.ChildNodes())
LogSyntaxTree (childNode, builder, ident);
}