Ejemplo n.º 1
0
        public void deployDeclaration(syntaxDeclaration syntax)
        {
            foreach (syntaxBlockLineDeclaration ln in declaration.lines)
            {
                switch (ln.render)
                {
                case syntaxBlockLineType.block:
                    syntaxBlockDeclaration bls = syntax.blocks.find(ln.name);
                    codeBlock cb = new codeBlock(ln.name, bls);
                    children.Add(cb);
                    cb.deployDeclaration(syntax);
                    break;

                case syntaxBlockLineType.comment:
                case syntaxBlockLineType.custom:
                case syntaxBlockLineType.normal:
                    codeLine cl = new codeLine(ln.name, ln);
                    children.Add(cl);
                    cl.deployDeclaration(syntax);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public void buildFrom(ICodeElement input)
        {
            codeBlock cb  = null;
            codeBlock cbi = null;
            syntaxBlockDeclaration sb;

            //foreach (syntaxRenderUnit ru in declaration.structure)
            //{
            //    sb = declaration.blocks.Find(x => x.name == ru.elementName);
            //    cb = new codeBlock(sb.name, sb);
            //    children.Add(cb);
            //    if (ru.mode == syntaxBlockRenderMode.inner)
            //    {
            //        flatBlocks.Add(cb);
            //    }
            //    cb.deployDeclaration(declaration);

            //    cbi = input.children.findElement(sb.name) as codeBlock;

            //    cb.buildFrom(cbi);

            //}

            foreach (var ie in input.children.items)
            {
                sb = declaration.blocks.find(ie.name);
                if (sb != null)
                {
                    cb = new codeBlock(ie.name, sb);
                    children.Add(cb);
                    if (sb.render == syntaxBlockRenderMode.inner)
                    {
                        flatBlocks.Add(cb);
                    }
                    cb.deployDeclaration(declaration);

                    //cbi = input[input.children.findElement(sb.name) as codeBlock;

                    cb.buildFrom(ie as codeBlock);
                }
                //cb = children.findElement(ie.name) as codeBlock;
                //if (cb == null)
                //{
                //    sb = declaration.blocks.find(ie.name);
                //    cb = new codeBlock(ie.name, sb);
                //    children.Add(cb);
                //    cb.deployDeclaration(input.declarationBase as syntaxDeclaration);
                //}
                //cb.buildFrom(ie);
            }

            //foreach (syntaxRenderUnit ru in declaration.structure)
            //{
            //    cb = input[ru.elementName]
            //    if (cb != null)
            //    {
            //        foreach (var cl in declaration.blocks.find(ru.elementName).lines)
            //        {
            //        }
            //    }
            //    sb = declaration.blocks.Find(x => x.name == ru.elementName);
            //    new codeBlock(sb.name, sb);
            //    children.Add(cb);
            //    if (ru.mode == syntaxBlockRenderMode.inner)
            //    {
            //        flatBlocks.Add(cb);
            //    }
            //    cb.deployDeclaration(declaration);
            //}

            //foreach (codeBlock sl in declaration.structure
            //{
            //    //output = output + sl.render(syntax).Trim(Environment.NewLine.ToCharArray()) + Environment.NewLine;
            //}
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Building DOM from source code string
        /// </summary>
        /// <param name="__source">Source code string</param>
        public void build(String __source)
        {
            codeBlock cb = null;
            syntaxBlockDeclaration sb;

            foreach (syntaxRenderUnit ru in declaration.structure)
            {
                sb = declaration.blocks.Find(x => x.name == ru.elementName);
                cb = new codeBlock(sb.name, sb);
                children.Add(cb);
                if (ru.mode == syntaxBlockRenderMode.inner)
                {
                    flatBlocks.Add(cb);
                }
                cb.deployDeclaration(declaration);
            }

            codeSourceElementCollection elements = new codeSourceElementCollection(__source, declaration);

            foreach (codeSourceElement el in elements.codeElements)
            {
                cb = null;
                sb = null;
                if (el.lineClass != null)
                {
                    switch (el.lineClass.lineType)
                    {
                    case syntaxBlockLineType.normal:
                        cb = flatBlocks.Find(x => x.children.hasElement(el.name));
                        codeLine cl = null;
                        if (cb != null)
                        {
                            cl = cb.children.getElement <codeLine>(el.name);
                            cl.deployCode(el);
                        }
                        else
                        {
                            unresolvedElements.Add(el);
                        }

                        break;

                    case syntaxBlockLineType.block:

                        sb = declaration.blocks.find(el.name);
                        if (sb != null)
                        {
                            if (sb.role == syntaxBlockRole.permanent)
                            {
                                cb = children.getElement <codeBlock>(el.name);
                            }
                        }

                        //declaration.blocks.

                        //el.lineClass.

                        //
                        if (cb == null)
                        {
                            // sb = declaration.blocks.find(el.name);
                            if (sb != null)
                            {
                                cb = new codeBlock(el.name, sb);
                                children.Add(cb);
                                cb.deployDeclaration(declaration);
                            }
                            else
                            {
                                unresolvedElements.Add(el);
                            }
                        }

                        if (cb != null)
                        {
                            cb.deployCode(el, declaration);
                        }

                        break;

                    case syntaxBlockLineType.emptyLine:
                        break;

                    default:
                        break;
                    }
                }
            }
        }