Esempio n. 1
0
            private static TagSpan GetOutlineSpan(ITextSnapshot snapshot, IOutlinableResult outlineResult)
            {
                TagSpan tagSpan = null;

                try
                {
                    int length = outlineResult.EndIndex - outlineResult.StartIndex;
                    if (length > 0)
                    {
                        var headerLength = outlineResult.DecoratorEnd - outlineResult.DecoratorStart;
                        ITextSnapshotLine startLine;
                        if ((startLine = snapshot.GetLineFromPosition(outlineResult.DecoratorStart)).LineNumber !=
                            snapshot.GetLineNumberFromPosition(outlineResult.DecoratorEnd))
                        {
                            // the decorator range spans multiple lines, so we want to truncate that
                            headerLength = startLine.End.Position - outlineResult.DecoratorStart;
                        }

                        Span headerSpan = new Span(outlineResult.DecoratorStart, headerLength);
                        var  span       = GetFinalSpan(snapshot, outlineResult.StartIndex, length);

                        tagSpan = new TagSpan(
                            new SnapshotSpan(snapshot, span),
                            new OutliningTag(snapshot, headerSpan, span, true)
                            );
                    }
                }
                catch (ArgumentException)
                {
                    // sometimes Python's parser gives us bad spans, ignore those and fix the parser
                    Debug.Assert(false, "bad argument when making span/tag");
                }

                return(tagSpan);
            }
Esempio n. 2
0
 private static bool ShouldInclude(IOutlinableResult result, NormalizedSnapshotSpanCollection spans)
 {
     for (int i = 0; i < spans.Count; i++)
     {
         if (spans[i].IntersectsWith(Span.FromBounds(result.StartIndex, result.EndIndex)))
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 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;
 }
Esempio n. 4
0
        private static BlockType GetBlockType(IOutlinableResult outlinable)
        {
            BlockType blockType = BlockType.Unknown;
            var       type      = outlinable.GetType();

            if (!_statementToBlockMap.TryGetValue(type, out blockType))
            {
                if (outlinable is IFunctionResult)
                {
                    blockType = BlockType.Method;
                }
            }
            return(blockType);
        }
Esempio n. 5
0
            private SnapshotSpan?ShouldInclude(IOutlinableResult result, NormalizedSnapshotSpanCollection spans)
            {
                if (spans.Count == 1 && spans[0].Length == spans[0].Snapshot.Length)
                {
                    // we're processing the entire snapshot
                    return(spans[0]);
                }

                for (int i = 0; i < spans.Count; i++)
                {
                    if (spans[i].IntersectsWith(Span.FromBounds(result.StartIndex, result.EndIndex)))
                    {
                        return(spans[i]);
                    }
                }
                return(null);
            }