protected override System.Threading.Tasks.Task <object> InitializeToolWindowAsync(Type toolWindowType, int id, CancellationToken cancellationToken) { var context = new OutputToolWindowContext { FccEngine = componentModel.GetService <IFCCEngine>(), ScriptManager = componentModel.GetService <ScriptManager>() }; return(System.Threading.Tasks.Task.FromResult <object>(context)); }
private Microsoft.VisualStudio.Editor.IVsEditorAdaptersFactoryService GetEditorAdaptersFactoryService() { Microsoft.VisualStudio.ComponentModelHost.IComponentModel componentModel = (Microsoft.VisualStudio.ComponentModelHost.IComponentModel)_serviceProvider.GetService( typeof(Microsoft.VisualStudio.ComponentModelHost.SComponentModel)); return(componentModel.GetService <Microsoft.VisualStudio.Editor.IVsEditorAdaptersFactoryService>()); }
/* * Hack necessary for debugging in 2022 ! * https://developercommunity.visualstudio.com/t/vsix-tool-window-vs2022-different-instantiation-wh/1663280 */ internal static OutputToolWindowContext GetOutputToolWindowContext() { return(new OutputToolWindowContext { EventAggregator = componentModel.GetService <IEventAggregator>() }); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var _dte2 = (DTE2)GetGlobalService(typeof(SDTE)); var sp = new ServiceProvider(_dte2 as Microsoft.VisualStudio.OLE.Interop.IServiceProvider); componentModel = sp.GetService(typeof(Microsoft.VisualStudio.ComponentModelHost.SComponentModel)) as Microsoft.VisualStudio.ComponentModelHost.IComponentModel; Assumes.Present(componentModel); fccEngine = componentModel.GetService <IFCCEngine>(); await OutputToolWindowCommand.InitializeAsync(this, componentModel.GetService <ILogger>()); await ClearUICommand.InitializeAsync(this, fccEngine); }
public int OnLoadCompleted(int fReload) { _cp.Unadvise(_cookie); var adapterService = _compModel.GetService <IVsEditorAdaptersFactoryService>(); ITextBuffer diskBuffer = adapterService.GetDocumentBuffer(_textLines); var factService = _compModel.GetService <IProjectionBufferFactoryService>(); var contentRegistry = _compModel.GetService <IContentTypeRegistryService>(); var bufferTagAggregatorFactory = _compModel.GetService <IBufferTagAggregatorFactoryService>(); IContentType contentType = SniffContentType(diskBuffer) ?? contentRegistry.GetContentType("HTML"); var projBuffer = new PhpProjectionBuffer(contentRegistry, factService, bufferTagAggregatorFactory, diskBuffer, _compModel.GetService <IBufferGraphFactoryService>(), contentType); diskBuffer.Properties.AddProperty(typeof(PhpProjectionBuffer), projBuffer); Guid langSvcGuid = typeof(PhpLanguageInfo).GUID; _textLines.SetLanguageServiceID(ref langSvcGuid); adapterService.SetDataBuffer(_textLines, projBuffer.ProjectionBuffer); IVsTextView view; ErrorHandler.ThrowOnFailure(_window.GetPrimaryView(out view)); if (contentType != null && contentType.IsOfType("HTML")) { var editAdapter = _compModel.GetService <IVsEditorAdaptersFactoryService>(); var newView = editAdapter.GetWpfTextView(view); var intellisenseController = HtmlIntellisenseControllerProvider.GetOrCreateController(_compModel, newView); intellisenseController.AttachKeyboardFilter(); } return(VSConstants.S_OK); }