-
Notifications
You must be signed in to change notification settings - Fork 112
/
TemplateClassificationTaggerProvider.cs
47 lines (40 loc) · 1.77 KB
/
TemplateClassificationTaggerProvider.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
37
38
39
40
41
42
43
44
45
46
47
// <copyright file="TemplateClassificationTaggerProvider.cs" company="Oleg Sych">
// Copyright © Oleg Sych. All Rights Reserved.
// </copyright>
namespace T4Toolbox.VisualStudio.Editor
{
using System;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;
[Export(typeof(ITaggerProvider)), TagType(typeof(ClassificationTag)), ContentType(TemplateContentType.Name)]
internal sealed class TemplateClassificationTaggerProvider : ITaggerProvider
{
private readonly ITemplateEditorOptions options;
private readonly IClassificationTypeRegistryService classificationTypeRegistry;
[ImportingConstructor]
public TemplateClassificationTaggerProvider(ITemplateEditorOptions options, IClassificationTypeRegistryService classificationTypeRegistry)
{
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
if (classificationTypeRegistry == null)
{
throw new ArgumentNullException(nameof(classificationTypeRegistry));
}
this.options = options;
this.classificationTypeRegistry = classificationTypeRegistry;
}
public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag
{
if (this.options.SyntaxColorizationEnabled)
{
return buffer.Properties.GetOrCreateSingletonProperty(() => new TemplateClassificationTagger(buffer, this.classificationTypeRegistry)) as ITagger<T>;
}
return null;
}
}
}