public void Dispose() { if (_legacyCommandTarget != null && _legacyCommandTarget.TextView != null) { containedLanguage2.RemoveContainedCommandTarget(_legacyCommandTarget.TextView); } containedLanguage2.ContainedLanguageDebugInfo = null; containedLanguage2.TextViewFilter = null; if (_legacyCommandTarget != null) { _legacyCommandTarget.Dispose(); _legacyCommandTarget = null; } containedLanguage.SetHost(null); _textBufferCoordinator = null; _containedLanguageHost = null; if (_secondaryBuffer != null) { ((_secondaryBuffer as IVsPersistDocData)).Close(); _secondaryBuffer = null; } if (Disposing != null) { Disposing(this, EventArgs.Empty); } }
private void InitContainedLanguage() { IVsTextLines vsTextLines = EnsureBufferCoordinator(); IVsContainedLanguage vsContainedLanguage; languageFactory.GetLanguage(hierarchy, MarkdownCodeProject.FileItemId, _textBufferCoordinator, out vsContainedLanguage); if (vsContainedLanguage == null) { Logger.Log("Markdown: Couldn't get IVsContainedLanguage for " + ProjectionBuffer.IProjectionBuffer.ContentType); return; } Guid langService; vsContainedLanguage.GetLanguageServiceID(out langService); vsTextLines.SetLanguageServiceID(ref langService); containedLanguage = vsContainedLanguage; IVsContainedLanguageHost legacyContainedLanguageHost = GetLegacyContainedLanguageHost(); vsContainedLanguage.SetHost(legacyContainedLanguageHost); _legacyCommandTarget = new LegacyContainedLanguageCommandTarget(); IVsTextViewFilter textViewFilter; _legacyCommandTarget.Create(owner.Document, vsContainedLanguage, _textBufferCoordinator, ProjectionBuffer, out textViewFilter); IWebContainedLanguageHost webContainedLanguageHost = legacyContainedLanguageHost as IWebContainedLanguageHost; webContainedLanguageHost.SetContainedCommandTarget(_legacyCommandTarget.TextView, _legacyCommandTarget.ContainedLanguageTarget); containedLanguage2 = (webContainedLanguageHost as IContainedLanguageHostVs); containedLanguage2.TextViewFilter = textViewFilter; ProjectionBuffer.ResetMappings(); WebEditor.TraceEvent(1005); }
public void Dispose() { if (_legacyCommandTarget != null && _legacyCommandTarget.TextView != null) containedLanguage2.RemoveContainedCommandTarget(_legacyCommandTarget.TextView); containedLanguage2.ContainedLanguageDebugInfo = null; containedLanguage2.TextViewFilter = null; if (_legacyCommandTarget != null) { _legacyCommandTarget.Dispose(); _legacyCommandTarget = null; } containedLanguage.SetHost(null); _textBufferCoordinator = null; _containedLanguageHost = null; if (_secondaryBuffer != null) { ((_secondaryBuffer as IVsPersistDocData)).Close(); _secondaryBuffer = null; } if (Disposing != null) Disposing(this, EventArgs.Empty); }