本文整理汇总了C#中NormalizedSnapshotSpanCollection类的典型用法代码示例。如果您正苦于以下问题:C# NormalizedSnapshotSpanCollection类的具体用法?C# NormalizedSnapshotSpanCollection怎么用?C# NormalizedSnapshotSpanCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NormalizedSnapshotSpanCollection类属于命名空间,在下文中一共展示了NormalizedSnapshotSpanCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
}
示例2: UncommentSpans
public NormalizedSnapshotSpanCollection UncommentSpans(NormalizedSnapshotSpanCollection spans)
{
Contract.Requires<ArgumentNullException>(spans != null, "spans");
Contract.Ensures(Contract.Result<NormalizedSnapshotSpanCollection>() != null);
throw new NotImplementedException();
}
示例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();
}
示例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);
}
示例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);
}
}
}
示例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();
}
}
示例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]);
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例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());
}
示例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"));
}
示例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;
}