Exemplo n.º 1
0
        private List <CodeUnit> ExtractNonCSharp(string program, Language language)
        {
            var tokens = tokensExtractor.GetFilteredTokensFromPygmentize(program, language);

            RenameTokenTypes(tokens);
            var codePath = new CodePath(Enumerable.Empty <CodePathPart>());
            var codeUnit = new CodeUnit(codePath, tokens);

            return(new List <CodeUnit> {
                codeUnit
            });
        }
Exemplo n.º 2
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.Select(t => new CSharpToken(t))));
            }

            currentCodePath.Pop();
        }
Exemplo n.º 3
0
 public CodeUnit(CodePath path, IEnumerable <IToken> tokens, int firstTokenIndex = 0)
 {
     Path            = path;
     Tokens          = tokens.ToList();
     FirstTokenIndex = firstTokenIndex;
 }