private void HandleBackgroundParseComplete(object sender, ParseResultEventArgs e)
        {
            PhpOutliningParseResultEventArgs antlrParseResultArgs = e as PhpOutliningParseResultEventArgs;

            if (antlrParseResultArgs == null)
            {
                return;
            }

            UpdateTags(antlrParseResultArgs);
        }
        private void UpdateTags(PhpOutliningParseResultEventArgs antlrParseResultArgs)
        {
            List <ITagSpan <IOutliningRegionTag> > outliningRegions = new List <ITagSpan <IOutliningRegionTag> >();

            if (antlrParseResultArgs != null)
            {
                ITextSnapshot snapshot = antlrParseResultArgs.Snapshot;

                foreach (ParserRuleContext child in antlrParseResultArgs.OutliningTrees)
                {
                    Interval sourceInterval = child.SourceInterval;
                    if (sourceInterval.a < 0 || sourceInterval.b < 0 || sourceInterval.Length <= 0)
                    {
                        continue;
                    }

                    var startToken = antlrParseResultArgs.Tokens[sourceInterval.a];
                    var stopToken  = antlrParseResultArgs.Tokens[sourceInterval.b];
                    PhpParser.CodeContext codeContext = child as PhpParser.CodeContext;
                    if (codeContext != null && codeContext.Eof() != null)
                    {
                        stopToken = antlrParseResultArgs.Tokens.Last();
                    }

                    Span span = new Span(startToken.StartIndex, stopToken.StopIndex - startToken.StartIndex + 1);
                    if (snapshot.GetLineNumberFromPosition(span.Start) == snapshot.GetLineNumberFromPosition(span.End))
                    {
                        continue;
                    }

                    if (codeContext != null)
                    {
                        int start = span.Start;
                        int end   = span.End;
                        if (codeContext.HTML_START_CODE() != null)
                        {
                            start = codeContext.HTML_START_CODE().Symbol.StopIndex + 1;
                        }

                        if (codeContext.CLOSE_PHP_TAG() != null)
                        {
                            end = codeContext.CLOSE_PHP_TAG().Symbol.StartIndex;
                        }

                        span = Span.FromBounds(start, end);
                    }

                    SnapshotSpan                  snapshotSpan = new SnapshotSpan(antlrParseResultArgs.Snapshot, span);
                    IOutliningRegionTag           tag          = new OutliningRegionTag("...", string.Empty);
                    TagSpan <IOutliningRegionTag> tagSpan      = new TagSpan <IOutliningRegionTag>(snapshotSpan, tag);
                    outliningRegions.Add(tagSpan);
                }

                //IAstRuleReturnScope resultArgs = antlrParseResultArgs.Result as IAstRuleReturnScope;
                //var result = resultArgs.Tree as CommonTree;
                //if (result != null)
                //{
                //    ITextSnapshot snapshot = antlrParseResultArgs.Snapshot;

                //    foreach (CommonTree child in result.Children)
                //    {
                //        if (child.Type == CharStreamConstants.EndOfFile)
                //            continue;

                //        var startToken = antlrParseResultArgs.Tokens[child.TokenStartIndex];
                //        var stopToken = antlrParseResultArgs.Tokens[child.TokenStopIndex];
                //        Span span = new Span(startToken.StartIndex, stopToken.StopIndex - startToken.StartIndex + 1);
                //        if (snapshot.GetLineNumberFromPosition(span.Start) == snapshot.GetLineNumberFromPosition(span.End))
                //            continue;

                //        SnapshotSpan snapshotSpan = new SnapshotSpan(antlrParseResultArgs.Snapshot, span);
                //        IOutliningRegionTag tag = new OutliningRegionTag("...", string.Empty);
                //        TagSpan<IOutliningRegionTag> tagSpan = new TagSpan<IOutliningRegionTag>(snapshotSpan, tag);
                //        outliningRegions.Add(tagSpan);
                //    }
                //}
            }

            this._outliningRegions = outliningRegions;
            OnTagsChanged(new SnapshotSpanEventArgs(new SnapshotSpan(antlrParseResultArgs.Snapshot, new Span(0, antlrParseResultArgs.Snapshot.Length))));
        }