Example #1
0
        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;
        }
        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;
        }