public void VsTextViewCreated(IVsTextView vsTextView) { if (vsTextView == null) { throw new ArgumentNullException(nameof(vsTextView)); } if (ErrorHandler.Failed(vsTextView.GetBuffer(out var textLines))) { return; } IVsUserData userData = textLines as IVsUserData; if (userData == null) { return; } Guid monikerGuid = typeof(IVsUserData).GUID; if (ErrorHandler.Failed(userData.GetData(ref monikerGuid, out var monikerObj))) { return; } string filePath = monikerObj as string; _rdt.Value.FindDocument(filePath, out var hierarchy, out var itemId, out var docCookie); AbstractProject project = GetXamlProject(hierarchy); if (project == null) { project = new XamlProject( _vsWorkspace.GetProjectTrackerAndInitializeIfNecessary(_serviceProvider), hierarchy, _serviceProvider, _vsWorkspace); } IVisualStudioHostDocument vsDocument = project.GetCurrentDocumentFromPath(filePath); if (vsDocument == null) { if (!TryCreateXamlDocument(project, filePath, out vsDocument)) { return; } project.AddDocument(vsDocument, isCurrentContext: true, hookupHandlers: true); } AttachRunningDocTableEvents(); var wpfTextView = _editorAdaptersFactory.GetWpfTextView(vsTextView); var target = new XamlOleCommandTarget(wpfTextView, CommandHandlerServiceFactory, _editorAdaptersFactory, _serviceProvider); target.AttachToVsTextView(); }
IWorkspaceProjectContext IWorkspaceProjectContextFactory.CreateProjectContext( string languageName, string projectDisplayName, string projectFilePath, Guid projectGuid, object hierarchy, string binOutputPath) { // NOTE: It is acceptable for hierarchy to be null in Deferred Project Load scenarios. var vsHierarchy = hierarchy as IVsHierarchy; Func <ProjectId, IVsReportExternalErrors> getExternalErrorReporter = id => GetExternalErrorReporter(id, languageName); return(new CPSProject(_visualStudioWorkspace.GetProjectTrackerAndInitializeIfNecessary(ServiceProvider.GlobalProvider), getExternalErrorReporter, projectDisplayName, projectFilePath, vsHierarchy, languageName, projectGuid, binOutputPath, _serviceProvider, _visualStudioWorkspace, _hostDiagnosticUpdateSource, commandLineParserServiceOpt: _visualStudioWorkspace.Services.GetLanguageServices(languageName)?.GetService <ICommandLineParserService>())); }