public override void Dispose() { try { ((NemerleLanguageService)Source.LanguageService).DisposeColorizer(this.Source.TextLines); _bufferCoordinator = null; // Базовая реализация base.Dispose() предполагает, что значение внутреннего поля textView // является COM объектом и безусловно вызывает для него Marshal.ReleaseComObject. // Но для Contained Language в качестве view используется TextViewWrapper, который не является // COM объектом, что приводит к генерации исключения внутри base.Dispose() и // преждевременному выходу из функции. // // Поэтому деинициализаируем textView вручную и обнулим значение поля. Это отменит вызов ReleaseComObject // HACK: обнулим значение приватного поля textView, если его значение имеет тип TextViewWrapper var textViewFieldInfo = this.GetType().BaseType.GetField("textView", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); if (textViewFieldInfo != null) { var textView = (IVsTextView)textViewFieldInfo.GetValue(this); if (textView is TextViewWrapper) { textView.CloseView(); textViewFieldInfo.SetValue(this, null); } } base.Dispose(); } catch (Exception) { } }
public override void Dispose() { try { _bufferCoordinator = null; // Базовая реализация base.Dispose() предполагает, что значение внутреннего поля textView // является COM объектом и безусловно вызывает для него Marshal.ReleaseComObject. // Но для Contained Language в качестве view используется TextViewWrapper, который не является // COM объектом, что приводит к генерации исключения внутри base.Dispose() и // преждевременному выходу из функции. // // Поэтому деинициализаируем textView вручную и обнулим значение поля. Это отменит вызов ReleaseComObject // HACK: обнулим значение приватного поля textView, если его значение имеет тип TextViewWrapper var textViewFieldInfo = this.GetType().BaseType.GetField("textView", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); if (textViewFieldInfo != null) { var textView = (IVsTextView)textViewFieldInfo.GetValue(this); if (textView is TextViewWrapper) { textView.CloseView(); textViewFieldInfo.SetValue(this, null); } } base.Dispose(); } catch (Exception) { } }
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); } }
public int CloseView() { this.intellisenseHost = null; this.bufferCoordinator = null; this.languageHost = null; return(VSConstants.S_OK); }
public ContainedLanguage( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, AbstractProject project, IVsHierarchy hierarchy, uint itemid, TLanguageService languageService, SourceCodeKind sourceCodeKind, IFormattingRule vbHelperFormattingRule, Workspace workspace ) : base( bufferCoordinator, componentModel, project.VisualStudioProject, hierarchy, itemid, project.ProjectTracker, project.Id, languageService.LanguageServiceId, vbHelperFormattingRule: null ) { Contract.ThrowIfTrue(vbHelperFormattingRule != null); }
private IVsTextLines EnsureBufferCoordinator() { if (_secondaryBuffer != null) { return(_secondaryBuffer); } var vsTextBuffer = owner.Document.TextBuffer.QueryInterface <IVsTextBuffer>(); IVsEditorAdaptersFactoryService adapterFactory = WebEditor.ExportProvider.GetExport <IVsEditorAdaptersFactoryService>().Value; _secondaryBuffer = (adapterFactory.GetBufferAdapter(ProjectionBuffer.IProjectionBuffer) as IVsTextLines); if (_secondaryBuffer == null) { _secondaryBuffer = (adapterFactory.CreateVsTextBufferAdapterForSecondaryBuffer(vsTextBuffer.GetServiceProvider(), ProjectionBuffer.IProjectionBuffer) as IVsTextLines); } _secondaryBuffer.SetTextBufferData(VSConstants.VsTextBufferUserDataGuid.VsBufferDetectLangSID_guid, false); _secondaryBuffer.SetTextBufferData(VSConstants.VsTextBufferUserDataGuid.VsBufferMoniker_guid, owner.WorkspaceItem.PhysicalPath); IOleUndoManager oleUndoManager; _secondaryBuffer.GetUndoManager(out oleUndoManager); oleUndoManager.Enable(0); _textBufferCoordinator = adapterFactory.CreateVsTextBufferCoordinatorAdapter(); vsTextBuffer.SetTextBufferData(HtmlConstants.SID_SBufferCoordinatorServerLanguage, _textBufferCoordinator); vsTextBuffer.SetTextBufferData(typeof(VsTextBufferCoordinatorClass).GUID, _textBufferCoordinator); _textBufferCoordinator.SetBuffers(vsTextBuffer as IVsTextLines, _secondaryBuffer); return(_secondaryBuffer); }
public VSTypeScriptContainedLanguageWrapper( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, Workspace workspace, IVsHierarchy hierarchy, uint itemid, Guid languageServiceGuid ) { var filePath = ContainedLanguage.GetFilePathFromHierarchyAndItemId(hierarchy, itemid); var projectId = ProjectId.CreateNewId($"Project for {filePath}"); workspace.OnProjectAdded( ProjectInfo.Create( projectId, VersionStamp.Default, filePath, string.Empty, "TypeScript" ) ); _underlyingObject = new ContainedLanguage( bufferCoordinator, componentModel, workspace, projectId, null, filePath, languageServiceGuid, vbHelperFormattingRule: null ); }
protected virtual IVsContainedLanguage CreateContainedLanguage( IVsTextBufferCoordinator bufferCoordinator, VisualStudioProject project, IVsHierarchy hierarchy, uint itemid) { return(new ContainedLanguage <TPackage, TLanguageService>( bufferCoordinator, this.Package.ComponentModel, project, hierarchy, itemid, (TLanguageService)this)); }
protected virtual IVsContainedLanguage CreateContainedLanguage( IVsTextBufferCoordinator bufferCoordinator, AbstractProject project, IVsHierarchy hierarchy, uint itemid) { return(new ContainedLanguage <TPackage, TLanguageService>( bufferCoordinator, this.Package.ComponentModel, project, hierarchy, itemid, (TLanguageService)this, SourceCodeKind.Regular)); }
protected virtual IVsContainedLanguage CreateContainedLanguage( IVsTextBufferCoordinator bufferCoordinator, VisualStudioProject project, IVsHierarchy hierarchy, uint itemid) { return(new ContainedLanguage( bufferCoordinator, this.Package.ComponentModel, project, hierarchy, itemid, projectTrackerOpt: null, project.Id, this.LanguageServiceId)); }
public VSTypeScriptContainedLanguageWrapper( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, VSTypeScriptVisualStudioProjectWrapper project, IVsHierarchy hierarchy, uint itemid, Guid languageServiceGuid) : this(bufferCoordinator, componentModel, project, languageServiceGuid) { }
internal void SetBufferCoordinator(IVsTextBufferCoordinator coordinator) { _bufferCoordinator = coordinator; var primaryBuffer = GetPrimaryTextLines(); _primaryFileIndex = Location.GetFileIndex(FilePathUtilities.GetFilePath(primaryBuffer)); _primaryToSecondaryFilesMap[_primaryFileIndex] = FileIndex; }
public VSTypeScriptContainedLanguageWrapper( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, Workspace workspace, IVsHierarchy hierarchy, uint itemid, Guid languageServiceGuid) : this(bufferCoordinator, componentModel, workspace, languageServiceGuid) { }
internal TextViewWrapper(IVsContainedLanguageHost languageHost, IVsIntellisenseHost intellisenseHost, IVsTextBufferCoordinator coordinator, IOleCommandTarget nextTarget) { if (null == intellisenseHost) { throw new ArgumentNullException("buffer"); } this.intellisenseHost = intellisenseHost; this.bufferCoordinator = coordinator; this.languageHost = languageHost; this.nextTarget = nextTarget; }
public NemerleContainedLanguage(IVsTextBufferCoordinator bufferCoordinator, NemerleIntellisenseProvider intellisenseProject, uint itemId, IVsHierarchy pHierarchy) { if (null == bufferCoordinator) { throw new ArgumentNullException("bufferCoordinator"); } if (null == intellisenseProject) { throw new ArgumentNullException("intellisenseProject"); } _hierarchy = pHierarchy; object projectItem = null; pHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_ExtObject, out projectItem); _projectItem = projectItem as EnvDTE.ProjectItem; EnvDTE.Property prop = _projectItem.Properties.Item("FullPath"); if (prop != null) { _filePath = prop.Value as string; } var project = _projectItem.ContainingProject as NemerleOAProject; if (project != null) { _projectInfo = ((NemerleProjectNode)project.Project).ProjectInfo; } _typeResolutionService = null; DynamicTypeService typeService = LanguageService.GetService(typeof(DynamicTypeService)) as DynamicTypeService; if (typeService != null) { _typeResolutionService = typeService.GetTypeResolutionService(this._hierarchy); } this.bufferCoordinator = bufferCoordinator; this.intellisenseProject = intellisenseProject; this.itemId = itemId; // Make sure that the secondary buffer uses the IronPython language service. IVsTextLines buffer; ErrorHandler.ThrowOnFailure(bufferCoordinator.GetSecondaryBuffer(out buffer)); Guid languageGuid; this.GetLanguageServiceID(out languageGuid); ErrorHandler.ThrowOnFailure(buffer.SetLanguageServiceID(ref languageGuid)); _documentClosingEventHandler = new _dispDocumentEvents_DocumentClosingEventHandler(OnDocumentClosing); }
internal ContainedLanguage( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, VisualStudioProject project, IVsHierarchy hierarchy, uint itemid, VisualStudioProjectTracker projectTrackerOpt, ProjectId projectId, TLanguageService languageService, AbstractFormattingRule vbHelperFormattingRule = null) { this.BufferCoordinator = bufferCoordinator; this.ComponentModel = componentModel; this.Project = project; _languageService = languageService; this.Workspace = projectTrackerOpt?.Workspace ?? componentModel.GetService <VisualStudioWorkspace>(); _editorAdaptersFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>(); _diagnosticAnalyzerService = componentModel.GetService <IDiagnosticAnalyzerService>(); // Get the ITextBuffer for the secondary buffer Marshal.ThrowExceptionForHR(bufferCoordinator.GetSecondaryBuffer(out var secondaryTextLines)); var secondaryVsTextBuffer = (IVsTextBuffer)secondaryTextLines; SubjectBuffer = _editorAdaptersFactoryService.GetDocumentBuffer(secondaryVsTextBuffer); // Get the ITextBuffer for the primary buffer Marshal.ThrowExceptionForHR(bufferCoordinator.GetPrimaryBuffer(out var primaryTextLines)); DataBuffer = _editorAdaptersFactoryService.GetDataBuffer((IVsTextBuffer)primaryTextLines); // Create our tagger var bufferTagAggregatorFactory = ComponentModel.GetService <IBufferTagAggregatorFactoryService>(); _bufferTagAggregator = bufferTagAggregatorFactory.CreateTagAggregator <ITag>(SubjectBuffer); if (!ErrorHandler.Succeeded(((IVsProject)hierarchy).GetMkDocument(itemid, out var 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)) { FatalError.Report(new System.Exception("Failed to get document moniker for a contained document")); } } DocumentId documentId; if (this.Project != null) { documentId = this.Project.AddSourceTextContainer( SubjectBuffer.AsTextContainer(), filePath, sourceCodeKind: SourceCodeKind.Regular, folders: default,
public int GetLanguage(IVsHierarchy pHierarchy, uint itemid, IVsTextBufferCoordinator pBufferCoordinator, out IVsContainedLanguage ppLanguage) { ModuleId id = new ModuleId(pHierarchy, itemid); NemerleContainedLanguage lang; if (!languages.TryGetValue(id, out lang)) { lang = new NemerleContainedLanguage(pBufferCoordinator, intellisenseProject, itemid, pHierarchy); languages.Add(id, lang); } ppLanguage = lang; return VSConstants.S_OK; }
public int GetLanguage(IVsHierarchy pHierarchy, uint itemid, IVsTextBufferCoordinator pBufferCoordinator, out IVsContainedLanguage ppLanguage) { ModuleId id = new ModuleId(pHierarchy, itemid); PythonContainedLanguage lang; if (!languages.TryGetValue(id, out lang)) { lang = new PythonContainedLanguage(pBufferCoordinator, intellisenseProject, itemid); languages.Add(id, lang); } ppLanguage = lang; return(VSConstants.S_OK); }
public IVsContainedLanguage GetLanguage(string filePath, IVsTextBufferCoordinator bufferCoordinator) { var componentModel = (IComponentModel)_serviceProvider.GetService(typeof(SComponentModel)); var projectId = _razorProjectFactory.GetProject(filePath); return(new ContainedLanguage( bufferCoordinator, componentModel, _razorProjectFactory.Workspace, projectId, project: null, Guids.CSharpLanguageServiceId)); }
internal ContainedLanguage( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, Workspace workspace, ProjectId projectId, VisualStudioProject?project, string filePath, Guid languageServiceGuid, AbstractFormattingRule?vbHelperFormattingRule = null ) { this.BufferCoordinator = bufferCoordinator; this.ComponentModel = componentModel; this.Project = project; _languageServiceGuid = languageServiceGuid; this.Workspace = workspace; _editorAdaptersFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>(); _diagnosticAnalyzerService = componentModel.GetService <IDiagnosticAnalyzerService>(); // Get the ITextBuffer for the secondary buffer Marshal.ThrowExceptionForHR( bufferCoordinator.GetSecondaryBuffer(out var secondaryTextLines) ); SubjectBuffer = _editorAdaptersFactoryService.GetDocumentBuffer(secondaryTextLines) !; // Get the ITextBuffer for the primary buffer Marshal.ThrowExceptionForHR( bufferCoordinator.GetPrimaryBuffer(out var primaryTextLines) ); DataBuffer = _editorAdaptersFactoryService.GetDataBuffer(primaryTextLines) !; // Create our tagger var bufferTagAggregatorFactory = ComponentModel.GetService <IBufferTagAggregatorFactoryService>(); _bufferTagAggregator = bufferTagAggregatorFactory.CreateTagAggregator <ITag>( SubjectBuffer ); DocumentId documentId; if (this.Project != null) { documentId = this.Project.AddSourceTextContainer( SubjectBuffer.AsTextContainer(), filePath, sourceCodeKind: SourceCodeKind.Regular, folders: default,
public int GetLanguage(IVsHierarchy hierarchy, uint itemid, IVsTextBufferCoordinator bufferCoordinator, out IVsContainedLanguage language) { var project = FindMatchingProject(hierarchy, itemid); if (project == null) { language = null; return(VSConstants.E_INVALIDARG); } language = CreateContainedLanguage(bufferCoordinator, project, hierarchy, itemid); return(VSConstants.S_OK); }
protected virtual IVsContainedLanguage CreateContainedLanguage( IVsTextBufferCoordinator bufferCoordinator, VisualStudioProject project, IVsHierarchy hierarchy, uint itemid) { var filePath = ContainedLanguage.GetFilePathFromHierarchyAndItemId(hierarchy, itemid); return(new ContainedLanguage( bufferCoordinator, this.Package.ComponentModel, this.Workspace, project.Id, project, filePath, this.LanguageServiceId)); }
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 NemerleContainedLanguage(IVsTextBufferCoordinator bufferCoordinator, NemerleIntellisenseProvider intellisenseProject, uint itemId, IVsHierarchy pHierarchy) { if (null == bufferCoordinator) { throw new ArgumentNullException("bufferCoordinator"); } if (null == intellisenseProject) { throw new ArgumentNullException("intellisenseProject"); } _hierarchy = pHierarchy; object projectItem = null; pHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_ExtObject, out projectItem); _projectItem = projectItem as EnvDTE.ProjectItem; EnvDTE.Property prop = _projectItem.Properties.Item("FullPath"); if (prop != null) _filePath = prop.Value as string; var project = _projectItem.ContainingProject as NemerleOAProject; if(project != null) { _projectInfo = ((NemerleProjectNode)project.Project).ProjectInfo; } _typeResolutionService = null; DynamicTypeService typeService = LanguageService.GetService(typeof(DynamicTypeService)) as DynamicTypeService; if (typeService != null) _typeResolutionService = typeService.GetTypeResolutionService(this._hierarchy); this.bufferCoordinator = bufferCoordinator; this.intellisenseProject = intellisenseProject; this.itemId = itemId; // Make sure that the secondary buffer uses the IronPython language service. IVsTextLines buffer; ErrorHandler.ThrowOnFailure(bufferCoordinator.GetSecondaryBuffer(out buffer)); Guid languageGuid; this.GetLanguageServiceID(out languageGuid); ErrorHandler.ThrowOnFailure(buffer.SetLanguageServiceID(ref languageGuid)); _documentClosingEventHandler = new _dispDocumentEvents_DocumentClosingEventHandler(OnDocumentClosing); }
public ContainedLanguage( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, TProject project, IVsHierarchy hierarchy, uint itemid, TLanguageService languageService, SourceCodeKind sourceCodeKind, IFormattingRule vbHelperFormattingRule = null) : base(project) { this.BufferCoordinator = bufferCoordinator; this.ComponentModel = componentModel; this.Project = project; _languageService = languageService; this.Workspace = componentModel.GetService <VisualStudioWorkspace>(); _editorAdaptersFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>(); // Get the ITextBuffer for the secondary buffer IVsTextLines secondaryTextLines; Marshal.ThrowExceptionForHR(bufferCoordinator.GetSecondaryBuffer(out secondaryTextLines)); var secondaryVsTextBuffer = (IVsTextBuffer)secondaryTextLines; SetSubjectBuffer(_editorAdaptersFactoryService.GetDocumentBuffer(secondaryVsTextBuffer)); var bufferTagAggregatorFactory = ComponentModel.GetService <IBufferTagAggregatorFactoryService>(); _bufferTagAggregator = bufferTagAggregatorFactory.CreateTagAggregator <ITag>(SubjectBuffer); IVsTextLines primaryTextLines; Marshal.ThrowExceptionForHR(bufferCoordinator.GetPrimaryBuffer(out primaryTextLines)); var primaryVsTextBuffer = (IVsTextBuffer)primaryTextLines; var dataBuffer = (IProjectionBuffer)_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); }
public ContainedLanguage( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, AbstractProject project, IVsHierarchy hierarchy, uint itemid, TLanguageService languageService, SourceCodeKind sourceCodeKind, IFormattingRule vbHelperFormattingRule) : this(bufferCoordinator, componentModel, project.VisualStudioProject, hierarchy, itemid, languageService, vbHelperFormattingRule) { }
public PythonContainedLanguage(IVsTextBufferCoordinator bufferCoordinator, PythonIntellisenseProvider intellisenseProject, uint itemId) { if (null == bufferCoordinator) { throw new ArgumentNullException("bufferCoordinator"); } if (null == intellisenseProject) { throw new ArgumentNullException("intellisenseProject"); } this.bufferCoordinator = bufferCoordinator; this.intellisenseProject = intellisenseProject; this.itemId = itemId; // Make sure that the secondary buffer uses the IronPython language service. IVsTextLines buffer; ErrorHandler.ThrowOnFailure(bufferCoordinator.GetSecondaryBuffer(out buffer)); Guid languageGuid; this.GetLanguageServiceID(out languageGuid); ErrorHandler.ThrowOnFailure(buffer.SetLanguageServiceID(ref languageGuid)); }
public IVsContainedLanguage GetLanguage(string filePath, IVsTextBufferCoordinator bufferCoordinator) { var componentModel = _serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel; var project = _razorProject.GetProject(filePath); var languageService = CSharpLspLanguageService.FromServiceProvider(_serviceProvider); #pragma warning disable CS0618 // Type or member is obsolete - this is liveshare. return(new ContainedLanguage <CSharpLspPackage, CSharpLspLanguageService>(bufferCoordinator, componentModel, project, new RazorProjectHierarchy(filePath), (uint)VSConstants.VSITEMID.Nil, languageService, CodeAnalysis.SourceCodeKind.Regular, vbHelperFormattingRule: null, workspace: _remoteLanguageServiceWorkspace)); #pragma warning restore CS0618 // Type or member is obsolete - this is liveshare. }
internal ContainedLanguage( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, VisualStudioProject?project, IVsHierarchy hierarchy, uint itemid, VisualStudioProjectTracker?projectTrackerOpt, ProjectId projectId, Guid languageServiceGuid, AbstractFormattingRule?vbHelperFormattingRule = null) : this(bufferCoordinator, componentModel, projectTrackerOpt?.Workspace ?? componentModel.GetService <VisualStudioWorkspace>(), projectId, project, GetFilePathFromHierarchyAndItemId(hierarchy, itemid), languageServiceGuid, vbHelperFormattingRule) { }
public VSTypeScriptContainedLanguageWrapper( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, Workspace workspace, Guid languageServiceGuid) { var projectId = ProjectId.CreateNewId(); _underlyingObject = new ContainedLanguage( bufferCoordinator, componentModel, workspace, projectId, null, languageServiceGuid, vbHelperFormattingRule: null); var filePath = _underlyingObject.GetFilePathFromBuffers(); workspace.OnProjectAdded(ProjectInfo.Create(projectId, VersionStamp.Default, filePath, string.Empty, InternalLanguageNames.TypeScript)); }
public VSTypeScriptContainedLanguageWrapper( IVsTextBufferCoordinator bufferCoordinator, IComponentModel componentModel, AbstractProject project, IVsHierarchy hierarchy, uint itemid, Guid languageServiceGuid) { var workspace = componentModel.GetService <VisualStudioWorkspace>(); var filePath = ContainedLanguage.GetFilePathFromHierarchyAndItemId(hierarchy, itemid); _underlyingObject = new ContainedLanguage( bufferCoordinator, componentModel, workspace, project.Id, project.VisualStudioProject, filePath, languageServiceGuid, vbHelperFormattingRule: null); }
internal void Create(HtmlEditorDocument document, IVsContainedLanguage containedLanguage, IVsTextBufferCoordinator bufferCoordinator, LanguageProjectionBuffer languageBuffer, out IVsTextViewFilter containedLanguageViewfilter) { containedLanguageViewfilter = null; TextViewData textViewDataForBuffer = TextViewConnectionListener.GetTextViewDataForBuffer(document.TextBuffer); if (textViewDataForBuffer == null || textViewDataForBuffer.LastActiveView == null) return; TextView = textViewDataForBuffer.LastActiveView; IVsTextViewIntellisenseHostProvider vsTextViewIntellisenseHostProvider = TextView.QueryInterface<IVsTextViewIntellisenseHostProvider>(); if (vsTextViewIntellisenseHostProvider == null) return; Guid gUID = typeof(IVsTextViewIntellisenseHost).GUID; IntPtr intPtr; vsTextViewIntellisenseHostProvider.CreateIntellisenseHost(bufferCoordinator, ref gUID, out intPtr); if (intPtr == IntPtr.Zero) return; IVsTextViewIntellisenseHost vsTextViewIntellisenseHost = Marshal.GetObjectForIUnknown(intPtr) as IVsTextViewIntellisenseHost; Marshal.Release(intPtr); if (vsTextViewIntellisenseHost == null) return; HtmlMainController htmlMainController = HtmlMainController.FromTextView(TextView); ICommandTarget chainedController = htmlMainController.ChainedController; if (chainedController == null) return; OleToCommandTargetShim oleToCommandTargetShim = chainedController as OleToCommandTargetShim; if (containedLanguage.GetTextViewFilter(vsTextViewIntellisenseHost, oleToCommandTargetShim.OleTarget, out containedLanguageViewfilter) != 0) return; IOleCommandTarget oleTarget = containedLanguageViewfilter as IOleCommandTarget; OleToCommandTargetShim containedLanguageTarget = new OleToCommandTargetShim(TextView, oleTarget); ContainedLanguageTarget = containedLanguageTarget; _languageBuffer = languageBuffer; _languageBuffer.MappingsChanged += OnMappingsChanged; }
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 IVsTextLines EnsureBufferCoordinator() { if (_secondaryBuffer != null) return _secondaryBuffer; var vsTextBuffer = owner.Document.TextBuffer.QueryInterface<IVsTextBuffer>(); IVsEditorAdaptersFactoryService adapterFactory = WebEditor.ExportProvider.GetExport<IVsEditorAdaptersFactoryService>().Value; _secondaryBuffer = (adapterFactory.GetBufferAdapter(ProjectionBuffer.IProjectionBuffer) as IVsTextLines); if (_secondaryBuffer == null) { _secondaryBuffer = (adapterFactory.CreateVsTextBufferAdapterForSecondaryBuffer(vsTextBuffer.GetServiceProvider(), ProjectionBuffer.IProjectionBuffer) as IVsTextLines); } _secondaryBuffer.SetTextBufferData(VSConstants.VsTextBufferUserDataGuid.VsBufferDetectLangSID_guid, false); _secondaryBuffer.SetTextBufferData(VSConstants.VsTextBufferUserDataGuid.VsBufferMoniker_guid, owner.WorkspaceItem.PhysicalPath); IOleUndoManager oleUndoManager; _secondaryBuffer.GetUndoManager(out oleUndoManager); oleUndoManager.Enable(0); _textBufferCoordinator = adapterFactory.CreateVsTextBufferCoordinatorAdapter(); vsTextBuffer.SetTextBufferData(HtmlConstants.SID_SBufferCoordinatorServerLanguage, _textBufferCoordinator); vsTextBuffer.SetTextBufferData(typeof(VsTextBufferCoordinatorClass).GUID, _textBufferCoordinator); _textBufferCoordinator.SetBuffers(vsTextBuffer as IVsTextLines, _secondaryBuffer); return _secondaryBuffer; }
public int SetBufferCoordinator(IVsTextBufferCoordinator pBC) { BufferCoordinator = pBC; return(VSConstants.S_OK); }
internal void Create(HtmlEditorDocument document, IVsContainedLanguage containedLanguage, IVsTextBufferCoordinator bufferCoordinator, LanguageProjectionBuffer languageBuffer, out IVsTextViewFilter containedLanguageViewfilter) { containedLanguageViewfilter = null; TextViewData textViewDataForBuffer = TextViewConnectionListener.GetTextViewDataForBuffer(document.TextBuffer); if (textViewDataForBuffer == null || textViewDataForBuffer.LastActiveView == null) { return; } TextView = textViewDataForBuffer.LastActiveView; IVsTextViewIntellisenseHostProvider vsTextViewIntellisenseHostProvider = TextView.QueryInterface <IVsTextViewIntellisenseHostProvider>(); if (vsTextViewIntellisenseHostProvider == null) { return; } Guid gUID = typeof(IVsTextViewIntellisenseHost).GUID; IntPtr intPtr; vsTextViewIntellisenseHostProvider.CreateIntellisenseHost(bufferCoordinator, ref gUID, out intPtr); if (intPtr == IntPtr.Zero) { return; } IVsTextViewIntellisenseHost vsTextViewIntellisenseHost = Marshal.GetObjectForIUnknown(intPtr) as IVsTextViewIntellisenseHost; Marshal.Release(intPtr); if (vsTextViewIntellisenseHost == null) { return; } HtmlMainController htmlMainController = HtmlMainController.FromTextView(TextView); ICommandTarget chainedController = htmlMainController.ChainedController; if (chainedController == null) { return; } OleToCommandTargetShim oleToCommandTargetShim = chainedController as OleToCommandTargetShim; if (containedLanguage.GetTextViewFilter(vsTextViewIntellisenseHost, oleToCommandTargetShim.OleTarget, out containedLanguageViewfilter) != 0) { return; } IOleCommandTarget oleTarget = containedLanguageViewfilter as IOleCommandTarget; OleToCommandTargetShim containedLanguageTarget = new OleToCommandTargetShim(TextView, oleTarget); ContainedLanguageTarget = containedLanguageTarget; _languageBuffer = languageBuffer; _languageBuffer.MappingsChanged += OnMappingsChanged; }
public int SetBufferCoordinator(IVsTextBufferCoordinator pBC) { bufferCoordinator = pBC; return VSConstants.S_OK; }
public int CloseView() { this.intellisenseHost = null; this.bufferCoordinator = null; this.languageHost = null; return VSConstants.S_OK; }