-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGcodeClassifierProvider.cs
More file actions
93 lines (76 loc) · 3.58 KB
/
GcodeClassifierProvider.cs
File metadata and controls
93 lines (76 loc) · 3.58 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
namespace GcodeLanguage
{
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;
// /// <summary>
// /// Classifier provider. It adds the classifier to the set of classifiers.
// /// </summary>
// [Export(typeof(IClassifierProvider))]
// [ContentType("text")] // This classifier applies to all text files.
// internal class GcodeClassifierProvider : IClassifierProvider
// {
// // Disable "Field is never assigned to..." compiler's warning. Justification: the field is assigned by MEF.
//#pragma warning disable 649
// /// <summary>
// /// Classification registry to be used for getting a reference
// /// to the custom classification type later.
// /// </summary>
// [Import]
// private IClassificationTypeRegistryService classificationRegistry;
//#pragma warning restore 649
// #region IClassifierProvider
// /// <summary>
// /// Gets a classifier for the given text buffer.
// /// </summary>
// /// <param name="buffer">The <see cref="ITextBuffer"/> to classify.</param>
// /// <returns>A classifier for the text buffer, or null if the provider cannot do so in its current state.</returns>
// public IClassifier GetClassifier(ITextBuffer buffer)
// {
// return buffer.Properties.GetOrCreateSingletonProperty<GcodeClassifier>(creator: () => new GcodeClassifier(this.classificationRegistry));
// }
// #endregion
// }
[Export(typeof(ITaggerProvider))]
[ContentType("gcode")]
[TagType(typeof(ClassificationTag))]
internal sealed class GcodeClassifierProvider : ITaggerProvider
{
[Export(typeof(ContentTypeDefinition))]
[Name("gcode")]
[BaseDefinition("text")]
internal static ContentTypeDefinition GcodeContentType = null;
[Export(typeof(FileExtensionToContentTypeDefinition))]
[FileExtension(".gcode")]
[ContentType("gcode")]
internal static FileExtensionToContentTypeDefinition GcodeFileType = null;
[Export(typeof(FileExtensionToContentTypeDefinition))]
[FileExtension(".mpf")]
[ContentType("gcode")]
internal static FileExtensionToContentTypeDefinition GcodeFileTypeMPF = null;
[Export(typeof(FileExtensionToContentTypeDefinition))]
[FileExtension(".mpt")]
[ContentType("gcode")]
internal static FileExtensionToContentTypeDefinition GcodeFileTypeMPT = null;
[Export(typeof(FileExtensionToContentTypeDefinition))]
[FileExtension(".nc")]
[ContentType("gcode")]
internal static FileExtensionToContentTypeDefinition GcodeFileTypeNC = null;
[Import]
internal IClassificationTypeRegistryService ClassificationTypeRegistry = null;
[Import]
internal IBufferTagAggregatorFactoryService aggregatorFactory = null;
public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag
{
ITagAggregator<GcodeTokenTag> GcodeTagAggregator =
aggregatorFactory.CreateTagAggregator<GcodeTokenTag>(buffer);
return new GcodeClassifier(buffer, GcodeTagAggregator, ClassificationTypeRegistry) as ITagger<T>;
}
}
}