InlineParameterNameHintsTaggerProvider.cs 2.7 KB
Newer Older
A
Ankita Khera 已提交
1 2 3 4
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

A
Ankita Khera 已提交
5
using System;
A
Ankita Khera 已提交
6
using System.ComponentModel.Composition;
A
Ankita Khera 已提交
7
using Microsoft.CodeAnalysis.Host.Mef;
A
Ankita Khera 已提交
8
using Microsoft.VisualStudio.Text;
9
using Microsoft.VisualStudio.Text.Classification;
A
Ankita Khera 已提交
10 11 12 13
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;

A
Ankita Khera 已提交
14
namespace Microsoft.CodeAnalysis.Editor.InlineParameterNameHints
A
Ankita Khera 已提交
15
{
A
Ankita Khera 已提交
16 17 18 19
    /// <summary>
    /// The provider that is used as a middleman to create the tagger so that the data tag
    /// can be used to create the UI tag
    /// </summary>
A
Ankita Khera 已提交
20
    [Export(typeof(IViewTaggerProvider))]
21
    [ContentType(ContentTypeNames.RoslynContentType)]
22
    [TagType(typeof(IntraTextAdornmentTag))]
23
    [Name(nameof(InlineParameterNameHintsTaggerProvider))]
A
Ankita Khera 已提交
24
    internal class InlineParameterNameHintsTaggerProvider : IViewTaggerProvider
A
Ankita Khera 已提交
25
    {
A
Ankita Khera 已提交
26
        private readonly IBufferTagAggregatorFactoryService _bufferTagAggregatorFactoryService;
27
        public readonly IClassificationFormatMapService ClassificationFormatMapService;
A
Ankita Khera 已提交
28
        public readonly IClassificationTypeRegistryService ClassificationTypeRegistryService;
A
Ankita Khera 已提交
29

A
Ankita Khera 已提交
30
        [ImportingConstructor]
A
Ankita Khera 已提交
31
        [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
A
Ankita Khera 已提交
32 33 34
        public InlineParameterNameHintsTaggerProvider(IBufferTagAggregatorFactoryService bufferTagAggregatorFactoryService,
                                                      [Import] IClassificationFormatMapService classificationFormatMapService,
                                                      [Import] IClassificationTypeRegistryService classificationTypeRegistryService)
A
Ankita Khera 已提交
35
        {
36
            _bufferTagAggregatorFactoryService = bufferTagAggregatorFactoryService;
37
            this.ClassificationFormatMapService = classificationFormatMapService;
A
Ankita Khera 已提交
38
            this.ClassificationTypeRegistryService = classificationTypeRegistryService;
A
Ankita Khera 已提交
39 40
        }

A
Ankita Khera 已提交
41
        /*
42
        public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag
A
Ankita Khera 已提交
43
        {
44 45
            var tagAggregator = _bufferTagAggregatorFactoryService.CreateTagAggregator<InlineParameterNameHintDataTag>(buffer);
            return new InlineParameterNameHintsTagger(buffer, tagAggregator) as ITagger<T>;
A
Ankita Khera 已提交
46
        }
A
Ankita Khera 已提交
47 48 49 50 51
        */

        public ITagger<T> CreateTagger<T>(ITextView textView, ITextBuffer buffer) where T : ITag
        {
            var tagAggregator = _bufferTagAggregatorFactoryService.CreateTagAggregator<InlineParameterNameHintDataTag>(buffer);
52
            return new InlineParameterNameHintsTagger(this, textView, buffer, tagAggregator) as ITagger<T>;
A
Ankita Khera 已提交
53
        }
A
Ankita Khera 已提交
54 55
    }
}