示例#1
0
        private static VimEditorHost GetOrCreateVimEditorHost()
        {
            if (s_cachedVimEditorHost == null)
            {
                var editorHostFactory = new EditorHostFactory();
                editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));

                // Other Exports needed to construct VsVim
                editorHostFactory.Add(new TypeCatalog(
                                          typeof(TestableClipboardDevice),
                                          typeof(TestableKeyboardDevice),
                                          typeof(TestableMouseDevice),
                                          typeof(global::Vim.UnitTest.Exports.VimHost),
                                          typeof(VimErrorDetector),
                                          typeof(DisplayWindowBrokerFactoryService),
                                          typeof(WordCompletionSessionFactoryService),
                                          typeof(AlternateKeyUtil),
                                          typeof(VimProtectedOperations),
                                          typeof(OutlinerTaggerProvider)));

                var compositionContainer = editorHostFactory.CreateCompositionContainer();
                s_cachedVimEditorHost = new VimEditorHost(compositionContainer);
            }

            return(s_cachedVimEditorHost);
        }
 public void GetVersionNumberAll()
 {
     Assert.Equal(10, EditorHostFactory.GetVersionNumber(EditorVersion.Vs2010));
     Assert.Equal(11, EditorHostFactory.GetVersionNumber(EditorVersion.Vs2012));
     Assert.Equal(12, EditorHostFactory.GetVersionNumber(EditorVersion.Vs2013));
     Assert.Equal(14, EditorHostFactory.GetVersionNumber(EditorVersion.Vs2015));
 }
示例#3
0
文件: VimTestBase.cs 项目: vvmk/VsVim
        private static VimEditorHost GetOrCreateVimEditorHost()
        {
            var key = Thread.CurrentThread.ManagedThreadId;

            if (!s_cachedVimEditorHostMap.TryGetValue(key, out VimEditorHost host))
            {
                var editorHostFactory = new EditorHostFactory();
                editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));

                // Other Exports needed to construct VsVim
                editorHostFactory.Add(new TypeCatalog(
                                          typeof(TestableClipboardDevice),
                                          typeof(TestableKeyboardDevice),
                                          typeof(TestableMouseDevice),
                                          typeof(global::Vim.UnitTest.Exports.VimHost),
                                          typeof(VimErrorDetector),
                                          typeof(DisplayWindowBrokerFactoryService),
                                          typeof(WordCompletionSessionFactoryService),
                                          typeof(AlternateKeyUtil),
                                          typeof(OutlinerTaggerProvider)));

                var compositionContainer = editorHostFactory.CreateCompositionContainer();
                host = new VimEditorHost(compositionContainer);
                s_cachedVimEditorHostMap[key] = host;
            }

            return(host);
        }
 public void GetShortVersionStringAll()
 {
     foreach (var e in Enum.GetValues(typeof(EditorVersion)).Cast <EditorVersion>())
     {
         var value = EditorHostFactory.GetShortVersionString(e);
         Assert.NotNull(value);
     }
 }
示例#5
0
        internal EditorHostLoader()
        {
            var editorHostFactory = new EditorHostFactory();

            editorHostFactory.Add(new AssemblyCatalog(typeof(DefaultKeyProcessorProvider).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(MarginFactory).Assembly));
            _editorHost = editorHostFactory.CreateEditorHost();
        }
        public void MaxEditorVersionIsMax()
        {
            var max = EditorHostFactory.GetVersionNumber(EditorHostFactory.MaxEditorVersion);

            foreach (var e in Enum.GetValues(typeof(EditorVersion)).Cast <EditorVersion>())
            {
                var number = EditorHostFactory.GetVersionNumber(e);
                Assert.True(number <= max);
            }
        }
示例#7
0
        internal VimComponentHost()
        {
            var editorHostFactory = new EditorHostFactory();

            editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(VimKeyProcessor).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(VimComponentHost).Assembly));
            _editorHost = editorHostFactory.CreateEditorHost();
            _vim = _editorHost.CompositionContainer.GetExportedValue<IVim>();
        }
示例#8
0
        internal VimComponentHost()
        {
            var editorHostFactory = new EditorHostFactory();

            editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(VimKeyProcessor).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(VimComponentHost).Assembly));
            _editorHost = editorHostFactory.CreateEditorHost();
            _vim        = _editorHost.CompositionContainer.GetExportedValue <IVim>();
        }
示例#9
0
        private EditorHost GetOrCreateEditorHost()
        {
            if (EditorHostCache != null)
            {
                return(EditorHostCache);
            }

            var editorHostFactory = new EditorHostFactory();

            EditorHostCache = editorHostFactory.CreateEditorHost();
            return(EditorHostCache);
        }
示例#10
0
        private static VimEditorHost CreateVimEditorHost()
        {
            var editorHostFactory = new EditorHostFactory();

            editorHostFactory.Add(new AssemblyCatalog(typeof(Vim.IVim).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(Vim.UI.Wpf.VimKeyProcessor).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(VsCommandTarget).Assembly));
            editorHostFactory.Add(new AssemblyCatalog(typeof(ISharedService).Assembly));
            editorHostFactory.Add(new TypeCatalog(
                                      typeof(Vim.VisualStudio.UnitTest.MemoryLeakTest.ServiceProvider),
                                      typeof(Vim.VisualStudio.UnitTest.MemoryLeakTest.VsEditorAdaptersFactoryService),
                                      typeof(VimErrorDetector)));

            return(new VimEditorHost(editorHostFactory.CreateCompositionContainer()));
        }
示例#11
0
        public MainWindow()
        {
            InitializeComponent();

            var editorHostFactory = new EditorHostFactory(EditorVersion.Vs2015);
            var editorHost        = editorHostFactory.CreateEditorHost();

            var textBuffer = editorHost.TextBufferFactoryService.CreateTextBuffer();

            textBuffer.Insert(0, "Hello Editor");

            var wpfTextView     = editorHost.TextEditorFactoryService.CreateTextView(textBuffer);
            var wpfTextViewHost = editorHost.TextEditorFactoryService.CreateTextViewHost(wpfTextView, setFocus: true);

            Content = wpfTextViewHost.HostControl;
        }
示例#12
0
 private VsfEditorHost GetOrCreateEditorHost()
 {
     if (cachedEditorHost == null)
     {
         var editorHostFactory = new EditorHostFactory();
         var catalog           = new AggregateCatalog(
             new AssemblyCatalog(typeof(LanguageFactory).Assembly),
             new AssemblyCatalog(typeof(PkgSource).Assembly),
             new AssemblyCatalog(typeof(TextBufferBraces).Assembly)
             );
         editorHostFactory.Add(catalog);
         var compositionContainer = editorHostFactory.CreateCompositionContainer();
         cachedEditorHost = new VsfEditorHost(compositionContainer);
     }
     return(cachedEditorHost);
 }
示例#13
0
 private VsfEditorHost GetOrCreateEditorHost()
 {
     if (cachedEditorHost == null)
     {
         var editorHostFactory = new EditorHostFactory();
         var catalog           = new AggregateCatalog(
             new AssemblyCatalog(typeof(IUpdatableSettings).Assembly), // Viasfora.Settings
             new AssemblyCatalog(typeof(LanguageFactory).Assembly),    // Viasfora.Languages
             new AssemblyCatalog(typeof(Guids).Assembly),              // Viasfora.Core
             new AssemblyCatalog(typeof(TextBufferBraces).Assembly),   // Viasfora.Rainbow
             new AssemblyCatalog(typeof(XmlTaggerProvider).Assembly)   // Viasfora.Xml
             );
         editorHostFactory.Add(catalog);
         var compositionContainer = editorHostFactory.CreateCompositionContainer();
         cachedEditorHost = new VsfEditorHost(compositionContainer);
     }
     return(cachedEditorHost);
 }
示例#14
0
        public void Init()
        {
            {
                var A = new EditorHostFactory();
                var B = A.CreateCompositionContainer();
                IEditorFormatMapService efms = B.GetExportedValue <IEditorFormatMapService>();
                if (!VsSettings.IsInitialized)
                {
                    VsSettings.Initialize(this.pkg, efms);
                }
            }

            CreateMenu();
            cmdExec = new CommandExecutorService()
            {
            };
            disableVsVimCmdAvailable = cmdExec.IsCommandAvailable(VsVimSetDisabled);
            enableVsVimCmdAvailable  = cmdExec.IsCommandAvailable(VsVimSetEnabled);
            viEmuPluginPresent       = cmdExec.IsCommandAvailable(ViEmuEnableDisableCommand);
            iVsUiShell  = Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell;
            iVsUiShell4 = iVsUiShell as IVsUIShell4;
            JumpLabelUserControl.WarmupCache();
            // warmup options
            GeneralOptions.Instance.caretPositionSensivity = GeneralOptions.Instance.caretPositionSensivity;
            // warmp up:
#if MEASUREEXECTIME
            var watch2_0 = System.Diagnostics.Stopwatch.StartNew();
#endif
            var wfs = iVsUiShell.GetDocumentWindowFrames().GetValueOrDefault();
            if (wfs.Count > 0)
            {
                Trace.WriteLine("GetDocumentWindowFrames warmed up");
                foreach (var wf in wfs)
                {
                    wf.GetProperty((int)VsFramePropID.Caption, out var oce);
                    wf.SetProperty((int)VsFramePropID.Caption, (string)oce);
                }
            }
#if MEASUREEXECTIME
            watch2_0.Stop();
            Trace.WriteLine($"PeasyMotion Adornment warmup document tabs: {watch2_0.ElapsedMilliseconds} ms");
#endif
        }
示例#15
0
 private VsfEditorHost GetOrCreateEditorHost()
 {
     if ( cachedEditorHost == null ) {
     var editorHostFactory = new EditorHostFactory();
     var catalog = new AggregateCatalog(
       new AssemblyCatalog(typeof(LanguageFactory).Assembly),
       new AssemblyCatalog(typeof(PkgSource).Assembly),
       new AssemblyCatalog(typeof(TextBufferBraces).Assembly)
       );
     editorHostFactory.Add(catalog);
     var compositionContainer = editorHostFactory.CreateCompositionContainer();
     cachedEditorHost = new VsfEditorHost(compositionContainer);
       }
       return cachedEditorHost;
 }
示例#16
0
        private EditorHost GetOrCreateEditorHost()
        {
            if (EditorHostCache != null)
            {
                return EditorHostCache;
            }

            var editorHostFactory = new EditorHostFactory();
            EditorHostCache = editorHostFactory.CreateEditorHost();
            return EditorHostCache;
        }
示例#17
0
        private static VimEditorHost GetOrCreateVimEditorHost()
        {
            if (s_cachedVimEditorHost == null)
            {
                var editorHostFactory = new EditorHostFactory();
                editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));

                // Other Exports needed to construct VsVim
                editorHostFactory.Add(new TypeCatalog(
                    typeof(TestableClipboardDevice),
                    typeof(TestableKeyboardDevice),
                    typeof(TestableMouseDevice),
                    typeof(global::Vim.UnitTest.Exports.VimHost),
                    typeof(VimErrorDetector),
                    typeof(DisplayWindowBrokerFactoryService),
                    typeof(WordCompletionSessionFactoryService),
                    typeof(AlternateKeyUtil),
                    typeof(VimProtectedOperations),
                    typeof(OutlinerTaggerProvider)));

                var compositionContainer = editorHostFactory.CreateCompositionContainer();
                s_cachedVimEditorHost = new VimEditorHost(compositionContainer);
            }

            return s_cachedVimEditorHost;
        }
示例#18
0
 private VsfEditorHost GetOrCreateEditorHost()
 {
     if ( cachedEditorHost == null ) {
     var editorHostFactory = new EditorHostFactory();
     editorHostFactory.Add(new AssemblyCatalog(typeof(IVsfSettings).Assembly));
     var compositionContainer = editorHostFactory.CreateCompositionContainer();
     cachedEditorHost = new VsfEditorHost(compositionContainer);
       }
       return cachedEditorHost;
 }