blob: 081672e69e67290937fe4de6bcaf3d73a24459aa (
plain)
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
|
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// This file contain implementations details that are subject to change without notice.
// Use at your own risk.
//
namespace Microsoft.VisualStudio.Text.Outlining
{
using System;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Threading;
using Microsoft.Win32;
[Export(typeof(IOutliningManagerService))]
internal class OutliningManagerService : IOutliningManagerService
{
[Import]
internal IBufferTagAggregatorFactoryService TagAggregatorFactory { get; set; }
[Import]
internal IEditorOptionsFactoryService EditorOptionsFactoryService { get; set; }
// While these are IDisposable, they are kept for the life of the textView, meaning that callers shouldn't actually
// dispose of them.
public IOutliningManager GetOutliningManager(ITextView textView)
{
if (textView == null)
throw new ArgumentNullException(nameof(textView));
if (!textView.Roles.Contains(PredefinedTextViewRoles.Structured))
return null;
return textView.Properties.GetOrCreateSingletonProperty(delegate
{
var tagAggregator = TagAggregatorFactory.CreateTagAggregator<IOutliningRegionTag>(textView.TextBuffer);
var manager = new OutliningManager(textView.TextBuffer, tagAggregator, EditorOptionsFactoryService.GlobalOptions);
textView.Closed += delegate { manager.Dispose(); };
return manager;
});
}
}
}
|