Welcome to mirror list, hosted at ThFree Co, Russian Federation.

EditorOperationsFactoryService.cs « EditorOperations « Impl « Text « src - github.com/microsoft/vs-editor-api.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7b1d6932fa8d8667c2ab442eb9cf3229aa6f036a (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
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
94
95
//
//  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.Operations.Implementation
{
    using System;
    using System.ComponentModel.Composition;

    using Microsoft.VisualStudio.Text.Editor;
    using Microsoft.VisualStudio.Text.Formatting;
    using Microsoft.VisualStudio.Utilities;
    using Microsoft.VisualStudio.Text.Outlining;
#if WINDOWS
    using Microsoft.VisualStudio.Language.Intellisense.Utilities;
#endif

    [Export(typeof(IEditorOperationsFactoryService))]
    internal sealed class EditorOperationsFactoryService : IEditorOperationsFactoryService
    {
        [Import]
        internal ITextStructureNavigatorSelectorService TextStructureNavigatorFactory { get; set; }

#if WINDOWS
        // This service should be optional: it is implemented on the VS side and other hosts may not implement it.
        [Import(AllowDefault = true)]
        internal IWaitIndicator WaitIndicator { get; set; }
#endif

        [Import]
        internal ITextSearchService TextSearchService { get; set; }

        [Import]
        internal ITextUndoHistoryRegistry UndoHistoryRegistry { get; set; }

        [Import]
        internal ITextBufferUndoManagerProvider TextBufferUndoManagerProvider { get; set; }

        [Import]
        internal IEditorPrimitivesFactoryService EditorPrimitivesProvider { get; set; }

        [Import]
        internal IEditorOptionsFactoryService EditorOptionsProvider { get; set; }

#if WINDOWS
        [Import(AllowDefault = true)]
        internal IRtfBuilderService RtfBuilderService { get; set; }

#endif
        [Import]
        internal ISmartIndentationService SmartIndentationService { get; set; }

        [Import]
        internal ITextDocumentFactoryService TextDocumentFactoryService { get; set; }

        [Import]
        internal IContentTypeRegistryService ContentTypeRegistryService { get; set; }

        [Import(AllowDefault = true)]
        internal IOutliningManagerService OutliningManagerService { get; set; }

        /// <summary>
        /// Provides a operations implementation for a given text view.
        /// </summary>
        /// <param name="textView">
        /// The text view to which the operations will be bound.
        /// </param> 
        /// <returns>
        /// An implementation of IEditorOperations that can provide operations implementations for the given text view.
        /// </returns>
        public IEditorOperations GetEditorOperations(ITextView textView)
        {
            // Validate
            if (textView == null)
            {
                throw new ArgumentNullException("textView");
            }

            // Only one EditorOperations should be created per ITextView
            IEditorOperations editorOperations = null;

            // We create one, only if it doesn't already exist
            if (!textView.Properties.TryGetProperty<IEditorOperations>(typeof(EditorOperationsFactoryService), out editorOperations))
            {
                editorOperations = new EditorOperations(textView, this);
                textView.Properties.AddProperty(typeof(EditorOperationsFactoryService), editorOperations);
            }

            return editorOperations;
        }
    }
}