public CodeWindowManager(IVsCodeWindow codeWindow, IWpfTextView textView, IComponentModel componentModel) { _window = codeWindow; _textView = textView; _editorOperationsFactory = componentModel.GetService<IEditorOperationsFactoryService>(); _analyzer = componentModel.GetService<IPythonAnalyzer>(); }
public PreviewEngine( string title, string helpString, string description, string topLevelItemName, Glyph topLevelGlyph, Solution newSolution, Solution oldSolution, IComponentModel componentModel, IVsImageService2 imageService, bool showCheckBoxes = true) { _topLevelName = topLevelItemName; _topLevelGlyph = topLevelGlyph; _title = title; _helpString = helpString; _description = description; _newSolution = newSolution.WithMergedLinkedFileChangesAsync(oldSolution, cancellationToken: CancellationToken.None).Result; _oldSolution = oldSolution; _diffSelector = componentModel.GetService<ITextDifferencingSelectorService>(); _editorFactory = componentModel.GetService<IVsEditorAdaptersFactoryService>(); _componentModel = componentModel; this.ShowCheckBoxes = showCheckBoxes; _imageService = imageService; }
protected AbstractEditorFactory(Package package) { _package = package ?? throw new ArgumentNullException(nameof(package)); _componentModel = (IComponentModel)ServiceProvider.GetService(typeof(SComponentModel)); _editorAdaptersFactoryService = _componentModel.GetService<IVsEditorAdaptersFactoryService>(); _contentTypeRegistryService = _componentModel.GetService<IContentTypeRegistryService>(); _waitIndicator = _componentModel.GetService<IWaitIndicator>(); }
GoToDefinitionAdorner(IWpfTextView textTextView, IComponentModel componentModel) { _textView = textTextView; _classicationFormatMapService = componentModel.GetService<IClassificationFormatMapService>(); _classifier = componentModel.GetService<IViewClassifierAggregatorService>().GetClassifier(textTextView); _adornmentLayer = textTextView.GetAdornmentLayer(AdornerName); _textView.Closed += OnTextViewClosed; }
public FSharpEditorFactory(Package parentPackage) { if (parentPackage == null) { throw new ArgumentNullException(nameof(parentPackage)); } _parentPackage = parentPackage; _componentModel = (IComponentModel)ServiceProvider.GetService(typeof(SComponentModel)); _editorAdaptersFactoryService = _componentModel.GetService<IVsEditorAdaptersFactoryService>(); _contentTypeRegistryService = _componentModel.GetService<IContentTypeRegistryService>(); }
public MyToolWindow() : base(null) { this.Caption = Resources.ToolWindowTitle; this.BitmapResourceID = 301; this.BitmapIndex = 1; _componentModel = (IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SComponentModel)); _invisibleEditorManager = (IVsInvisibleEditorManager)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsInvisibleEditorManager)); _editorAdapter = _componentModel.GetService<IVsEditorAdaptersFactoryService>(); _editorFactoryService = _componentModel.GetService<ITextEditorFactoryService>(); }
public TextInformationManager(IServiceProvider serviceProvider, IComponentModel componentModel) { this.serviceProvider = serviceProvider; this.componentModel = componentModel; fontAndColorStorage = (IVsFontAndColorStorage) serviceProvider.GetService(typeof (SVsFontAndColorStorage)); fontAndColorUtilities = fontAndColorStorage as IVsFontAndColorUtilities; fontAndColorCache = (IVsFontAndColorCacheManager)serviceProvider.GetService(typeof(SVsFontAndColorCacheManager)); textManager = (IVsTextManager) serviceProvider.GetService(typeof (SVsTextManager)); editorAdaptersFactoryService = componentModel.GetService<IVsEditorAdaptersFactoryService>(); textStructureNavigatorSelectorService = componentModel.GetService<ITextStructureNavigatorSelectorService>(); classicationFormatMapService = componentModel.GetService<IClassificationFormatMapService>(); classificationAggregatorService = componentModel.GetService<IClassifierAggregatorService>(); }
DiagnosticService(IWpfTextView textView, IComponentModel componentModel) { var viewTagAggregatorFactoryService = componentModel.GetService<IViewTagAggregatorFactoryService>(); var outliningManagerService = componentModel.GetService<IOutliningManagerService>(); _textView = textView; _errorTagAggregator = viewTagAggregatorFactoryService.CreateTagAggregator<DiagnosticErrorTag>(textView); _outliningManager = outliningManagerService.GetOutliningManager(textView); _diagnosticMapping = new Dictionary<DiagnosticSeverity, ReadOnlyCollection<IMappingTagSpan<DiagnosticErrorTag>>>(); _waitingForAnalysis = true; _textView.Closed += OnTextViewClosed; _textView.TextBuffer.Changed += OnTextBufferChanged; _errorTagAggregator.BatchedTagsChanged += OnBatchedTagsChanged; }
// Constructor for testing protected AbstractDebuggerIntelliSenseContext(IWpfTextView wpfTextView, ITextBuffer contextBuffer, Microsoft.VisualStudio.TextManager.Interop.TextSpan[] currentStatementSpan, IComponentModel componentModel, IContentType contentType, bool isImmediateWindow) { _textView = wpfTextView; this.ContextBuffer = contextBuffer; this.CurrentStatementSpan = currentStatementSpan[0]; _contentType = contentType; this.ProjectionBufferFactoryService = componentModel.GetService<IProjectionBufferFactoryService>(); _bufferGraphFactoryService = componentModel.GetService<IBufferGraphFactoryService>(); _isImmediateWindow = isImmediateWindow; }
public static async Task <IWpfTextView> GetWpfTextViewAsync(this Microsoft.VisualStudio.Shell.IAsyncServiceProvider serviceProvider) { IVsTextManager2 textManager = (IVsTextManager2)await serviceProvider.GetServiceAsync(typeof(SVsTextManager)); if (textManager == null) { return(null); } int result = textManager.GetActiveView2(1, null, (uint)_VIEWFRAMETYPE.vftCodeWindow, out IVsTextView view); if (result != VSConstants.S_OK) { return(null); } IComponentModel componentModel = (IComponentModel)await serviceProvider.GetServiceAsync(typeof(SComponentModel)); IVsEditorAdaptersFactoryService adapterService = componentModel?.GetService <IVsEditorAdaptersFactoryService>(); if (adapterService == null) { return(null); } return(adapterService.GetWpfTextView(view)); }
private void InstallPackages( IComponentModel services, XElement packages, IDictionary<string, string> packageVersions ) { Contract.Requires( services != null ); Contract.Requires( packages != null ); Contract.Requires( packageVersions != null ); if ( packageVersions.Count == 0 ) return; var extensionId = (string) packages.Attribute( "repositoryId" ); var installer = services.GetService<IVsPackageInstaller>(); var unzipped = false; var skipAssemblyReferences = false; var ignoreDependencies = false; // although it's less efficient, we install the packages one at a time to display status. // the mechanism to report back status is internal and can't be wired up without some // crafty reflection hacks. this is a more straight forward alternative. foreach ( var entry in packageVersions ) { var packageVersion = new Dictionary<string, string>() { { entry.Key, entry.Value } }; // provide user feedback DesignTimeEnvironment.StatusBar.Text = SR.PackageInstallStatus.FormatDefault( entry.Key, entry.Value ); // install the package from the vsix location installer.InstallPackagesFromVSExtensionRepository( extensionId, unzipped, skipAssemblyReferences, ignoreDependencies, Project, packageVersion ); } }
internal VsInteractiveWindow(IComponentModel model, Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator, __VSCREATETOOLWIN creationFlags) { _componentModel = model; this.Caption = title; _editorAdapters = _componentModel.GetService<IVsEditorAdaptersFactoryService>(); _evaluator = evaluator; // The following calls this.OnCreate: Guid clsId = this.ToolClsid; Guid empty = Guid.Empty; Guid typeId = providerId; IVsWindowFrame frame; var vsShell = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)); // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are // destroyed when closed. We are really multi instance but we don't want to be closed. ErrorHandler.ThrowOnFailure( vsShell.CreateToolWindow( (uint)(__VSCREATETOOLWIN.CTW_fInitNew | __VSCREATETOOLWIN.CTW_fToolbarHost | creationFlags), (uint)instanceId, this.GetIVsWindowPane(), ref clsId, ref typeId, ref empty, null, title, null, out frame ) ); this.Frame = frame; }
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { try { await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); AsyncPackageHelper.InitializePackage(GetType().Name); // can only get a dialog page from a package OptionsDialogPage = (IOptionsDialogPage)GetDialogPage(typeof(OptionsDialogPage)); ((IServiceContainer)this).AddService(typeof(SOptionsDialogPageAccessor), CreateService, true); ((IServiceContainer)this).AddService(typeof(SToolWindowProvider), CreateService, true); await base.InitializeAsync(cancellationToken, progress); _componentModel = GetGlobalService(typeof(SComponentModel)) as IComponentModel; Assumes.Present(_componentModel); _sessionService = _componentModel.GetService <ISessionService>(); var settingsServiceFactory = _componentModel?.GetService <ISettingsServiceFactory>(); _settingsManager = settingsServiceFactory.Create(); Assumes.Present(_settingsManager); await JoinableTaskFactory.RunAsync(VsTaskRunContext.UIThreadNormalPriority, InitializeCommandsAsync); Log.Debug($"{nameof(InitializeAsync)} completed"); } catch (Exception ex) { Log.Fatal(ex, nameof(InitializeAsync)); } }
public PythonRunSettings([Import(typeof(SVsServiceProvider))]IServiceProvider serviceProvider) { _compModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); var opState = _compModel.GetService<IOperationState>(); opState.StateChanged += StateChange; _dispatcher = Dispatcher.CurrentDispatcher; _serviceProvider = serviceProvider; }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { try { await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); ((IServiceContainer)this).AddService(typeof(SToolWindowProvider), CreateService, true); _componentModel = await GetServiceAsync(typeof(SComponentModel)) as IComponentModel; _sessionService = _componentModel.GetService <ISessionService>(); var settingsServiceFactory = _componentModel?.GetService <ISettingsServiceFactory>(); _settingsManager = settingsServiceFactory.GetOrCreate(nameof(CommandsPackage)); AsyncPackageHelper.InitializeLogging(_settingsManager.GetExtensionTraceLevel()); AsyncPackageHelper.InitializePackage(GetType().Name); await base.InitializeAsync(cancellationToken, progress); await JoinableTaskFactory.RunAsync(VsTaskRunContext.UIThreadNormalPriority, InitializeCommandsAsync); Log.Debug($"{nameof(CommandsPackage)} {nameof(InitializeAsync)} completed"); } catch (Exception ex) { Log.Fatal(ex, nameof(InitializeAsync)); } }
public FileChange(TextDocument left, TextDocument right, IComponentModel componentModel, AbstractChange parent, PreviewEngine engine, IVsImageService2 imageService) : base(engine) { Contract.ThrowIfFalse(left != null || right != null); this.Id = left != null ? left.Id : right.Id; _left = left; _right = right; _imageService = imageService; _componentModel = componentModel; var bufferFactory = componentModel.GetService<ITextBufferFactoryService>(); var bufferText = left != null ? left.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None) : right.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None); _buffer = bufferFactory.CreateTextBuffer(bufferText.ToString(), bufferFactory.InertContentType); _encoding = bufferText.Encoding; this.Children = ComputeChildren(left, right, CancellationToken.None); this.parent = parent; }
public CodeWindowManager(IVsCodeWindow codeWindow, IWpfTextView textView, IComponentModel componentModel) { _window = codeWindow; _textView = textView; _editorOperationsFactory = componentModel.GetService<IEditorOperationsFactoryService>(); _textView.Properties.AddProperty(typeof(CodeWindowManager), this); }
private static async Task <TService> GetComponentModelServiceAsync <TService>() where TService : class { Debug.Assert(ThreadHelper.CheckAccess()); IComponentModel componentModel = await GetGlobalServiceAsync <SComponentModel, IComponentModel>(); return(componentModel?.GetService <TService>()); }
public ReplCSharpEditorSurface() { _CurrentScriptName = System.IO.Path.GetFileName(VSTools.DefaultScriptFileName); InitializeComponent(); this.DataContext = this; _componentModel = (IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SComponentModel)); _EditorAdapterFactory = _componentModel.GetService<IVsEditorAdaptersFactoryService>(); }
public DefaultInterpreterSetter(IPythonInterpreterFactory factory, IServiceProvider site = null) { Assert.IsNotNull(factory, "Cannot set default to null"); _model = (IComponentModel)(site ?? VSTestContext.ServiceProvider).GetService(typeof(SComponentModel)); var interpreterService = _model.GetService<IInterpreterOptionsService>(); Assert.IsNotNull(interpreterService); OriginalInterpreter = interpreterService.DefaultInterpreter; CurrentDefault = factory; interpreterService.DefaultInterpreter = factory; }
protected AbstractDebuggerIntelliSenseContext( IWpfTextView wpfTextView, IVsTextView vsTextView, IVsTextLines vsDebuggerTextLines, ITextBuffer contextBuffer, Microsoft.VisualStudio.TextManager.Interop.TextSpan[] currentStatementSpan, IComponentModel componentModel, IServiceProvider serviceProvider, IContentType contentType) { _textView = wpfTextView; _debuggerTextLines = vsDebuggerTextLines; this.ContextBuffer = contextBuffer; this.CurrentStatementSpan = currentStatementSpan[0]; _contentType = contentType; this.ProjectionBufferFactoryService = componentModel.GetService<IProjectionBufferFactoryService>(); _bufferGraphFactoryService = componentModel.GetService<IBufferGraphFactoryService>(); _isImmediateWindow = IsImmediateWindow((IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell)), vsTextView); }
public static void PrepareSolution(TestContext context) { componentModel = (IComponentModel)VsIdeTestHostContext.ServiceProvider.GetService(typeof(SComponentModel)); componentModel.GetService<TextViewListener>().ReferenceProviders = new[] { sourceRecord }; DTE.Solution.Open(Path.Combine(SolutionDir, "TestBed.sln")); fileName = Path.GetFullPath(Path.Combine(SolutionDir, "CSharp", "File.cs")); DTE.ItemOperations.OpenFile(fileName).Activate(); textView = GetCurentTextView(); System.Threading.Thread.Sleep(2500); // Wait for the language service to bind the file; this can really take 2 seconds }
public void Invoke(CancellationToken cancellationToken) { if (_virtualTextDocument == null) { return; } var codeStreamService = _componentModel?.GetService <ICodeStreamService>(); if (codeStreamService == null) { return; } ThreadHelper.JoinableTaskFactory.Run(async delegate { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); try { var toolWindowProvider = Package.GetGlobalService(typeof(SToolWindowProvider)) as IToolWindowProvider; if (!toolWindowProvider.IsVisible(Guids.WebViewToolWindowGuid)) { if (toolWindowProvider?.ShowToolWindowSafe(Guids.WebViewToolWindowGuid) == true) { } else { Log.Warning("Could not activate tool window"); } } var sessionService = _componentModel.GetService <ISessionService>(); if (sessionService.WebViewDidInitialize == true) { _ = codeStreamService.NewReviewAsync(_virtualTextDocument.Uri, "Lightbulb Menu", cancellationToken: cancellationToken); } else { var eventAggregator = _componentModel.GetService <IEventAggregator>(); IDisposable d = null; d = eventAggregator.GetEvent <WebviewDidInitializeEvent>().Subscribe(e => { try { _ = codeStreamService.NewReviewAsync(_virtualTextDocument.Uri, "Lightbulb Menu", cancellationToken: cancellationToken); d.Dispose(); } catch (Exception ex) { Log.Error(ex, $"{nameof(CreateReviewSuggestedAction)} event"); } }); } } catch (Exception ex) { Log.Error(ex, nameof(CreateReviewSuggestedAction)); } }); }
public RoslynKeyProcessor(IWpfTextView wpfTextView, IComponentModel mef) { this.wpfTextView = wpfTextView; innerCommandTarget = CreateInstanceNonPublic(oleCommandTargetType, CreateInstanceNonPublic(languageServiceType, Activator.CreateInstance(packageType, true)), // languageService wpfTextView, // wpfTextView mef.DefaultExportProvider.GetExport<object>("Microsoft.CodeAnalysis.Editor.ICommandHandlerServiceFactory").Value, // commandHandlerServiceFactory null, // featureOptionsService (not used) mef.GetService<IVsEditorAdaptersFactoryService>() // editorAdaptersFactoryService ); AddShortcuts(); }
private static IWpfTextView GetWpfTextViewFromTextView(this IServiceProvider serviceProvider, IVsTextView vsTextView) { if (vsTextView == null) { return(null); } IComponentModel componentModel = serviceProvider.GetService <SComponentModel, IComponentModel>(); IVsEditorAdaptersFactoryService vsEditorAdaptersFactoryService = componentModel?.GetService <IVsEditorAdaptersFactoryService>(); return(vsEditorAdaptersFactoryService?.GetWpfTextView(vsTextView)); }
private static async Task <IWpfTextView> GetWpfTextViewFromTextViewAsync(this Shell.IAsyncServiceProvider serviceProvider, IVsTextView vsTextView) { if (vsTextView == null) { return(null); } IComponentModel componentModel = await serviceProvider.GetServiceAsync <SComponentModel, IComponentModel>(); IVsEditorAdaptersFactoryService vsEditorAdaptersFactoryService = componentModel?.GetService <IVsEditorAdaptersFactoryService>(); return(vsEditorAdaptersFactoryService?.GetWpfTextView(vsTextView)); }
internal static async Task <VisualStudioWorkspace> GetVSWorkspaceAsync(this Shell.IAsyncServiceProvider serviceProvider) { if (serviceProvider == null) { return(null); } var service = await serviceProvider.GetServiceAsync(typeof(SComponentModel)); IComponentModel componentModel = service as IComponentModel; return(componentModel?.GetService <VisualStudioWorkspace>()); }
private void SolutionOrFolder_Loaded(object sender, EventArgs e) { var sessionService = _componentModel?.GetService <ISessionService>(); if (sessionService == null) { Log.IsNull(nameof(sessionService)); return; } if (sessionService.ProjectType == ProjectType.Solution) { Log.Debug($"About to {nameof(TryTriggerLspActivationAsync)} for {sessionService.ProjectType}..."); ThreadHelper.JoinableTaskFactory.Run(async delegate { await TryTriggerLspActivationAsync(); }); } else { Log.Debug($"Skipped {nameof(TryTriggerLspActivationAsync)} for {sessionService.ProjectType}"); } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (_packageRestoreManager != null) { NuGetUIThreadHelper.JoinableTaskFactory.RunAsync(async delegate { try { string solutionDirectory = await _solutionManager.GetSolutionDirectoryAsync(CancellationToken.None); _componentModel = await AsyncServiceProvider.GlobalProvider.GetComponentModelAsync(); _vsSolutionManager = _componentModel.GetService <IVsSolutionManager>(); _solutionRestoreWorker = _componentModel.GetService <ISolutionRestoreWorker>(); // if the project is PR and there is no restore running, check for missing assets file // otherwise check for missing packages if (await ExperimentUtility.IsTransitiveOriginExpEnabled.GetValueAsync(CancellationToken.None) && _projectContextInfo?.ProjectStyle == ProjectModel.ProjectStyle.PackageReference && _solutionRestoreWorker.IsRunning == false && await GetMissingAssetsFileStatusAsync(_projectContextInfo.ProjectId)) { _packageRestoreManager.RaiseAssetsFileMissingEventForProjectAsync(true); } else { await _packageRestoreManager.RaisePackagesMissingEventForSolutionAsync(solutionDirectory, CancellationToken.None); } } catch (Exception ex) { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); // By default, restore bar is invisible. So, in case of failure of RaisePackagesMissingEventForSolutionAsync, assume it is needed UpdateRestoreBar(packagesMissing: true); var unwrappedException = ExceptionUtility.Unwrap(ex); ShowErrorUI(unwrappedException.Message); } }).PostOnFailure(nameof(PackageRestoreBar)); } }
public ContainedLanguage( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, AbstractProject project, IVsHierarchy hierarchy, uint itemid, TLanguageService languageService, SourceCodeKind sourceCodeKind, IFormattingRule vbHelperFormattingRule = null) : base(project) { this.BufferCoordinator = bufferCoordinator; this.ComponentModel = componentModel; _languageService = languageService; this.Workspace = componentModel.GetService <VisualStudioWorkspace>(); _editorAdaptersFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>(); // Get the ITextBuffer for the secondary buffer Marshal.ThrowExceptionForHR(bufferCoordinator.GetSecondaryBuffer(out var secondaryTextLines)); var secondaryVsTextBuffer = (IVsTextBuffer)secondaryTextLines; SetSubjectBuffer(_editorAdaptersFactoryService.GetDocumentBuffer(secondaryVsTextBuffer)); var bufferTagAggregatorFactory = ComponentModel.GetService <IBufferTagAggregatorFactoryService>(); _bufferTagAggregator = bufferTagAggregatorFactory.CreateTagAggregator <ITag>(SubjectBuffer); Marshal.ThrowExceptionForHR(bufferCoordinator.GetPrimaryBuffer(out var primaryTextLines)); var primaryVsTextBuffer = (IVsTextBuffer)primaryTextLines; var dataBuffer = _editorAdaptersFactoryService.GetDataBuffer(primaryVsTextBuffer); SetDataBuffer(dataBuffer); this.ContainedDocument = new ContainedDocument( this, sourceCodeKind, this.Workspace, hierarchy, itemid, componentModel, vbHelperFormattingRule); // TODO: Can contained documents be linked or shared? this.Project.AddDocument(this.ContainedDocument, isCurrentContext: true, hookupHandlers: true); }
/// <summary> /// Gets whether the client scrip generator package is installed for the given project /// </summary> /// <param name="proj">The project to check</param> /// <returns>True if installed</returns> public static bool IsPackageInstalled(EnvDTE.Project proj) { IComponentModel componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel)); IVsPackageInstallerServices installerServices = componentModel.GetService <IVsPackageInstallerServices>(); try { return(installerServices.IsPackageInstalled(proj, TypeRightPackage.NugetID)); } catch (Exception) { return(false); } }
public void UpdatePreview(string text) { var service = VisualStudioMefHostServices.Create(_componentModel.GetService <ExportProvider>()); var workspace = new PreviewWorkspace(service); var fileName = "project." + (Language == "C#" ? "csproj" : "vbproj"); var project = workspace.CurrentSolution.AddProject(fileName, "assembly.dll", Language); // use the mscorlib, system, and system.core that are loaded in the current process. string[] references = { "mscorlib", "System", "System.Core" }; var metadataService = workspace.Services.GetService <IMetadataService>(); var referenceAssemblies = Thread.GetDomain().GetAssemblies() .Where(x => references.Contains(x.GetName(true).Name, StringComparer.OrdinalIgnoreCase)) .Select(a => metadataService.GetReference(a.Location, MetadataReferenceProperties.Assembly)); project = project.WithMetadataReferences(referenceAssemblies); var document = project.AddDocument("document", SourceText.From(text, Encoding.UTF8)); var formatted = Formatter.FormatAsync(document, OptionStore.GetOptions()).WaitAndGetResult(CancellationToken.None); var textBuffer = _textBufferFactoryService.CreateTextBuffer(formatted.GetTextSynchronously(CancellationToken.None).ToString(), _contentType); var container = textBuffer.AsTextContainer(); var projection = _projectionBufferFactory.CreateProjectionBufferWithoutIndentation(_contentTypeRegistryService, _editorOptions.CreateOptions(), textBuffer.CurrentSnapshot, separator: "", exposedLineSpans: GetExposedLineSpans(textBuffer.CurrentSnapshot).ToArray()); var textView = _textEditorFactoryService.CreateTextView(projection, _textEditorFactoryService.CreateTextViewRoleSet(PredefinedTextViewRoles.Interactive)); this.TextViewHost = _textEditorFactoryService.CreateTextViewHost(textView, setFocus: false); workspace.TryApplyChanges(document.Project.Solution); workspace.OpenDocument(document.Id, container); this.TextViewHost.Closed += (s, a) => { workspace.Dispose(); workspace = null; }; }
/// <summary> /// Adds the Nuget Package reference /// </summary> /// <param name="packageID">Package Id as hosted in NuGet.</param> /// <param name="project">Project to which the operation has to be performed.</param> /// <param name="repositoryPath">Repository path.</param> internal static void InstallNuGetPackageForProject(string packageID, Project project, string repositoryPath) { try { IComponentModel componentModel = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SComponentModel)) as IComponentModel; var installer = componentModel.GetService <IVsPackageInstaller>(); Version ver = null; installer.InstallPackage(repositoryPath, project, packageID, ver, false); } catch (Exception ex) { MessageBox.Show(IntuitAnywhereResources.msg005, IntuitAnywhereResources.msgdialogtitle); } }
internal VsResetInteractive( DTE dte, IComponentModel componentModel, IVsMonitorSelection monitorSelection, IVsSolutionBuildManager buildManager, Func<string, string> createReference, Func<string, string> createImport) : base(componentModel.GetService<IEditorOptionsFactoryService>(), createReference, createImport) { _dte = dte; _componentModel = componentModel; _monitorSelection = monitorSelection; _buildManager = buildManager; }
internal void Execute(IVsInteractiveWindow vsInteractiveWindow, string title) { var hierarchyPointer = default(IntPtr); var selectionContainerPointer = default(IntPtr); try { uint itemid; IVsMultiItemSelect multiItemSelectPointer; Marshal.ThrowExceptionForHR(_monitorSelection.GetCurrentSelection( out hierarchyPointer, out itemid, out multiItemSelectPointer, out selectionContainerPointer)); if (hierarchyPointer != IntPtr.Zero) { List <string> references, referenceSearchPaths, sourceSearchPaths, namespacesToImport; string projectDirectory; GetProjectProperties(hierarchyPointer, out references, out referenceSearchPaths, out sourceSearchPaths, out namespacesToImport, out projectDirectory); // Now, we're going to do a bunch of async operations. So create a wait // indicator so the user knows something is happening, and also so they cancel. var waitIndicator = _componentModel.GetService <IWaitIndicator>(); var waitContext = waitIndicator.StartWait(title, ServicesVSResources.BuildingProject, allowCancel: true); var resetInteractiveTask = ResetInteractiveAsync( vsInteractiveWindow, references.ToImmutableArray(), referenceSearchPaths.ToImmutableArray(), sourceSearchPaths.ToImmutableArray(), namespacesToImport.ToImmutableArray(), projectDirectory, waitContext); // Once we're done resetting, dismiss the wait indicator and focus the REPL window. resetInteractiveTask.SafeContinueWith( _ => { waitContext.Dispose(); // We have to set focus to the Interactive Window *after* the wait indicator is dismissed. vsInteractiveWindow.Show(focus: true); }, TaskScheduler.FromCurrentSynchronizationContext()); } } finally { SafeRelease(hierarchyPointer); SafeRelease(selectionContainerPointer); } }
internal VsResetInteractive( DTE dte, IComponentModel componentModel, IVsMonitorSelection monitorSelection, IVsSolutionBuildManager buildManager, Func <string, string> createReference, Func <string, string> createImport) : base(componentModel.GetService <IEditorOptionsFactoryService>(), createReference, createImport) { _dte = dte; _componentModel = componentModel; _monitorSelection = monitorSelection; _buildManager = buildManager; }
// Test constructor internal CSharpDebuggerIntelliSenseContext( IWpfTextView view, ITextBuffer contextBuffer, TextSpan[] currentStatementSpan, IComponentModel componentModel, bool immediateWindow) : base(view, contextBuffer, currentStatementSpan, componentModel, componentModel.GetService <IContentTypeRegistryService>().GetContentType(ContentTypeNames.CSharpContentType), immediateWindow) { }
// Test constructor internal CSharpDebuggerIntelliSenseContext( IWpfTextView view, ITextBuffer contextBuffer, TextSpan[] currentStatementSpan, IComponentModel componentModel, bool immediateWindow) : base(view, contextBuffer, currentStatementSpan, componentModel, componentModel.GetService<IContentTypeRegistryService>().GetContentType(ContentTypeNames.CSharpContentType), immediateWindow) { }
private void InitializeEditor() { IComponentModel m_componentModel = (IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SComponentModel)); oleServiceProvider = (IOleServiceProvider)GetService(typeof(IOleServiceProvider)); bufferFactory = m_componentModel.GetService <ITextBufferFactoryService>(); m_EditorAdapterFactory = m_componentModel.GetService <IVsEditorAdaptersFactoryService>(); bufferAdapter = m_EditorAdapterFactory.CreateVsTextBufferAdapter(oleServiceProvider, bufferFactory.TextContentType); int result = bufferAdapter.InitializeContent("ed", 2); viewAdapter = m_EditorAdapterFactory.CreateVsTextViewAdapter(oleServiceProvider); ((IVsWindowPane)viewAdapter).SetSite(oleServiceProvider); INITVIEW[] _initView = new INITVIEW[] { new INITVIEW() }; _initView[0].fSelectionMargin = 0; _initView[0].fWidgetMargin = 0; _initView[0].fVirtualSpace = 0; _initView[0].fDragDropMove = 1; _initView[0].fVirtualSpace = 0; viewAdapter.Initialize(bufferAdapter as IVsTextLines, IntPtr.Zero, (uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags3.VIF_NO_HWND_SUPPORT, _initView); }
private void InitializeColors() { // Use VS color keys in order to support theming. CodeAnalysisColors.SystemCaptionTextColorKey = EnvironmentColors.SystemWindowTextColorKey; CodeAnalysisColors.SystemCaptionTextBrushKey = EnvironmentColors.SystemWindowTextBrushKey; CodeAnalysisColors.CheckBoxTextBrushKey = EnvironmentColors.SystemWindowTextBrushKey; CodeAnalysisColors.BackgroundBrushKey = VsBrushes.CommandBarGradientBeginKey; CodeAnalysisColors.ButtonStyleKey = VsResourceKeys.ButtonStyleKey; CodeAnalysisColors.AccentBarColorKey = EnvironmentColors.FileTabInactiveDocumentBorderEdgeBrushKey; // Initialize ColorScheme support _colorSchemeApplier = _componentModel.GetService <ColorSchemeApplier>(); _colorSchemeApplier.Initialize(); }
protected AbstractDebuggerIntelliSenseContext( IWpfTextView wpfTextView, IVsTextView vsTextView, IVsTextLines vsDebuggerTextLines, ITextBuffer contextBuffer, Microsoft.VisualStudio.TextManager.Interop.TextSpan[] currentStatementSpan, IComponentModel componentModel, IServiceProvider serviceProvider, IContentType contentType) { _textView = wpfTextView; _debuggerTextLines = vsDebuggerTextLines; this.ContextBuffer = contextBuffer; this.CurrentStatementSpan = currentStatementSpan[0]; _contentType = contentType; this.ProjectionBufferFactoryService = componentModel.GetService <IProjectionBufferFactoryService>(); _bufferGraphFactoryService = componentModel.GetService <IBufferGraphFactoryService>(); var _editorAdaptersFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>(); _isImmediateWindow = vsTextView.IsImmediateWindow( (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell)), _editorAdaptersFactoryService); }
private void PrimeLanguageServiceComponentsOnBackground(IComponentModel componentModel) { var commandHandlerServiceFactory = componentModel.GetService <ICommandHandlerServiceFactory>(); commandHandlerServiceFactory.Initialize(this.ContentTypeName); var formatter = this.Workspace.Services.GetLanguageServices(ShaderToolsLanguageName).GetService <ISyntaxFormattingService>(); if (formatter != null) { // TODO //formatter.GetDefaultFormattingRules(); } }
protected async System.Threading.Tasks.Task OnServerInitializedBaseAsync(JsonRpc rpc, IComponentModel componentModel) { try { Log.Debug($"{nameof(OnServerInitializedBaseAsync)} starting..."); var codeStreamAgentService = componentModel.GetService <ICodeStreamAgentService>(); await codeStreamAgentService.SetRpcAsync(rpc); bool autoSignInResult = false; try { Log.Debug($"TryAutoSignInAsync starting..."); var authenticationController = new AuthenticationController( SettingsServiceFactory.GetOrCreate(), componentModel.GetService <ISessionService>(), codeStreamAgentService, EventAggregator, componentModel.GetService <ICredentialsService>(), componentModel.GetService <IWebviewUserSettingsService>() ); autoSignInResult = await authenticationController.TryAutoSignInAsync(); } catch (Exception ex) { Log.Error(ex, nameof(OnServerInitializedBaseAsync)); } Log.Information($"AutoSignIn Result={autoSignInResult}"); Log.Debug($"Publishing {nameof(LanguageServerReadyEvent)}..."); EventAggregator.Publish(new LanguageServerReadyEvent { IsReady = true }); Log.Debug($"Published {nameof(LanguageServerReadyEvent)}"); } catch (Exception ex) { Log.Fatal(ex, nameof(OnServerInitializedBaseAsync)); throw; } }
public async Task CSharpMetadataTest() { // Hop on to the UI thread so the language service APIs work await Application.Current.Dispatcher.NextFrame(DispatcherPriority.ApplicationIdle); // Use a type that is not in the public reference source textView.Caret.MoveTo(textView.FindSpan("System.IO.Log.LogStore").End); GetCurrentNativeTextView().Execute(VSConstants.VSStd97CmdID.GotoDefn); var metadataTextView = GetCurentTextView(); var docService = componentModel.GetService <ITextDocumentFactoryService>(); ITextDocument document; Assert.IsTrue(docService.TryGetTextDocument(metadataTextView.TextDataModel.DocumentBuffer, out document)); if (!RoslynUtilities.IsRoslynInstalled(VsIdeTestHostContext.ServiceProvider)) { var symbol = new CSharp10Resolver(DTE).GetSymbolAt(document.FilePath, metadataTextView.FindSpan("public LogStore(SafeFileHandle").End); Assert.IsNull(symbol); // CSharp10Resolver cannot get a Compilation for metadata as source, but must not crash. } ISymbolResolver resolver = null; if (RoslynUtilities.IsRoslynInstalled(VsIdeTestHostContext.ServiceProvider)) { resolver = new RoslynSymbolResolver(); } else if (DTE.Version == "12.0") { resolver = new CSharp12Resolver(); } if (resolver == null) { var symbol = resolver.GetSymbolAt(document.FilePath, metadataTextView.FindSpan("public LogStore(SafeFileHandle").End); Assert.IsFalse(symbol.HasLocalSource); Assert.AreEqual("mscorlib", symbol.AssemblyName); Assert.AreEqual("T:Microsoft.Win32.SafeHandles.SafeFileHandle", symbol.IndexId); } }
public int OnLoadCompleted(int fReload) { _cp.Unadvise(_cookie); var adapterService = _compModel.GetService <IVsEditorAdaptersFactoryService>(); ITextBuffer diskBuffer = adapterService.GetDocumentBuffer(_textLines); var contentRegistry = _compModel.GetService <IContentTypeRegistryService>(); var factService = _compModel.GetService <IProjectionBufferFactoryService>(); IContentType contentType = SniffContentType(diskBuffer) ?? contentRegistry.GetContentType("HTML"); var projBuffer = new TemplateProjectionBuffer(contentRegistry, factService, diskBuffer, _compModel.GetService <IBufferGraphFactoryService>(), contentType); diskBuffer.ChangedHighPriority += projBuffer.DiskBufferChanged; diskBuffer.Properties.AddProperty(typeof(TemplateProjectionBuffer), projBuffer); Guid langSvcGuid = typeof(DjangoLanguageInfo).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); }
internal VsInteractiveWindow( IComponentModel model, Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator, __VSCREATETOOLWIN creationFlags, Guid toolbarCommandSet, uint toolbarId, IOleCommandTarget toolbarCommandTarget) { _componentModel = model; this.Caption = title; _editorAdapters = _componentModel.GetService <IVsEditorAdaptersFactoryService>(); _evaluator = evaluator; _toolbarCommandSet = toolbarCommandSet; _toolbarCommandTarget = toolbarCommandTarget; _toolbarId = toolbarId; // The following calls this.OnCreate: Guid clsId = this.ToolClsid; Guid empty = Guid.Empty; Guid typeId = providerId; IVsWindowFrame frame; var vsShell = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)); // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are // destroyed when closed. We are really multi instance but we don't want to be closed. ErrorHandler.ThrowOnFailure( vsShell.CreateToolWindow( (uint)(__VSCREATETOOLWIN.CTW_fInitNew | __VSCREATETOOLWIN.CTW_fToolbarHost | creationFlags), (uint)instanceId, this.GetIVsWindowPane(), ref clsId, ref typeId, ref empty, null, title, null, out frame ) ); var guid = GetType().GUID; ErrorHandler.ThrowOnFailure(frame.SetGuidProperty((int)__VSFPROPID.VSFPROPID_CmdUIGuid, ref guid)); this.Frame = frame; }
public static ReplEditFilter GetOrCreate( IServiceProvider serviceProvider, IComponentModel componentModel, IVsTextView vsTextView, IOleCommandTarget next = null ) { var editorFactory = componentModel.GetService <IVsEditorAdaptersFactoryService>(); var opsFactory = componentModel.GetService <IEditorOperationsFactoryService>(); var textView = editorFactory.GetWpfTextView(vsTextView); if (textView.TextBuffer.GetInteractiveWindow() == null) { return(null); } return(textView.Properties.GetOrCreateSingletonProperty(() => new ReplEditFilter( vsTextView, textView, opsFactory.GetEditorOperations(textView), serviceProvider, next ))); }
private void CreateHostedEditor() { //Get the component model so we can request the editor adapter factory which we can use to spin up an editor instance. IComponentModel componentModel = (IComponentModel)ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel)); IContentTypeRegistryService contentTypeRegistry = componentModel.GetService <IContentTypeRegistryService>(); IContentType contentType = contentTypeRegistry.GetContentType("CSharp"); IVsEditorAdaptersFactoryService editorAdapterFactory = componentModel.GetService <IVsEditorAdaptersFactoryService>(); this.textBuffer = editorAdapterFactory.CreateVsTextBufferAdapter(OleServiceProvider); Guid CSharpLanguageService = new Guid("{694DD9B6-B865-4C5B-AD85-86356E9C88DC}"); ErrorHandler.ThrowOnFailure(textBuffer.SetLanguageServiceID(ref CSharpLanguageService)); string initialContents = String.Format("using System;{0}{0}namespace Lazers{0}{{{0}{1}public class Awesome{0}{1}{{{0}{1}}}{0}}}", Environment.NewLine, " "); ErrorHandler.ThrowOnFailure(textBuffer.InitializeContent(initialContents, initialContents.Length)); //Disable the splitter due to a crashing bug if we don't :( this.codeWindow = editorAdapterFactory.CreateVsCodeWindowAdapter(OleServiceProvider); ((IVsCodeWindowEx)this.codeWindow).Initialize((uint)_codewindowbehaviorflags.CWB_DISABLESPLITTER, VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Filter, "", "", 0, new INITVIEW[1]); this.codeWindow.SetBuffer((IVsTextLines)this.textBuffer); ErrorHandler.ThrowOnFailure(this.codeWindow.GetPrimaryView(out this.textView)); this.textViewHost = editorAdapterFactory.GetWpfTextViewHost(this.textView); this.Content = textViewHost.HostControl; this.editorCommandTarget = (IOleCommandTarget)this.textView; }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { var dialog = new OpenFileDialog(); dialog.Title = "Choose .csproj file to run detection on"; dialog.Filter = "Project files|*.csproj"; if (dialog.ShowDialog() == true) { IComponentModel componentModel = (IComponentModel)this.ServiceProvider.GetService(typeof(SComponentModel)); var frameworkPickerService = componentModel.GetService <IFrameworkPickerService>(); MessageBox.Show("Test framework: " + frameworkPickerService.FindTestFramework(dialog.FileName) + Environment.NewLine + "Mock framework: " + frameworkPickerService.FindMockFramework(dialog.FileName)); } }
public ContainedDocument( AbstractContainedLanguage containedLanguage, SourceCodeKind sourceCodeKind, Workspace workspace, IVsHierarchy hierarchy, uint itemId, IComponentModel componentModel, IFormattingRule vbHelperFormattingRule) { Contract.ThrowIfNull(containedLanguage); _containedLanguage = containedLanguage; _sourceCodeKind = sourceCodeKind; _componentModel = componentModel; _workspace = workspace; _optionService = _workspace.Services.GetService <IOptionService>(); _hostType = GetHostType(); var rdt = (IVsRunningDocumentTable)componentModel.GetService <SVsServiceProvider>().GetService(typeof(SVsRunningDocumentTable)); var filePath = rdt.GetMonikerForHierarchyAndItemId(hierarchy, itemId); if (Project.Hierarchy != null) { string moniker; Project.Hierarchy.GetCanonicalName(itemId, out moniker); _itemMoniker = moniker; } this.Key = new DocumentKey(Project, filePath); this.Id = DocumentId.CreateNewId(Project.Id, filePath); this.Folders = containedLanguage.Project.GetFolderNames(itemId); this.Loader = TextLoader.From(containedLanguage.SubjectBuffer.AsTextContainer(), VersionStamp.Create(), filePath); _differenceSelectorService = componentModel.GetService <ITextDifferencingSelectorService>(); _snapshotTracker = new ReiteratedVersionSnapshotTracker(_containedLanguage.SubjectBuffer); _vbHelperFormattingRule = vbHelperFormattingRule; }
public VSTypeScriptContainedLanguageWrapper( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, VSTypeScriptVisualStudioProjectWrapper project, Guid languageServiceGuid) { _underlyingObject = new ContainedLanguage( bufferCoordinator, componentModel, componentModel.GetService <VisualStudioWorkspace>(), project.Project.Id, project.Project, languageServiceGuid, vbHelperFormattingRule: null); }
public CSharpDebuggerIntelliSenseContext( IWpfTextView view, IVsTextView vsTextView, IVsTextLines debuggerBuffer, ITextBuffer contextBuffer, TextSpan[] currentStatementSpan, IComponentModel componentModel, IServiceProvider serviceProvider) : base(view, vsTextView, debuggerBuffer, contextBuffer, currentStatementSpan, componentModel, serviceProvider, componentModel.GetService<IContentTypeRegistryService>().GetContentType(ContentTypeNames.CSharpContentType)) { }
public ContainedDocument( AbstractContainedLanguage containedLanguage, SourceCodeKind sourceCodeKind, Workspace workspace, IVsHierarchy hierarchy, uint itemId, IComponentModel componentModel, IFormattingRule vbHelperFormattingRule) { Contract.ThrowIfNull(containedLanguage); _containedLanguage = containedLanguage; _sourceCodeKind = sourceCodeKind; _componentModel = componentModel; _workspace = workspace; _optionService = _workspace.Services.GetService<IOptionService>(); _hostType = GetHostType(); string filePath; if (!ErrorHandler.Succeeded(((IVsProject)hierarchy).GetMkDocument(itemId, out filePath))) { // we couldn't look up the document moniker from an hierarchy for an itemid. // Since we only use this moniker as a key, we could fall back to something else, like the document name. Debug.Assert(false, "Could not get the document moniker for an item from its hierarchy."); if (!hierarchy.TryGetItemName(itemId, out filePath)) { Environment.FailFast("Failed to get document moniker for a contained document"); } } if (Project.Hierarchy != null) { string moniker; Project.Hierarchy.GetCanonicalName(itemId, out moniker); _itemMoniker = moniker; } this.Key = new DocumentKey(Project, filePath); this.Id = DocumentId.CreateNewId(Project.Id, filePath); this.Folders = containedLanguage.Project.GetFolderNames(itemId); this.Loader = TextLoader.From(containedLanguage.SubjectBuffer.AsTextContainer(), VersionStamp.Create(), filePath); _differenceSelectorService = componentModel.GetService<ITextDifferencingSelectorService>(); _snapshotTracker = new ReiteratedVersionSnapshotTracker(_containedLanguage.SubjectBuffer); _vbHelperFormattingRule = vbHelperFormattingRule; }
/// <summary> /// Sets the default font size to match that of a normal editor buffer. /// </summary> private void SetDefaultFontSize(IComponentModel model, IWpfTextView textView) { var formatMapSvc = model.GetService<IClassificationFormatMapService>(); var fontsAndColorsSvc = model.GetService<IVsFontsAndColorsInformationService>(); var fontCat = new VisualStudio.Editor.FontsAndColorsCategory( _langSvcGuid, Microsoft.VisualStudio.Editor.DefGuidList.guidTextEditorFontCategory, Microsoft.VisualStudio.Editor.DefGuidList.guidTextEditorFontCategory ); var fontInfo = fontsAndColorsSvc.GetFontAndColorInformation(fontCat); var fontPrefs = fontInfo.GetFontAndColorPreferences(); var font = System.Drawing.Font.FromHfont(fontPrefs.hRegularViewFont); var classMap = formatMapSvc.GetClassificationFormatMap(textView); var defaultProps = classMap.DefaultTextProperties; defaultProps = defaultProps.SetFontRenderingEmSize(font.Size); classMap.DefaultTextProperties = defaultProps; }
internal bool CreateFromRegistry(IComponentModel model, int id) { string contentTypeName, title, replId, languageServiceId; using (var root = GetRegistryRoot()) { if (root == null) { return false; } using (var replInfo = root.OpenSubKey(id.ToString())) { if (replInfo == null) { return false; } contentTypeName = replInfo.GetValue(ContentTypeKey) as string; if (contentTypeName == null) { return false; } title = replInfo.GetValue(TitleKey) as string; if (title == null) { return false; } replId = replInfo.GetValue(ReplIdKey) as string; if (replId == null) { return false; } languageServiceId = replInfo.GetValue(LanguageServiceGuidKey) as string; if (languageServiceId == null) { return false; } } } Guid languageServiceGuid; if (!Guid.TryParse(languageServiceId, out languageServiceGuid)) { return false; } var contentTypes = model.GetService<IContentTypeRegistryService>(); var contentType = contentTypes.GetContentType(contentTypeName); if (contentType == null) { return false; } string[] roles; var evaluator = GetInteractiveEvaluator(model, replId, out roles); if (evaluator == null) { return false; } CreateInteractiveWindow(evaluator, contentType, roles, id, title, languageServiceGuid, replId); return true; }
public ContainedDocument( AbstractContainedLanguage containedLanguage, SourceCodeKind sourceCodeKind, Workspace workspace, IVsHierarchy hierarchy, uint itemId, IComponentModel componentModel, IFormattingRule vbHelperFormattingRule) { Contract.ThrowIfNull(containedLanguage); _containedLanguage = containedLanguage; _sourceCodeKind = sourceCodeKind; _componentModel = componentModel; _workspace = workspace; _optionService = _workspace.Services.GetService<IOptionService>(); _hostType = GetHostType(); var rdt = (IVsRunningDocumentTable)componentModel.GetService<SVsServiceProvider>().GetService(typeof(SVsRunningDocumentTable)); var filePath = rdt.GetMonikerForHierarchyAndItemId(hierarchy, itemId); if (Project.Hierarchy != null) { string moniker; Project.Hierarchy.GetCanonicalName(itemId, out moniker); _itemMoniker = moniker; } this.Key = new DocumentKey(Project, filePath); this.Id = DocumentId.CreateNewId(Project.Id, filePath); this.Folders = containedLanguage.Project.GetFolderNames(itemId); this.Loader = TextLoader.From(containedLanguage.SubjectBuffer.AsTextContainer(), VersionStamp.Create(), filePath); _differenceSelectorService = componentModel.GetService<ITextDifferencingSelectorService>(); _snapshotTracker = new ReiteratedVersionSnapshotTracker(_containedLanguage.SubjectBuffer); _vbHelperFormattingRule = vbHelperFormattingRule; }
public static ReplEditFilter GetOrCreate( IServiceProvider serviceProvider, IComponentModel componentModel, ITextView textView, IOleCommandTarget next = null ) { var editorFactory = componentModel.GetService<IVsEditorAdaptersFactoryService>(); var opsFactory = componentModel.GetService<IEditorOperationsFactoryService>(); var vsTextView = editorFactory.GetViewAdapter(textView); if (textView.TextBuffer.GetInteractiveWindow() == null) { return null; } return textView.Properties.GetOrCreateSingletonProperty(() => new ReplEditFilter( vsTextView, textView, opsFactory.GetEditorOperations(textView), serviceProvider, next )); }
public ContainedDocument( AbstractContainedLanguage containedLanguage, SourceCodeKind sourceCodeKind, Workspace workspace, IVsHierarchy hierarchy, uint itemId, IComponentModel componentModel, IFormattingRule vbHelperFormattingRule) { Contract.ThrowIfNull(containedLanguage); _containedLanguage = containedLanguage; _sourceCodeKind = sourceCodeKind; _componentModel = componentModel; _workspace = workspace; _optionService = _workspace.Services.GetService<IOptionService>(); _hostType = GetHostType(); var rdt = (IVsRunningDocumentTable)componentModel.GetService<SVsServiceProvider>().GetService(typeof(SVsRunningDocumentTable)); IVsHierarchy sharedHierarchy; uint itemIdInSharedHierarchy; var isSharedHierarchy = LinkedFileUtilities.TryGetSharedHierarchyAndItemId(hierarchy, itemId, out sharedHierarchy, out itemIdInSharedHierarchy); var filePath = isSharedHierarchy ? rdt.GetMonikerForHierarchyAndItemId(sharedHierarchy, itemIdInSharedHierarchy) : rdt.GetMonikerForHierarchyAndItemId(hierarchy, itemId); // we couldn't look up the document moniker in RDT for a hierarchy/item pair // Since we only use this moniker as a key, we could fall back to something else, like the document name. if (filePath == null) { Debug.Assert(false, "Could not get the document moniker for an item in its hierarchy."); filePath = hierarchy.GetDocumentNameForHierarchyAndItemId(itemId); } if (Project.Hierarchy != null) { string moniker; Project.Hierarchy.GetCanonicalName(itemId, out moniker); _itemMoniker = moniker; } this.Key = new DocumentKey(Project, filePath); this.Id = DocumentId.CreateNewId(Project.Id, filePath); this.Folders = containedLanguage.Project.GetFolderNames(itemId); this.Loader = TextLoader.From(containedLanguage.SubjectBuffer.AsTextContainer(), VersionStamp.Create(), filePath); _differenceSelectorService = componentModel.GetService<ITextDifferencingSelectorService>(); _snapshotTracker = new ReiteratedVersionSnapshotTracker(_containedLanguage.SubjectBuffer); _vbHelperFormattingRule = vbHelperFormattingRule; }
private void InstallIlMerge(IComponentModel componentModel) { try { var installer = componentModel.GetService<IVsPackageInstaller>(); _dte.StatusBar.Text = @"Installing MSBuild.ILMerge.Task..."; installer.InstallPackage("http://packages.nuget.org", _selectedProject, "MSBuild.ILMerge.Task", (Version)null, false); _dte.StatusBar.Clear(); SetIlMergeTooltip(true); _isIlMergeInstalled = true; } catch (Exception ex) { MessageBox.Show("Error installing MSBuild.ILMerge.Task" + Environment.NewLine + Environment.NewLine + ex.Message); } }
private void UninstallIlMerge(IComponentModel componentModel) { try { var uninstaller = componentModel.GetService<IVsPackageUninstaller>(); _dte.StatusBar.Text = @"Uninstalling MSBuild.ILMerge.Task..."; uninstaller.UninstallPackage(_selectedProject, "MSBuild.ILMerge.Task", true); _dte.StatusBar.Clear(); SetIlMergeTooltip(false); _isIlMergeInstalled = false; } catch (Exception ex) { MessageBox.Show("Error uninstalling MSBuild.ILMerge.Task" + Environment.NewLine + Environment.NewLine + ex.Message); } }