• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NormalizedSnapshotSpanCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中NormalizedSnapshotSpanCollection的典型用法代码示例。如果您正苦于以下问题:C# NormalizedSnapshotSpanCollection类的具体用法?C# NormalizedSnapshotSpanCollection怎么用?C# NormalizedSnapshotSpanCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NormalizedSnapshotSpanCollection类属于命名空间,在下文中一共展示了NormalizedSnapshotSpanCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: DrawChanges

		private void DrawChanges(DrawingContext drawingContext, NormalizedSnapshotSpanCollection changes, Brush brush)
		{
			if (changes.Count > 0)
			{
				double yTop = Math.Floor(_scrollBar.GetYCoordinateOfBufferPosition(changes[0].Start)) + markerStartOffset;
				double yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(changes[0].End)) + markerEndOffset;

				for (int i = 1; i < changes.Count; ++i)
				{
					double y = _scrollBar.GetYCoordinateOfBufferPosition(changes[i].Start) + markerStartOffset;
					if (yBottom < y)
					{
						drawingContext.DrawRectangle(
							brush,
							null,
							new Rect(0, yTop, markerWidth, yBottom - yTop));

						yTop = y;
					}

					yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(changes[i].End)) + markerEndOffset;
				}

				drawingContext.DrawRectangle(
					brush,
					null,
					new Rect(0, yTop, markerWidth, yBottom - yTop));
			}
		}
开发者ID:jburrow,项目名称:progressive-scroll,代码行数:29,代码来源:ChangeRenderer.cs


示例2: UncommentSpans

        public NormalizedSnapshotSpanCollection UncommentSpans(NormalizedSnapshotSpanCollection spans)
        {
            Contract.Requires<ArgumentNullException>(spans != null, "spans");
            Contract.Ensures(Contract.Result<NormalizedSnapshotSpanCollection>() != null);

            throw new NotImplementedException();
        }
开发者ID:chandramouleswaran,项目名称:LangSvcV2,代码行数:7,代码来源:ICommenterContracts.cs


示例3: GetOverarchingSpan2

 public void GetOverarchingSpan2()
 {
     var spans = new NormalizedSnapshotSpanCollection();
     _selection.SetupGet(x => x.SelectedSpans).Returns(spans).Verifiable();
     Assert.True(TextSelectionUtil.GetOverarchingSelectedSpan(_selection.Object).IsNone());
     _selection.Verify();
 }
开发者ID:aesire,项目名称:VsVim,代码行数:7,代码来源:TextSelectionUtilTest.cs


示例4: FormattedStringBuilderEndToEnd1

        public void FormattedStringBuilderEndToEnd1()
        {
            var classificationFormatMap = new MockClassificationFormatMap();
            var htmlMarkupProvider = new HtmlMarkupProvider(
                classificationFormatMap,
                MockClassificationType.Default,
                Brushes.White);
            var classifier = new MockClassifier();

            var formattedStringBuilder = new FormattedStringBuilder(
                htmlMarkupProvider,
                classifier,
                MockClassificationType.Default,
                waitIndicator: null);

            var snapshot = new MockTextSnapshot("bla");
            var spans = new NormalizedSnapshotSpanCollection(new []
            {
                new SnapshotSpan(snapshot, 0, 3)
            });

            var actualResult = formattedStringBuilder.AppendSnapshotSpans(spans);
            var expectedResult = "<pre style=\"font-family:Consolas;font-size:12;color:black;background:white;\">b<span style=\"color:blue;\">l</span>a\r\n</pre>";

            Assert.AreEqual(expectedResult, actualResult);
        }
开发者ID:xornand,项目名称:VS-PPT,代码行数:26,代码来源:FormattedStringBuilderTests.cs


示例5: Add

		public void Add(ISynchronousClassifier classifier, NormalizedSnapshotSpanCollection spans, CancellationToken cancellationToken) {
			if (classifier == null)
				throw new ArgumentNullException(nameof(classifier));
			if (spans == null)
				throw new ArgumentNullException(nameof(spans));
			foreach (var span in spans) {
				if (spansCount > 0)
					htmlWriter.WriteRaw(delimiter);
				spansCount++;
				var tagSpans = classifier.GetClassificationSpans(span, cancellationToken);
				var text = span.GetText();
				int pos = span.Start.Position;
				foreach (var tagSpan in tagSpans) {
					if (pos < tagSpan.Span.Start) {
						WriteCss(classificationFormatMap.DefaultTextProperties);
						htmlWriter.WriteSpan(cssWriter.ToString(), text, pos - span.Start.Position, tagSpan.Span.Start.Position - pos);
					}
					WriteCss(classificationFormatMap.GetTextProperties(tagSpan.ClassificationType));
					htmlWriter.WriteSpan(cssWriter.ToString(), text, tagSpan.Span.Start - span.Start.Position, tagSpan.Span.Length);
					pos = tagSpan.Span.End;
				}
				if (pos < span.End) {
					WriteCss(classificationFormatMap.DefaultTextProperties);
					htmlWriter.WriteSpan(cssWriter.ToString(), text, pos - span.Start.Position, span.End.Position - pos);
				}
			}
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:27,代码来源:HtmlBuilder.cs


示例6: GenerateHtmlFragmentCore

		string GenerateHtmlFragmentCore(NormalizedSnapshotSpanCollection spans, ITextView textView, string delimiter, CancellationToken cancellationToken) {
			ISynchronousClassifier classifier = null;
			try {
				int tabSize;
				IClassificationFormatMap classificationFormatMap;
				if (textView != null) {
					classifier = synchronousViewClassifierAggregatorService.GetSynchronousClassifier(textView);
					classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(textView);
					tabSize = textView.Options.GetTabSize();
				}
				else {
					classifier = spans.Count == 0 ? null : synchronousClassifierAggregatorService.GetSynchronousClassifier(spans[0].Snapshot.TextBuffer);
					classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(AppearanceCategoryConstants.TextEditor);
					tabSize = defaultTabSize;
				}
				tabSize = OptionsHelpers.FilterTabSize(tabSize);

				var builder = new HtmlBuilder(classificationFormatMap, delimiter, tabSize);
				if (spans.Count != 0)
					builder.Add(classifier, spans, cancellationToken);
				return builder.Create();
			}
			finally {
				(classifier as IDisposable)?.Dispose();
			}
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:26,代码来源:HtmlBuilderService.cs


示例7: CalculateForBlock3

 public void CalculateForBlock3()
 {
     var buffer = EditorUtil.CreateBuffer("dog", "cat", "chicken");
     var col = new NormalizedSnapshotSpanCollection(buffer.GetSpan(0, 2));
     var span = _calcRaw.CalculateForBlock(buffer.GetLine(1).Start.Add(1), col);
     Assert.IsTrue(span.IsMultiple);
     Assert.AreEqual(buffer.GetLine(1).Start.Add(1).GetSpan(2), span.AsMultiple().Item2[0]);
 }
开发者ID:rride,项目名称:VsVim,代码行数:8,代码来源:VisualSpanCalculatorTest.cs


示例8: GenerateHtmlFragment

		public string GenerateHtmlFragment(NormalizedSnapshotSpanCollection spans, string delimiter, CancellationToken cancellationToken) {
			if (spans == null)
				throw new ArgumentNullException(nameof(spans));
			if (delimiter == null)
				throw new ArgumentNullException(nameof(delimiter));

			return GenerateHtmlFragmentCore(spans, null, delimiter, cancellationToken);
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:8,代码来源:HtmlBuilderService.cs


示例9: GetTags

        private static IEnumerable<ITagSpan<OutliningRegionTag>> GetTags(string input)
        {
            var buffer = new FakeTextBuffer(input);
            var tagger = new TemplateOutliningTagger(buffer);

            var snapshotSpans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length));
            return tagger.GetTags(snapshotSpans);
        }
开发者ID:icool123,项目名称:T4Toolbox,代码行数:8,代码来源:TemplateOutliningTaggerTest.cs


示例10: GetOverarchingSpan3

 public void GetOverarchingSpan3()
 {
     var buffer = CreateTextBuffer("foo bar");
     var span = buffer.GetLineRange(0).Extent;
     var col = new NormalizedSnapshotSpanCollection(span);
     _selection.SetupGet(x => x.SelectedSpans).Returns(col).Verifiable();
     Assert.Equal(span, TextSelectionUtil.GetOverarchingSelectedSpan(_selection.Object).Value);
     _selection.Verify();
 }
开发者ID:aesire,项目名称:VsVim,代码行数:9,代码来源:TextSelectionUtilTest.cs


示例11: GetOverarchingSpan4

 public void GetOverarchingSpan4()
 {
     var buffer = CreateTextBuffer("foo", "baz", "bar");
     var span1 = buffer.GetLineRange(0).Extent;
     var span2 = buffer.GetLineRange(0, 1).Extent;
     var col = new NormalizedSnapshotSpanCollection(new SnapshotSpan[] { span1, span2 });
     _selection.SetupGet(x => x.SelectedSpans).Returns(col).Verifiable();
     Assert.AreEqual(buffer.GetLineRange(0, 1).Extent, TextSelectionUtil.GetOverarchingSelectedSpan(_selection.Object).Value);
     _selection.Verify();
 }
开发者ID:bajtos,项目名称:VsVim,代码行数:10,代码来源:TextSelectionUtilTest.cs


示例12: GetTagsReturnsErrorSpanForSemanticError

        public static void GetTagsReturnsErrorSpanForSemanticError()
        {
            var buffer = new FakeTextBuffer("<#@ include file=\" \" #>");
            var tagger = new TemplateErrorTagger(buffer);

            var snapshotSpans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length));
            ITagSpan<ErrorTag> errorSpan = tagger.GetTags(snapshotSpans).Single();

            Assert.Equal(new Span(12, 8), errorSpan.Span);
            Assert.Contains("File", (string)errorSpan.Tag.ToolTipContent, StringComparison.OrdinalIgnoreCase);
        }
开发者ID:icool123,项目名称:T4Toolbox,代码行数:11,代码来源:TemplateErrorTaggerTest.cs


示例13: ShouldClassifyScenario

 public void ShouldClassifyScenario()
 {
     TestInitialise("Features/gherkin.feature");
     var snapShotSpan = new SnapshotSpan(new MockTextSnapshot(featureFileContent), new Span(0, 15));
     var spanCollection = new NormalizedSnapshotSpanCollection(new[] { snapShotSpan });
     var tags = playTagger.GetTags(spanCollection);
     var tag = tags.First(_ => _.Span.GetText().StartsWith("  Scenario: SC2")).Tag;
     Assert.AreEqual("Scenario: SC2" + Environment.NewLine +
                     "  Given something" + Environment.NewLine +
                     "  When some event occurs" + Environment.NewLine +
                     "  Then there is some outcome", tag.GetText());
 }
开发者ID:AngelPortal,项目名称:NBehave,代码行数:12,代码来源:PlayTaggerSpec.cs


示例14: IsComment

        private static bool IsComment(SnapshotPoint position)
        {
            if (position.Position < 2)
                return false;

            var tagger = position.Snapshot.TextBuffer.Properties.GetProperty<ITagger<ClassificationTag>>(jsTaggerType);

            Span span = Span.FromBounds(position.Position - 1, position.Position);
            var spans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(position.Snapshot, span));
            var classifications = tagger.GetTags(spans);

            return classifications.Any(c => c.Tag.ClassificationType.IsOfType("comment"));
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:13,代码来源:JsDocCompletionSource.cs


示例15: CreateElisionBufferWithoutIndentation

        public static IElisionBuffer CreateElisionBufferWithoutIndentation(
            this IProjectionBufferFactoryService factoryService,
            IEditorOptions editorOptions,
            IContentType contentType,
            IEnumerable<SnapshotSpan> exposedSpans)
        {
            var spans = new NormalizedSnapshotSpanCollection(exposedSpans);

            if (spans.Count > 0)
            {
                // BUG(6335): We have to make sure that the spans refer to the current snapshot of
                // the buffer.
                var buffer = spans.First().Snapshot.TextBuffer;
                var currentSnapshot = buffer.CurrentSnapshot;
                spans = new NormalizedSnapshotSpanCollection(
                    spans.Select(s => s.TranslateTo(currentSnapshot, SpanTrackingMode.EdgeExclusive)));
            }

            contentType = contentType ?? factoryService.ProjectionContentType;
            var elisionBuffer = factoryService.CreateElisionBuffer(
                null, spans, ElisionBufferOptions.None, contentType);

            if (spans.Count > 0)
            {
                var snapshot = spans.First().Snapshot;
                var buffer = snapshot.TextBuffer;

                // We need to figure out the shorted indentation level of the exposed lines.  We'll
                // then remove that indentation from all lines.
                var indentationColumn = DetermineIndentationColumn(editorOptions, spans);

                var spansToElide = new List<Span>();

                foreach (var span in spans)
                {
                    var startLineNumber = snapshot.GetLineNumberFromPosition(span.Start);
                    var endLineNumber = snapshot.GetLineNumberFromPosition(span.End);

                    for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++)
                    {
                        var line = snapshot.GetLineFromLineNumber(lineNumber);
                        var lineOffsetOfColumn = line.GetLineOffsetFromColumn(indentationColumn, editorOptions);
                        spansToElide.Add(Span.FromBounds(line.Start, line.Start + lineOffsetOfColumn));
                    }
                }

                elisionBuffer.ElideSpans(new NormalizedSpanCollection(spansToElide));
            }

            return elisionBuffer;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:51,代码来源:IProjectionBufferFactoryServiceExtensions.cs


示例16: CalculateForBlock4

 public void CalculateForBlock4()
 {
     var buffer = EditorUtil.CreateBuffer("dog again", "cat again", "chicken");
     var col = new NormalizedSnapshotSpanCollection(new SnapshotSpan[]
     {
         buffer.GetLine(0).Start.GetSpan(2),
         buffer.GetLine(1).Start.GetSpan(2)
     });
     var span = _calcRaw.CalculateForBlock(buffer.GetLine(1).Start, col);
     Assert.IsTrue(span.IsMultiple);
     col = span.AsMultiple().item2;
     Assert.AreEqual(buffer.GetLine(1).Start.GetSpan(2), col[0]);
     Assert.AreEqual(buffer.GetLine(2).Start.GetSpan(2), col[1]);
 }
开发者ID:rride,项目名称:VsVim,代码行数:14,代码来源:VisualSpanCalculatorTest.cs


示例17: Split

		private IEnumerable<SnapshotSpan> Split(SnapshotSpan span, IEnumerable<SnapshotSpan> remove) {
			var removeNorm = new NormalizedSnapshotSpanCollection(remove);
			foreach (var r in removeNorm.OrderBy(x => x.Start.Position)) {
				if (r.Start < span.End) {
					if (r.Start > span.Start) {
						yield return new SnapshotSpan(span.Start, r.Start);
					}
					if (r.End < span.End) {
						span = new SnapshotSpan(r.End, span.End);
					} else {
						yield break;
					}
				}
			}
			yield return span;
		}
开发者ID:Teme64,项目名称:DynamicJavaScriptRunTimes.NET,代码行数:16,代码来源:Classifier.cs


示例18: ShouldClassifyScenarioWithExamples

        public void ShouldClassifyScenarioWithExamples()
        {
            TestInitialise("Features/gherkin.feature");
            var snapShotSpan = new SnapshotSpan(new MockTextSnapshot(featureFileContent), new Span(0, 15));
            var spanCollection = new NormalizedSnapshotSpanCollection(new[] { snapShotSpan });
            var tags = playTagger.GetTags(spanCollection);
            var tag = tags.First(span => span.Span.GetText().StartsWith("  Scenario: SC1")).Tag;

            Assert.AreEqual("Scenario: SC1" + Environment.NewLine +
                            "  Given numbers [left] and [right]" + Environment.NewLine +
                            "  When I add the numbers" + Environment.NewLine +
                            "  Then the sum is [sum]" + Environment.NewLine +
                            "Examples:" + Environment.NewLine +
                            "     | left | right | sum |" + Environment.NewLine +
                            "     | 1 | 2 | 3 |" + Environment.NewLine +
                            "     | 3 | 4 | 7 |", tag.GetText());
        }
开发者ID:AngelPortal,项目名称:NBehave,代码行数:17,代码来源:PlayTaggerSpec.cs


示例19: CreateRegionsAround_SelectionAtEndOfDocument

        public void CreateRegionsAround_SelectionAtEndOfDocument()
        {
            var textBuffer = GetCSharpTextBuffer("Outlining1.txt");
              var snapshot = textBuffer.CurrentSnapshot;
              var outlining = SelectionOutliningManager.Get(textBuffer);

              int lineCount = snapshot.LineCount;
              var selectionSpan = GetSpanFromLines(snapshot, lineCount-10, lineCount-1);
              outlining.CreateRegionsAround(selectionSpan);

              // validate GetTags() gives us two spans
              var allDocument = new NormalizedSnapshotSpanCollection(snapshot.GetSpan());
              var tags = outlining.GetTags(allDocument).ToList();

              var span1 = GetSpanFromLines(snapshot, 0, (lineCount - 10)-1);
              Assert.Equal(span1, tags.First());
        }
开发者ID:bayulabster,项目名称:viasfora,代码行数:17,代码来源:SelectionOutliningManagerTests.cs


示例20: BracesInSpans

        public IEnumerable<BracePos> BracesInSpans(NormalizedSnapshotSpanCollection spans)
        {
            if ( ScanIsUnnecessary() ) yield break;

              for ( int i = 0; i < spans.Count; i++ ) {
            var wantedSpan = spans[i];
            EnsureLinesInPreferredSpan(wantedSpan);
            int startIndex = FindIndexOfBraceAtOrAfter(wantedSpan.Start);
            if ( startIndex < 0 ) {
              continue;
            }
            for ( int j = startIndex; j < braces.Count; j++ ) {
              BracePos bp = braces[j];
              if ( bp.Position > wantedSpan.End ) break;
              yield return bp;
            }
              }
        }
开发者ID:bayulabster,项目名称:viasfora,代码行数:18,代码来源:TextBufferBraces.cs



注:本文中的NormalizedSnapshotSpanCollection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NorthwindConfig类代码示例发布时间:2022-05-24
下一篇:
C# NormalizationForm类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap