コード例 #1
0
        private static IEnumerable <CodeUnit> GetCodeUnitFrom <T>(T node, Stack <CodePathPart> currentCodePath, Func <T, CSharpSyntaxNode> getEntryFunction)
            where T : CSharpSyntaxNode
        {
            if (node == null)
            {
                yield break;
            }

            var nodeName = GetNodeName(node);

            currentCodePath.Push(new CodePathPart(node, nodeName));

            var codePath = new CodePath(currentCodePath.Reverse().ToList());
            var entry    = getEntryFunction(node);

            if (entry != null)
            {
                var tokens = entry.GetTokens().ToList();
                yield return(new CodeUnit(codePath, tokens));
            }

            currentCodePath.Pop();
        }
コード例 #2
0
 public CodeUnit(CodePath path, IEnumerable <SyntaxToken> tokens, int firstTokenIndex = 0)
 {
     Path            = path;
     Tokens          = tokens.ToList();
     FirstTokenIndex = firstTokenIndex;
 }