-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrayLogClassifier.cs
More file actions
49 lines (44 loc) · 1.73 KB
/
GrayLogClassifier.cs
File metadata and controls
49 lines (44 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Text.Tagging;
namespace GrayLog
{
/// <summary>
/// GrayLog tag classifier finds every instance of GrayLogTag within a given span.
/// </summary>
internal class GrayLogClassifier : IClassifier
{
private readonly IClassificationType _classificationType;
private readonly ITagAggregator<GrayLogTag> _tagger;
internal GrayLogClassifier(ITagAggregator<GrayLogTag> tagger, IClassificationType grayLogType)
{
_tagger = tagger;
_classificationType = grayLogType;
}
/// <summary>
/// Get every GrayLogTag instance within the given span. Generally, the span in
/// question is the displayed portion of the file currently open in the Editor
/// </summary>
/// <param name="span">The span of text that will be searched for GrayLog tags</param>
/// <returns>A list of every relevant tag in the given span</returns>
public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
{
var tags = _tagger.GetTags(span);
return tags
.Select(tagSpan => tagSpan.Span.GetSpans(span.Snapshot).First())
.Select(grayLogSpan => new ClassificationSpan(grayLogSpan, _classificationType))
.ToList();
}
/// <summary>
/// Create an event for when the Classification changes
/// </summary>
public event EventHandler<ClassificationChangedEventArgs> ClassificationChanged
{
add {}
remove {}
}
}
}