Ejemplo n.º 1
0
        public void OutliningTagger_ThreeMeasures()
        {
            var iTextBufferFactoryService = GetTextBufferFactoryService();
            var text = iTextBufferFactoryService.CreateTextBuffer(@"CREATE MEASURE T[M1] = 1;

CREATE MEASURE T[m3] = 
 (3 + 9) / 12

;

CREATE MEASURE T[M2] = 2
;

", iTextBufferFactoryService.TextContentType);

            Assert.IsNotNull(text);
            var outliningTagger = new OutliningTagger(text);
            var spans           = new NormalizedSnapshotSpanCollection(text.CurrentSnapshot, GetTextSnapshotSpan(text.CurrentSnapshot));
            var tags            = outliningTagger.GetTags(spans);

            Assert.AreEqual(3, tags.Count());

            var tag1 = tags.First();

            Assert.AreEqual(0, tag1.Span.Start.Position);
            Assert.AreEqual(25, tag1.Span.End.Position);
            var tag2 = tags.Skip(1).First();

            Assert.AreEqual(29, tag2.Span.Start.Position);
            Assert.AreEqual(72, tag2.Span.End.Position);
            var tag3 = tags.Skip(2).First();

            Assert.AreEqual(76, tag3.Span.Start.Position);
            Assert.AreEqual(103, tag3.Span.End.Position);
        }
Ejemplo n.º 2
0
 private OutliningManager(ITextBuffer buffer)
 {
     this.regions         = new BufferOutlines();
     this.outliningTagger = new OutliningTagger(this);
     this.glyphTagger     = new GlyphTagger(this);
     LoadRegions(buffer);
 }
Ejemplo n.º 3
0
        public void OutliningTagger_TwoMeasures()
        {
            var iTextBufferFactoryService = GetTextBufferFactoryService();
            var OneLineQuery = iTextBufferFactoryService.CreateTextBuffer(@"CREATE MEASURE T[M1] = 1
CREATE MEASURE 'T T'[M2] = 2", iTextBufferFactoryService.TextContentType);

            Assert.IsNotNull(OneLineQuery);
            var outliningTagger = new OutliningTagger(OneLineQuery);
            var spans           = new NormalizedSnapshotSpanCollection(OneLineQuery.CurrentSnapshot, GetTextSnapshotSpan(OneLineQuery.CurrentSnapshot));
            var tags            = outliningTagger.GetTags(spans);

            Assert.AreEqual(2, tags.Count());
            var tag1 = tags.First();

            Assert.AreEqual(0, tag1.Span.Start.Position);
            Assert.AreEqual(24, tag1.Span.End.Position);
            Assert.AreEqual("T[M1]", tag1.Tag.CollapsedForm as string);
            Assert.AreEqual("CREATE MEASURE T[M1] = 1", tag1.Tag.CollapsedHintForm as string);
            var tag2 = tags.Last();

            Assert.AreEqual(26, tag2.Span.Start.Position);
            Assert.AreEqual(54, tag2.Span.End.Position);
            Assert.AreEqual("'T T'[M2]", tag2.Tag.CollapsedForm as string);
            Assert.AreEqual("CREATE MEASURE 'T T'[M2] = 2", tag2.Tag.CollapsedHintForm as string);
        }
Ejemplo n.º 4
0
        public void OutliningTagger_OneLineQuery()
        {
            var iTextBufferFactoryService = GetTextBufferFactoryService();
            var OneLineQuery = iTextBufferFactoryService.CreateTextBuffer(@"EVALUATE T", iTextBufferFactoryService.TextContentType);

            Assert.IsNotNull(OneLineQuery);
            var outliningTagger = new OutliningTagger(OneLineQuery);
            var spans           = new NormalizedSnapshotSpanCollection(OneLineQuery.CurrentSnapshot, GetTextSnapshotSpan(OneLineQuery.CurrentSnapshot));
            var tags            = outliningTagger.GetTags(spans);

            Assert.AreEqual(1, tags.Count());
        }
Ejemplo n.º 5
0
        public void OutliningTagger_RandomText()
        {
            var iTextBufferFactoryService = GetTextBufferFactoryService();
            var textBuffer = iTextBufferFactoryService.CreateTextBuffer(@"asd", iTextBufferFactoryService.TextContentType);

            Assert.IsNotNull(textBuffer);
            var outliningTagger = new OutliningTagger(textBuffer);
            var spans           = new NormalizedSnapshotSpanCollection(textBuffer.CurrentSnapshot, GetTextSnapshotSpan(textBuffer.CurrentSnapshot));
            var tags            = outliningTagger.GetTags(spans);

            Assert.AreEqual(0, tags.Count());
        }
Ejemplo n.º 6
0
        public void OutliningTagger_EmptyBuffer()
        {
            var iTextBufferFactoryService = GetTextBufferFactoryService();
            var emptyTextBuffer           = iTextBufferFactoryService.CreateTextBuffer();

            Assert.IsNotNull(emptyTextBuffer);
            var outliningTagger = new OutliningTagger(emptyTextBuffer);
            var spans           = new NormalizedSnapshotSpanCollection(emptyTextBuffer.CurrentSnapshot, GetTextSnapshotSpan(emptyTextBuffer.CurrentSnapshot));
            var tags            = outliningTagger.GetTags(spans);

            Assert.AreEqual(0, tags.Count());
        }
Ejemplo n.º 7
0
        internal BraceMatchingTagger(ITextView view, ITextBuffer sourceBuffer)
        {
            this.View         = view;
            this.SourceBuffer = sourceBuffer;
            this.CurrentChar  = null;

            // Share the RegionParser
            this.outliningTagger = OutliningTaggerProvider.GetOrCreateOutliningTagger(sourceBuffer);

            this.View.Caret.PositionChanged += CaretPositionChanged;
            this.View.LayoutChanged         += ViewLayoutChanged;
        }
Ejemplo n.º 8
0
        public ITagger <T> CreateTagger <T>(ITextBuffer buffer)
            where T : ITag
        {
            OutliningTagger tagger;

            if (buffer.Properties.TryGetProperty(TextBufferProperties.OutliningTagger, out tagger))
            {
                return((ITagger <T>)tagger);
            }

            //var nitraSolutionService = XXNamespaceXX.ReSharperSolution.XXLanguageXXSolution;
            tagger = new OutliningTagger(buffer, null);
            buffer.Properties.AddProperty(TextBufferProperties.OutliningTagger, tagger);
            return((ITagger <T>)tagger);
        }
Ejemplo n.º 9
0
            private void AddTagIfNecessary(int startIndex, int endIndex, int headerIndex = -1, DecoratorStatement decorator = null, int minLinesToCollapse = 3)
            {
                var startLine = _snapshot.GetLineFromPosition(startIndex).LineNumber;
                var endLine   = _snapshot.GetLineFromPosition(endIndex).LineNumber;
                var lines     = endLine - startLine + 1;

                // Collapse if more than 3 lines.
                if (lines >= minLinesToCollapse)
                {
                    TagSpan tagSpan = OutliningTagger.GetTagSpan(
                        _snapshot,
                        startIndex,
                        endIndex,
                        headerIndex,
                        decorator);
                    TagSpans.Add(tagSpan);
                }
            }
Ejemplo n.º 10
0
 protected BaseOutliningManager(ITextBuffer buffer)
 {
     this.Regions         = new BufferOutlines();
     this.outliningTagger = new OutliningTagger(this);
     this.glyphTagger     = new GlyphTagger(this);
 }