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(); }
public CodeUnit(CodePath path, IEnumerable <SyntaxToken> tokens, int firstTokenIndex = 0) { Path = path; Tokens = tokens.ToList(); FirstTokenIndex = firstTokenIndex; }