-
Notifications
You must be signed in to change notification settings - Fork 13
/
EmojiLocationHandler.cs
36 lines (32 loc) · 1021 Bytes
/
EmojiLocationHandler.cs
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
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Tagging;
namespace Emoji
{
class EmojiLocationHandler : IEmojiLocationHandler
{
private static readonly HashSet<string> CommentClassifications = new HashSet<string>(new[]
{
"css comment",
"xml doc comment",
"vb xml doc comment",
"vb xml comment",
"html comment",
"vbscript comment",
"comment",
});
private readonly ITagAggregator<IClassificationTag> _classificationTagAggregator;
public EmojiLocationHandler(ITextBuffer buffer, IBufferTagAggregatorFactoryService bufferTagAggregatorFactoryService)
{
_classificationTagAggregator = bufferTagAggregatorFactoryService.CreateTagAggregator<IClassificationTag>(buffer);
}
public bool CanHazEmoji(SnapshotSpan span)
{
return _classificationTagAggregator
.GetTags(span)
.Select(t => t.Tag.ClassificationType.Classification.ToLowerInvariant())
.Any(CommentClassifications.Contains);
}
}
}