예제 #1
0
        private void EnsureBufferHasTokenizer(IContentType contentType, ITextBuffer buffer)
        {
            if (contentType.IsOfType(PowerShellConstants.LanguageName) && !buffer.Properties.ContainsProperty(BufferProperties.PowerShellTokenizer))
            {
                IPowerShellTokenizationService psts = new PowerShellTokenizationService(buffer);

                buffer.PostChanged += (o, args) => psts.StartTokenization();

                buffer.Properties.AddProperty(BufferProperties.PowerShellTokenizer, psts);
            }
        }
예제 #2
0
        private static void TextBufferFactoryService_TextBufferCreated(object sender, TextBufferCreatedEventArgs e)
        {
            e.TextBuffer.ContentTypeChanged += TextBuffer_ContentTypeChanged;

            if (e.TextBuffer.ContentType.IsOfType("PowerShell"))
            {
                var psts = new PowerShellTokenizationService(e.TextBuffer);
                _gotoDefinitionCommand.AddTextBuffer(e.TextBuffer);
                e.TextBuffer.ChangedLowPriority += (o, args) => psts.StartTokenization();
                e.TextBuffer.Properties.AddProperty("HasTokenizer", true);
            }
        }
예제 #3
0
        static void TextBuffer_ContentTypeChanged(object sender, ContentTypeChangedEventArgs e)
        {
            var buffer = sender as ITextBuffer;

            if (buffer == null)
            {
                return;
            }

            if (e.AfterContentType.IsOfType("PowerShell") && !buffer.Properties.ContainsProperty("HasTokenizer"))
            {
                var psts = new PowerShellTokenizationService(buffer);
                _gotoDefinitionCommand.AddTextBuffer(buffer);
                buffer.ChangedLowPriority += (o, args) => psts.StartTokenization();
                buffer.Properties.AddProperty("HasTokenizer", true);
            }
        }