示例#1
0
        public FrameworkElement Context(BlockColoring coloring, TextRunProperties properties)
        {
            Genero4glCodeBlock         item  = this;
            Stack <Genero4glCodeBlock> stack = new Stack <Genero4glCodeBlock>();

            do
            {
                if (item.type == BlockType.Root)
                {
                    break;
                }
                if (item.type != BlockType.Unknown)
                {
                    stack.Push(item);
                }
                item = item.parent;
            }while (item.type != BlockType.Namespace);
            int           repeatCount = 0;
            StringBuilder builder     = new StringBuilder();

            while (stack.Count != 0)
            {
                item = stack.Pop();
                builder.Append(item.Statement(repeatCount));

                repeatCount += 2;
                if (stack.Count != 0)
                {
                    builder.Append('\r');
                    builder.Append(' ', repeatCount);
                }
            }
            return(new TextBlob(FormatStatements(builder.ToString(), coloring, properties)));
        }
示例#2
0
        private static void GetOutlinableResults(Genero4glBlockTagger tagger, ITextView textView, NormalizedSnapshotSpanCollection spans, AstNode node, Genero4glCodeBlock parent, ITextSnapshot snapshot, int level, ref List <Genero4glCodeBlock> outlinables)
        {
            Genero4glCodeBlock curr = null;

            foreach (var child in node.Children)
            {
                if (child.Value != null)
                {
                    var outRes = child.Value as IOutlinableResult;
                    if (outRes.CanOutline && /*&& ShouldInclude(outRes, spans)*/
                        outRes.EndIndex < textView.TextSnapshot.Length)
                    {
                        curr = new Genero4glCodeBlock(tagger, textView, parent, GetBlockType(outRes), outRes,
                                                      level + 1);
                        if (curr != null)
                        {
                            outlinables.Add(curr);
                        }
                    }

                    if (child.Value.Children.Count > 0)
                    {
                        if (curr == null)
                        {
                            curr = new Genero4glCodeBlock(tagger, textView, parent, BlockType.Unknown, null, level + 1);
                        }

                        GetOutlinableResults(tagger, textView, spans, child.Value, curr, snapshot, level + 1,
                                             ref outlinables);
                    }
                }
            }
        }
示例#3
0
 // Methods
 public Genero4glCodeBlock(Genero4glBlockTagger tagger, ITextView textView, Genero4glCodeBlock parent, BlockType type, IOutlinableResult outlinable, int level)
 {
     _tagger     = tagger;
     _textView   = textView;
     this.parent = parent;
     if (parent != null)
     {
         parent.children.Add(this);
     }
     this.type   = type;
     this.level  = level;
     _outlinable = outlinable;
 }
示例#4
0
        private IEnumerable <ITagSpan <IBlockTag> > ProcessSuite(NormalizedSnapshotSpanCollection spans, GeneroAst ast, ModuleNode moduleNode, ITextSnapshot snapshot, bool isTopLevel)
        {
            if (moduleNode != null)
            {
                List <Genero4glCodeBlock> outlinables = new List <Genero4glCodeBlock>();
                int level = 0;
                Genero4glCodeBlock block = new Genero4glCodeBlock(this, _textview, null, BlockType.Root, null, level);
                GetOutlinableResults(this, _textview, spans, moduleNode, block, snapshot, level, ref outlinables);

                foreach (var child in outlinables)
                {
                    TagSpan <Genero4glCodeBlock> tagSpan = new TagSpan <Genero4glCodeBlock>(child.Span, child);
                    if (tagSpan != null)
                    {
                        yield return(tagSpan);
                    }
                }
            }
        }