本文整理汇总了C#中ParseTree.NodeAt方法的典型用法代码示例。如果您正苦于以下问题:C# ParseTree.NodeAt方法的具体用法?C# ParseTree.NodeAt怎么用?C# ParseTree.NodeAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseTree
的用法示例。
在下文中一共展示了ParseTree.NodeAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNodeDeclaration
private static SymbolDeclaration GetNodeDeclaration(ParseTree.Node node, string fileName = null)
{
if (node.declaration == null)
{
var declarationSemantics = node.semantics & SemanticFlags.SymbolDeclarationsMask;
var enclosingScopeNode = EnclosingSemanticNode(node.parent, SemanticFlags.ScopesMask);
var enclosingScope = GetNodeScope(enclosingScopeNode, fileName);
if (enclosingScope == null)
return null;
ParseTree.BaseNode modifiersNode = null;
ParseTree.BaseNode partialNode = null;
ParseTree.Node typeParamsNode = null;
switch (declarationSemantics)
{
case SemanticFlags.NamespaceDeclaration:
node.declaration = new NamespaceDeclaration { parseTreeNode = node, kind = SymbolKind.Namespace };
break;
case SemanticFlags.UsingNamespace:
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.ImportedNamespace };
break;
//var namespaceToImport = node.Print();
//(enclosingScope as NamespaceScope).declaration.importedNamespaces[namespaceToImport] = new SymbolReference(node.ChildAt(0));
//return null;
case SemanticFlags.UsingAlias:
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.TypeAlias };
break;
//var name = node.ChildAt(0).Print();
//((NamespaceScope) enclosingScope).declaration.typeAliases[name] = new SymbolReference(node.ChildAt(2));
//return null;
case SemanticFlags.ExternAlias:
break;
case SemanticFlags.ClassDeclaration:
modifiersNode = node.parent.FindChildByName("modifiers");
partialNode = node.parent.FindChildByName("PARTIAL");
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.Class };
typeParamsNode = node.FindChildByName("typeParameterList") as ParseTree.Node;
// Debug.Log(node.declaration + " mods: " + node.declaration.modifiers);
break;
case SemanticFlags.TypeParameterDeclaration:
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.TypeParameter };
break;
case SemanticFlags.BaseListDeclaration:
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.BaseTypesList };
break;
case SemanticFlags.ConstantDeclarator:
modifiersNode = node.parent.parent.parent.FindChildByName("modifiers");
node.declaration = new SymbolDeclaration {
parseTreeNode = node,
kind =
node.parent.parent.RuleName == "constantDeclaration" ?
SymbolKind.ConstantField :
SymbolKind.LocalConstant
};
break;
case SemanticFlags.ConstructorDeclarator:
modifiersNode = node.parent.FindChildByName("modifiers");
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.Constructor };
break;
case SemanticFlags.DestructorDeclarator:
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.Destructor };
break;
case SemanticFlags.OperatorDeclarator:
case SemanticFlags.ConversionOperatorDeclarator:
modifiersNode = node.parent.parent.FindChildByName("modifiers");
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.Operator };
break;
case SemanticFlags.MethodDeclarator:
modifiersNode = node.parent.FindChildByName("modifiers");
typeParamsNode = node.NodeAt(0);
if (typeParamsNode != null)
typeParamsNode = typeParamsNode.NodeAt(0);
if (typeParamsNode != null)
typeParamsNode = typeParamsNode.NodeAt(0);
if (typeParamsNode != null)
typeParamsNode = typeParamsNode.NodeAt(-1);
if (typeParamsNode != null)
typeParamsNode = typeParamsNode.FindChildByName("typeParameterList") as ParseTree.Node;
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.Method };
break;
case SemanticFlags.LocalVariableDeclarator:
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.Variable };
break;
case SemanticFlags.ForEachVariableDeclaration:
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.ForEachVariable };
break;
case SemanticFlags.FromClauseVariableDeclaration:
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.FromClauseVariable };
break;
case SemanticFlags.LabeledStatement:
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.Label };
break;
case SemanticFlags.CatchExceptionParameterDeclaration:
node.declaration = new SymbolDeclaration { parseTreeNode = node, kind = SymbolKind.CatchParameter };
//.........这里部分代码省略.........