/// <summary> /// The CodeWindowManager is constructed by the base LanguageService class when VS calls /// the IVsLanguageInfo.GetCodeWindowManager method. You can override CreateCodeWindowManager /// on your LanguageService if you want to plug in a different CodeWindowManager. /// </summary> internal CodeWindowManager(LanguageService service, IVsCodeWindow codeWindow, ISource source) { this.service = service; this.codeWindow = codeWindow; this.viewFilters = new ArrayList(); this.source = source; #if DOCUMENT_PROPERTIES this.properties = service.CreateDocumentProperties(this); #endif }
/// <summary>Closes all view filters, and the document properties window</summary> internal void Close() { #if LANGTRACE Trace.WriteLine("CodeWindowManager::Close"); #endif #if DOCUMENT_PROPERTIES if (this.properties != null) this.properties.Close(); #endif CloseFilters(); this.viewFilters = null; #if DOCUMENT_PROPERTIES properties = null; #endif service = null; source = null; this.codeWindow = null; }
// Overriden in source.fs, it calls this base implementation public virtual void Dispose() { #if LANGTRACE Trace.WriteLine("Source::Cleanup"); #endif this.disposed = true; try { if (this.textLinesEvents != null) { this.textLinesEvents.Dispose(); this.textLinesEvents = null; } } finally { try { if (this.userDataEvents != null) { this.userDataEvents.Dispose(); this.userDataEvents = null; } } finally { try { if (this.hiddenTextSession != null) { // We can't throw or exit here because we need to call Dispose on the // other members that need to be disposed. this.hiddenTextSession.UnadviseClient(); // This is causing a debug assert in vs\env\msenv\textmgr\vrlist.cpp // at line 1997 in CVisibleRegionList::Terminate //this.hiddenTextSession.Terminate(); this.hiddenTextSession = null; } } finally { try { if (this.methodData != null) { this.methodData.Dispose(); this.methodData = null; } } finally { try { if (this.completionSet != null) { this.completionSet.Dispose(); this.completionSet = null; } } finally { try { // clear out any remaining tasks for this doc in the task list // tp may not be the same as taskProvider // REVIEW: This should be: if (null != this.taskReporter) // Right now, MSBuild 4.0 can clear out build loggers responsibly, so this.taskReporter will always // be null when we get to this point, so we'll need to create a new taskReporter to clear out the // background tasks TaskReporter tr = this.GetTaskReporter(); // may be our own TR or one from ProjectSite of this file if (null != tr) { tr.ClearBackgroundTasksForFile(this.GetFilePath()); // Refresh the task list tr.OutputTaskList(); } if (null != this.taskReporter) // dispose the one we own (do not dispose one shared by project site!) { this.taskReporter.Dispose(); this.taskReporter = null; this.taskProvider = null; } } finally { try { this.service = null; if (this.colorizer != null) { // The colorizer is owned by the core text editor, so we don't close it, the core text editor // does that for us when it is ready to do so. //colorizer.CloseColorizer(); this.colorizer = null; } } finally { this.colorState = null; try { if (this.expansionProvider != null) { this.expansionProvider.Dispose(); this.expansionProvider = null; } } finally { // Sometimes OnCloseSource is called when language service is changed, (for example // when you save the file with a different file extension) in which case we cannot // null out the site because that will cause a crash inside msenv.dll. // if (this.textLines != null) { // ((IObjectWithSite)this.textLines).SetSite(null); // } if (this.textLines != null) { this.textLines = null; Marshal.Release(pUnkTextLines); } } } } } } } } } }
internal SourceImpl(LanguageService service, IVsTextLines textLines, Colorizer colorizer) { #if LANGTRACE Tracing.TraceRef(textLines, "Source.textLines"); #endif this.service = service; this.textLines = textLines; // REVIEW: why the next line? RCW in this.textLines holds IUnknown already. (released in Dispose correctly though) pUnkTextLines = Marshal.GetIUnknownForObject(this.textLines); //so it can't get disposed on us this.colorizer = colorizer; this.completionSet = this.CreateCompletionSet(); this.methodData = new MethodData(this.service.Site); this.colorState = (IVsTextColorState)textLines; // track source changes this.textLinesEvents = new NativeMethods.ConnectionPointCookie(textLines, this, typeof(IVsTextLinesEvents)); this.userDataEvents = new NativeMethods.ConnectionPointCookie(textLines, this, typeof(IVsUserDataEvents)); this.doOutlining = this.service.Preferences.AutoOutlining; if (this.doOutlining) { GetHiddenTextSession(); } this.expansionProvider = GetExpansionProvider(); this.lastOnIdleRequestDuration = 0; this.openedTime = System.DateTime.Now; }
internal ViewFilter(CodeWindowManager mgr, IVsTextView view) { this.pvaChar = IntPtr.Zero; this.mgr = mgr; this.service = mgr.LanguageService; this.source = mgr.Source; this.commentSupported = this.service.Preferences.EnableCommenting; this.textView = view; NativeMethods.ThrowOnFailure(view.AddCommandFilter(this, out nextTarget)); this.textViewEvents = new NativeMethods.ConnectionPointCookie(view, this, typeof(IVsTextViewEvents)); if (this.service != null) { IVsExpansionManager emgr = this.service.Site.GetService(typeof(SVsExpansionManager)) as IVsExpansionManager; if (emgr != null) { int fBound; emgr.GetSnippetShortCutKeybindingState(out fBound); this.snippetBound = fBound == 0 ? false : true; this.expansionEvents = new NativeMethods.ConnectionPointCookie(emgr, this, typeof(IVsExpansionEvents)); } } }
public virtual void Dispose() { this.textView = null; this.service = null; this.nextTarget = null; this.textTipData = null; this.mgr = null; if (this.pvaChar != IntPtr.Zero) { Marshal.FreeCoTaskMem(pvaChar); pvaChar = IntPtr.Zero; } GC.SuppressFinalize(this); // REVIEW: Why this? }
/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="TypeAndMemberDropdownBars.OnSynchronizeDropdowns"]/*' /> /// <summary> /// This method is called to update the drop down bars to match the current contents of the text editor window. /// It is called during OnIdle when the caret position changes. You can provide new drop down members here. /// It is up to you to sort the ArrayLists if you want them sorted in any particular order. /// </summary> /// <param name="languageService">The language service</param> /// <param name="textView">The editor window</param> /// <param name="line">The line on which the cursor is now positioned</param> /// <param name="col">The column on which the cursor is now position</param> /// <param name="dropDownTypes">The current list of types (you can update this)</param> /// <param name="dropDownMembers">The current list of members (you can update this)</param> /// <param name="selectedType">The selected type (you can update this)</param> /// <param name="selectedMember">The selected member (you can update this)</param> /// <returns>true if something was updated</returns> public abstract bool OnSynchronizeDropdowns(LanguageService languageService, IVsTextView textView, int line, int col, ArrayList dropDownTypes, ArrayList dropDownMembers, ref int selectedType, ref int selectedMember);
/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="TypeAndMemberDropdownBars.TypeAndMemberDropdownBars"]/*' /> protected TypeAndMemberDropdownBars(LanguageService languageService) { this.languageService = languageService; this.dropDownTypes = new ArrayList(); this.dropDownMembers = new ArrayList(); }