void IWpfTextViewConnectionListener.SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { lock (s_gate) { // only add roslyn type to tracking map foreach (var buffer in subjectBuffers.Where(b => b.ContentType.IsOfType(ContentTypeNames.RoslynContentType))) { HashSet<IWpfTextView> set; if (!s_map.TryGetValue(buffer, out set)) { set = new HashSet<IWpfTextView>(); s_map.Add(buffer, set); } set.Add(textView); DebugRegisterView_NoLock(textView); } } var handlers = this.SubjectBuffersConnected; if (handlers != null) { handlers(this, new SubjectBuffersConnectedEventArgs(textView, subjectBuffers.ToReadOnlyCollection())); } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (!subjectBuffers.Any(b => b.ContentType.IsOfType(CssContentTypeDefinition.CssContentType))) return; var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView); if (textViewAdapter == null) return; textView.Properties.GetOrCreateSingletonProperty<CssSortProperties>(() => new CssSortProperties(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<CssExtractToFile>(() => new CssExtractToFile(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<CssAddMissingStandard>(() => new CssAddMissingStandard(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<CssAddMissingVendor>(() => new CssAddMissingVendor(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<CssRemoveDuplicates>(() => new CssRemoveDuplicates(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<MinifySelection>(() => new MinifySelection(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<CssFindReferences>(() => new CssFindReferences(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<F1Help>(() => new F1Help(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<CssSelectBrowsers>(() => new CssSelectBrowsers(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<RetriggerTarget>(() => new RetriggerTarget(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<ArrowsCommandTarget>(() => new ArrowsCommandTarget(textViewAdapter, textView)); uint cssFormatProperties; ErrorHandler.ThrowOnFailure(EditorExtensionsPackage.PriorityCommandTarget.RegisterPriorityCommandTarget(0, new CssFormatProperties(textView), out cssFormatProperties)); textView.Closed += delegate { ErrorHandler.ThrowOnFailure(EditorExtensionsPackage.PriorityCommandTarget.UnregisterPriorityCommandTarget(cssFormatProperties)); }; }
public async void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (textView.Properties.ContainsProperty("TsCommandFilter")) return; if (!subjectBuffers.Any(b => b.ContentType.IsOfType("TypeScript"))) return; var adapter = EditorAdaptersFactoryService.GetViewAdapter(textView); var filter = textView.Properties.GetOrCreateSingletonProperty<TsCommandFilter>("TsCommandFilter", () => new TsCommandFilter(textView, CompletionBroker, _standardClassifications)); int tries = 0; // Ugly ugly hack // Keep trying to register our filter until after the JSLS CommandFilter // is added so we can catch completion before JSLS swallows all of them. // To confirm this, click Debug, New Breakpoint, Break at Function, type // Microsoft.VisualStudio.JSLS.TextView.TextView.CreateCommandFilter, // then make sure that our last filter is added after that runs. while (true) { IOleCommandTarget next; adapter.AddCommandFilter(filter, out next); filter.Next = next; if (IsJSLSInstalled(next) || ++tries > 10) return; await Task.Delay(500); adapter.RemoveCommandFilter(filter); // Remove the too-early filter and try again. } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (reason != ConnectionReason.TextViewLifetime) return; instants.Add (textView, new InstantVisualStudio (textView, this.documentService)); }
public async void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (textView.Properties.ContainsProperty("JsCommandFilter")) return; if (!subjectBuffers.Any(b => b.ContentType.IsOfType("JavaScript"))) return; var adapter = EditorAdaptersFactoryService.GetViewAdapter(textView); var filter = textView.Properties.GetOrCreateSingletonProperty("JsCommandFilter", () => new JsCommandFilter(textView, CompletionBroker, _standardClassifications)); int tries = 0; while (true) { IOleCommandTarget next; adapter.AddCommandFilter(filter, out next); filter.Next = next; if (IsJSLSInstalled(next) || ++tries > 10) return; await Task.Delay(500); adapter.RemoveCommandFilter(filter); // Remove the too-early filter and try again. } }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { foreach (var buffer in subjectBuffers) { foreach (var document in buffer.GetRelatedDocuments()) { buffer.GetWorkspace().CloseDocument(document.Id); } } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { if (textView.IsClosed) { return; } GetTextViewState(textView).SubjectBuffersConnected(reason, subjectBuffers); }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { foreach (ITextBuffer buffer in subjectBuffers) { CssEditorDocument doc = CssEditorDocument.FromTextBuffer(buffer); doc.Tree.TreeUpdated -= Tree_TreeUpdated; } }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { foreach (ITextBuffer buffer in subjectBuffers) { CssEditorDocument doc = CssEditorDocument.FromTextBuffer(buffer); doc.Tree.ItemsChanged -= Tree_ItemsChanged; } }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (textView.Properties.ContainsProperty("HandlebarsCompilationNotifier")) { ICompilationNotifier provider = textView.Properties.GetProperty<ICompilationNotifier>("HandlebarsCompilationNotifier"); provider.Dispose(); } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { if (reason != ConnectionReason.TextViewLifetime) { return; } instants.Add(textView, new InstantVisualStudio(textView, this.documentService)); }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (reason != ConnectionReason.TextViewLifetime) return; InstantVisualStudio instant; if (this.instants.TryGetValue (textView, out instant)) instant.Dispose(); }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { var actions = _textViews[textView]; _textViews.Remove(textView); foreach(var action in actions) { action(textView); } }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { if (textView.Properties.ContainsProperty("HandlebarsCompilationNotifier")) { ICompilationNotifier provider = textView.Properties.GetProperty <ICompilationNotifier>("HandlebarsCompilationNotifier"); provider.Dispose(); } }
void IWpfTextViewConnectionListener.SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (!_initialized) { AssertIsForeground(); CreateServicesOnUIThread(_componentModel, _languageName); _initialized = true; } }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { foreach (var buffer in subjectBuffers.Where(b => b.ContentType.IsOfType("css"))) { CssTreeWatcher watcher; if (buffer.Properties.TryGetProperty(typeof(CssTreeWatcher), out watcher)) watcher.Tree = null; } }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { foreach (var buffer in subjectBuffers) { foreach (var document in buffer.GetRelatedDocuments()) { buffer.GetWorkspace().CloseDocument(document.Id); } } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document)) { textView.Properties.GetOrCreateSingletonProperty("HandlebarsCompilationNotifier", () => Mef.GetImport<ICompilationNotifierProvider>(ContentTypeManager.GetContentType("Handlebars")) .GetCompilationNotifier(document)); } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (!textView.TextBuffer.ContentType.IsOfType(RContentTypeDefinition.ContentType)) { return; } VsAppShell.Current.DispatchOnUIThread(() => { var debugger = VsAppShell.Current.GetGlobalService<IVsDebugger>(); DataTipTextViewFilter.GetOrCreate(textView, _adaptersFactoryService, debugger); }); }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (subjectBuffers.Any(b => b.ContentType.IsOfType(LiveScriptContentTypeDefinition.LiveScriptContentType))) return; var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView); textView.Properties.GetOrCreateSingletonProperty(() => new EnterIndentation(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty(() => new CommentCommandTarget(textViewAdapter, textView, "#")); }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { foreach (ITextBuffer buffer in subjectBuffers) { CssEditorDocument doc = CssEditorDocument.FromTextBuffer(buffer); doc.Tree.ItemsChanged += (sender, e) => { ItemsChanged(buffer, e); }; doc.Tree.TreeUpdated += Tree_TreeUpdated; InitializeCache(doc.Tree.StyleSheet); } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { foreach (ITextBuffer buffer in subjectBuffers) { CssEditorDocument doc = CssEditorDocument.FromTextBuffer(buffer); doc.Tree.ItemsChanged += Tree_ItemsChanged; doc.Tree.TreeUpdated += Tree_TreeUpdated; InitializeCache(doc.Tree.StyleSheet); } }
public async void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, System.Collections.ObjectModel.Collection<ITextBuffer> subjectBuffers) { foreach (ITextBuffer buffer in subjectBuffers) { if (buffer.Properties.TryGetProperty(typeof(TrailingClassifier), out TrailingClassifier classifier)) { await classifier.SetTextViewAsync(textView); } } }
public AD7ConnectCanceledException(ConnectionReason reason) { // The debugger has a good HRESULT for when the user cancels trying to connect to the target computer. // Unfortunately, the core debugger doesn't always understand this HR, and in code paths where it doesn't // the message is lousy. So only use the debugger's HRESULT when we are in AddPort or any other code path // where we are sure cancel messages are respected. if (reason == ConnectionReason.AddPort) { this.HResult = HR.E_REMOTE_CONNECT_USER_CANCELED; } }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { var actions = _textViews[textView]; _textViews.Remove(textView); foreach (var action in actions) { action(textView); } }
public void SubjectBuffersConnected(ITextView textView, ConnectionReason reason, IReadOnlyCollection <ITextBuffer> subjectBuffers) { if (textView is null) { throw new ArgumentNullException(nameof(textView)); } var vsTextView = _editorAdaptersFactory.GetViewAdapter(textView); RazorLSPTextViewFilter.CreateAndRegister(vsTextView); }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (!subjectBuffers.Any(b => b.ContentType.IsOfType("JSON"))) return; var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView); if (textViewAdapter == null) return; textView.Properties.GetOrCreateSingletonProperty<FormatCommandTarget>(() => new FormatCommandTarget(textViewAdapter, textView)); }
public void SubjectBuffersConnected( IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers ) { // Create it for the view if we don't already have one textView.GetOrCreateAutoClosingProperty( v => new DashboardAdornmentManager(_renameService, _editorFormatMapService, v) ); }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { foreach (var buffer in subjectBuffers.Where(b => b.ContentType.IsOfType("css"))) { CssTreeWatcher watcher; if (buffer.Properties.TryGetProperty(typeof(CssTreeWatcher), out watcher)) { watcher.Tree = null; } } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, System.Collections.ObjectModel.Collection<ITextBuffer> subjectBuffers) { foreach (var buffer in subjectBuffers) { TrailingClassifier classifier; if (buffer.Properties.TryGetProperty(typeof(TrailingClassifier), out classifier)) { classifier.SetTextView(textView); } } }
public void SubjectBuffersDisconnected( ITextView textView, ConnectionReason reason, IReadOnlyCollection <ITextBuffer> subjectBuffers) { foreach (var buffer in subjectBuffers) { buffers.Remove(buffer); BufferUnRegistered?.Invoke(buffer); } }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { if (!textView.TextBuffer.ContentType.IsOfType(RContentTypeDefinition.ContentType)) { var filter = DataTipTextViewFilter.TryGet(textView); if (filter != null) { filter.Dispose(); } } }
/// <summary> /// SubjectBuffersConnected happens first /// </summary> /// <param name="wpfTextView"></param> /// <param name="reason"></param> /// <param name="subjectBuffers"></param> public void SubjectBuffersConnected(IWpfTextView wpfTextView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { try { var logPrefix = $"{nameof(SubjectBuffersConnected)}"; using (var metrics = Log.WithMetrics($"{logPrefix} ")) { if (wpfTextView == null || !wpfTextView.HasValidDocumentRoles()) { return; } IVirtualTextDocument virtualTextDocument = null; if (!TextDocumentExtensions.TryGetTextDocument(TextDocumentFactoryService, wpfTextView, out virtualTextDocument)) { Log.Warning($"{logPrefix} Could not create virtualTextDocument"); return; } Log.Verbose($"{logPrefix} pre-Lock"); lock (WeakTableLock) { Log.Verbose($"{logPrefix} in-Lock"); foreach (var buffer in subjectBuffers) { if (!TextBufferTable.TryGetValue(buffer, out HashSet <IWpfTextView> textViews)) { textViews = new HashSet <IWpfTextView>(); TextBufferTable.Add(buffer, textViews); } textViews.Add(wpfTextView); } using (metrics.Measure($"{logPrefix} Building properties")) { if (virtualTextDocument.SupportsMarkers) { wpfTextView.Properties.GetOrCreateSingletonProperty(PropertyNames.DocumentMarkerManager, () => new DocumentMarkerManager(CodeStreamAgentServiceFactory.Create(), wpfTextView, virtualTextDocument)); } wpfTextView.Properties.GetOrCreateSingletonProperty(PropertyNames.TextViewDocument, () => virtualTextDocument); wpfTextView.Properties.GetOrCreateSingletonProperty(PropertyNames.TextViewState, () => new TextViewState()); #if DEBUG if (TextViewCache == null) { System.Diagnostics.Debugger.Break(); } #endif } TextViewCache.Add(virtualTextDocument, wpfTextView); } Log.Verbose($"{logPrefix} Uri={virtualTextDocument.Uri}"); } } catch (Exception ex) { Log.Error(ex, nameof(SubjectBuffersConnected)); } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { ITextDocument document; if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document)) { textView.Properties.GetOrCreateSingletonProperty("HandlebarsCompilationNotifier", () => Mef.GetImport <ICompilationNotifierProvider>(ContentTypeManager.GetContentType("Handlebars")) .GetCompilationNotifier(document)); } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { if (subjectBuffers.Any(b => b.ContentType.IsOfType(LiveScriptContentTypeDefinition.LiveScriptContentType))) { return; } var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView); textView.Properties.GetOrCreateSingletonProperty(() => new EnterIndentation(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty(() => new CommentCommandTarget(textViewAdapter, textView, "#")); }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { if (!textView.TextBuffer.ContentType.IsOfType(RContentTypeDefinition.ContentType)) { return; } var adapterService = VsAppShell.Current.ExportProvider.GetExportedValue <IVsEditorAdaptersFactoryService>(); var debugger = VsAppShell.Current.GetGlobalService <IVsDebugger>(); DataTipTextViewFilter.GetOrCreate(textView, adapterService, debugger); }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (!subjectBuffers.Any(b => b.ContentType.IsOfType(LessContentTypeDefinition.LessContentType))) return; var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView); if (textViewAdapter == null) return; textView.Properties.GetOrCreateSingletonProperty<LessExtractVariableCommandTarget>(() => new LessExtractVariableCommandTarget(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<LessExtractMixinCommandTarget>(() => new LessExtractMixinCommandTarget(textViewAdapter, textView)); }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { if (!textView.TextBuffer.ContentType.IsOfType(RContentTypeDefinition.ContentType)) { return; } VsAppShell.Current.DispatchOnUIThread(() => { var debugger = VsAppShell.Current.GetGlobalService <IVsDebugger>(); DataTipTextViewFilter.GetOrCreate(textView, _adaptersFactoryService, debugger); }); }
void IWpfTextViewConnectionListener.SubjectBuffersConnected( IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers ) { if (!_initialized) { CreateServices(_languageName); _initialized = true; } }
void ITextViewConnectionListener.SubjectBuffersConnected(ITextView textView, ConnectionReason reason, IReadOnlyCollection <ITextBuffer> subjectBuffers) { Contract.ThrowIfFalse(_threadingContext.JoinableTaskContext.IsOnMainThread); // We won't listen to caret changes in the code definition window itself, since navigations there would cause it to // keep refreshing itself. if (!_subscribedViews.Contains(textView) && !textView.Roles.Contains(PredefinedTextViewRoles.CodeDefinitionView)) { _subscribedViews.Add(textView); textView.Caret.PositionChanged += OnTextViewCaretPositionChanged; QueueUpdateForCaretPosition(textView.Caret.Position); } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { if (!textView.TextBuffer.ContentType.IsOfType(RContentTypeDefinition.ContentType)) { return; } _coreShell.MainThread().Post(() => { var debugger = _coreShell.GetService <IVsDebugger>(); var adaptersFactoryService = _coreShell.GetService <IVsEditorAdaptersFactoryService>(); DataTipTextViewFilter.GetOrCreate(textView, adaptersFactoryService, debugger); }); }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { IVsTextView textViewAdapter = AdaptersFactory.GetViewAdapter(textView); foreach (var item in subjectBuffers) { if (textView.Properties.ContainsProperty(typeof(CommandFilterHighPriority))) { textViewAdapter.RemoveCommandFilter(textView.Properties[typeof(CommandFilter)] as IOleCommandTarget); textViewAdapter.RemoveCommandFilter(textView.Properties[typeof(CommandFilterHighPriority)] as IOleCommandTarget); } } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { // DevDiv https://devdiv.visualstudio.com/DevDiv/_workitems/edit/130129: // // This needs to be scheduled after editor has been composed. Otherwise // it may cause UI delays by composing the editor before it is needed // by the rest of VS. if (!_done) { _done = true; VsTaskLibraryHelper.CreateAndStartTask(VsTaskLibraryHelper.ServiceInstance, VsTaskRunContext.UIThreadIdlePriority, RefreshThemeColors); } }
public void SubjectBuffersConnected( ITextView textView, ConnectionReason reason, IReadOnlyCollection <ITextBuffer> subjectBuffers) { IntellisenseManager manager = textView.Properties.GetOrCreateSingletonProperty( delegate { return(new IntellisenseManager(this, textView)); }); // Create the appropriate Intellisense controllers for the content types in the buffer graph. It's important that we do // this after creating the brokers, as the controllers will most likely start using the brokers immediately. for (int f = 0; f < this.IntellisenseControllerFactories.Count; ++f) { var factory = this.IntellisenseControllerFactories[f]; // filter subject buffers to get the ones that match the factory content types FrugalList <ITextBuffer> matchingSubjectBuffers = new FrugalList <ITextBuffer>(); foreach (string factoryContentType in factory.Metadata.ContentTypes) { foreach (ITextBuffer subjectBuffer in subjectBuffers) { if (subjectBuffer.ContentType.IsOfType(factoryContentType) && !matchingSubjectBuffers.Contains(subjectBuffer)) { matchingSubjectBuffers.Add(subjectBuffer); } } } if (matchingSubjectBuffers.Count > 0) { // This controller factory is registered for the content type we understand. Go ahead and create // one. Note that this won't give us a handle to a controller object. We wouldn't be able to do anything // with such a reference anyway. if (manager.Controllers[f] == null) { manager.Controllers[f] = this.GuardedOperations.InstantiateExtension (factory, factory, provider => provider.TryCreateIntellisenseController(textView, matchingSubjectBuffers)); } else { foreach (ITextBuffer matchingSubjectBuffer in matchingSubjectBuffers) { manager.Controllers[f].ConnectSubjectBuffer(matchingSubjectBuffer); } } } } }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { if (reason != ConnectionReason.TextViewLifetime) { return; } InstantVisualStudio instant; if (this.instants.TryGetValue(textView, out instant)) { instant.Dispose(); } }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { if (textView == null) { throw new ArgumentException(nameof(textView)); } if (subjectBuffers == null) { throw new ArgumentNullException(nameof(subjectBuffers)); } _openViews.Remove(textView); }
private Connection GetConnection(ConnectionReason reason) { if (_connection == null) { _connection = ConnectionManager.GetInstance(_name, reason); if (_connection != null) { // User might change connection details via credentials dialog in ConnectionManager.GetInstance, get updated name _name = ConnectionManager.GetFormattedConnectionName(_connection.ConnectionInfo); } } return _connection; }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { // Do we still have any buffers alive? if (textView.BufferGraph.GetTextBuffers(b => b.ContentType.IsOfType(ContentTypeNames.RoslynContentType)).Any()) { // Yep, some are still attached return; } if (textView.Properties.TryGetProperty(typeof(DashboardAdornmentManager), out DashboardAdornmentManager manager)) { manager.Dispose(); textView.Properties.RemoveProperty(typeof(DashboardAdornmentManager)); } }
private Connection GetConnection(ConnectionReason reason) { if (_connection == null) { _connection = ConnectionManager.GetInstance(_name, reason); if (_connection != null) { // User might change connection details via credentials dialog in ConnectionManager.GetInstance, get updated name _name = ConnectionManager.GetFormattedConnectionName(_connection.ConnectionInfo); } } return(_connection); }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { // Do we still have any buffers alive? if (textView.BufferGraph.GetTextBuffers(b => b.ContentType.IsOfType(ContentTypeNames.RoslynContentType)).Any()) { // Yep, some are still attached return; } if (textView.Properties.TryGetProperty(typeof(DashboardAdornmentManager), out DashboardAdornmentManager manager)) { manager.Dispose(); textView.Properties.RemoveProperty(typeof(DashboardAdornmentManager)); } }
public async void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (!subjectBuffers.Any(b => b.ContentType.IsOfType("CSharp") || b.ContentType.IsOfType("Basic"))) return; // VS2010 only creates TextViewAdapters later; wait for it to exist. await Dispatcher.Yield(); var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView); if (textViewAdapter == null) return; ITextDocument document; if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document)) return; textView.Properties.GetOrCreateSingletonProperty(() => new GoToDefinitionInterceptor(ReferenceProviders, ServiceProvider, textViewAdapter, textView, document)); }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, System.Collections.ObjectModel.Collection <ITextBuffer> subjectBuffers) { if (reason != ConnectionReason.TextViewLifetime) { return; } IDisposable adornment; if (textView.Properties.TryGetProperty(serviceType, out adornment)) { bool success = textView.Properties.RemoveProperty(serviceType); Debug.Assert(success, "Should be able to remove adornment from the text view."); adornment.Dispose(); } }
public async void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { // Give the code that created the buffer a chance to attach its own workspace await Task.Yield(); foreach (var buffer in subjectBuffers) { CreateWorkspace(buffer); buffer.ContentTypeChanged += (s, e) => { var workspace = buffer.GetWorkspace(); if (workspace != null) { foreach (var document in buffer.GetRelatedDocuments()) { workspace.CloseDocument(document.Id); } } CreateWorkspace(buffer); }; } }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { Validation.Requires.NotNull(subjectBuffers, nameof(subjectBuffers)); List<ITextBuffer> textBuffers = IgnoreLeftTextBufferInInlineDiffView(textView, subjectBuffers); if (textBuffers.Count == 0) { return; } if (!viewMap.ContainsKey(textView)) { TextView internalTextView = new TextView(textView, this.singletons); viewMap.Add(textView, internalTextView); internalTextView.Connect(textBuffers[0]); } }
void IWpfTextViewConnectionListener.SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { lock (s_gate) { // only add roslyn type to tracking map foreach (var buffer in subjectBuffers.Where(b => IsSupportedContentType(b.ContentType))) { if (!s_map.TryGetValue(buffer, out var set)) { set = new HashSet<IWpfTextView>(); s_map.Add(buffer, set); } set.Add(textView); DebugRegisterView_NoLock(textView); } } this.SubjectBuffersConnected?.Invoke(this, new SubjectBuffersConnectedEventArgs(textView, subjectBuffers.ToReadOnlyCollection())); }
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { Validation.Requires.NotNull(textView, nameof(textView)); Validation.Requires.NotNull(subjectBuffers, nameof(subjectBuffers)); List<ITextBuffer> textBuffers = IgnoreLeftTextBufferInInlineDiffView(textView, subjectBuffers); if (textBuffers.Count == 0) { return; } TextView internalTextView; if (viewMap.TryGetValue(textView, out internalTextView)) { internalTextView.Disconnect(textBuffers[0]); viewMap.Remove(textView); } }
void IWpfTextViewConnectionListener.SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { lock (s_gate) { // we need to check all buffers reported since we will be called after actual changes have happened. // for example, if content type of a buffer changed, we will be called after it is changed, rather than before it. foreach (var buffer in subjectBuffers) { if (s_map.TryGetValue(buffer, out var set)) { set.Remove(textView); if (set.Count == 0) { s_map.Remove(buffer); } } } } }
public async void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (!subjectBuffers.Any(b => b.ContentType.IsOfType("CSharp") || b.ContentType.IsOfType("Basic"))) return; // VS2010 only creates TextViewAdapters later; wait for it to exist. await Dispatcher.Yield(); var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView); if (textViewAdapter == null) return; ITextDocument document; if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document)) return; // Register the native command first, so that it ends up earlier in // the command chain than our interceptor. This prevents the native // comand from being intercepted too. textView.Properties.GetOrCreateSingletonProperty(() => new GoToDefintionNativeCommand(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty(() => new GoToDefinitionInterceptor(ReferenceProviders, ServiceProvider, textViewAdapter, textView, document)); }
public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { if (!subjectBuffers.Any(b => b.ContentType.IsOfType(CssContentTypeDefinition.CssContentType))) return; var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView); if (textViewAdapter == null) return; textView.Properties.GetOrCreateSingletonProperty<CssSortProperties>(() => new CssSortProperties(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<CssExtractToFile>(() => new CssExtractToFile(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<CssAddMissingStandard>(() => new CssAddMissingStandard(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<CssAddMissingVendor>(() => new CssAddMissingVendor(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<CssRemoveDuplicates>(() => new CssRemoveDuplicates(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<MinifySelection>(() => new MinifySelection(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<CssFindReferences>(() => new CssFindReferences(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<F1Help>(() => new F1Help(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<CssSelectBrowsers>(() => new CssSelectBrowsers(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<RetriggerTarget>(() => new RetriggerTarget(textViewAdapter, textView)); textView.Properties.GetOrCreateSingletonProperty<ArrowsCommandTarget>(() => new ArrowsCommandTarget(textViewAdapter, textView)); }