/// <summary> /// Parses the specified text buffer. Continues to monitor the parsed buffer and updates /// the parse tree asynchronously as the buffer changes. /// </summary> /// <param name="buffer"></param> public BufferParser EnqueueBuffer(IProjectEntry projEntry, ITextView textView, ITextBuffer buffer) { // only attach one parser to each buffer, we can get multiple enqueue's // for example if a document is already open when loading a project. BufferParser bufferParser; if (!buffer.Properties.TryGetProperty <BufferParser>(typeof(BufferParser), out bufferParser)) { Dispatcher dispatcher = null; var uiElement = textView as UIElement; if (uiElement != null) { dispatcher = uiElement.Dispatcher; } bufferParser = new BufferParser(this, dispatcher, projEntry, _parser, buffer); var curSnapshot = buffer.CurrentSnapshot; var severity = _parser.PyService.GeneralOptions.IndentationInconsistencySeverity; bufferParser.EnqueingEntry(); EnqueWorker(() => { _parser.ParseBuffers(bufferParser, severity, curSnapshot); }); } else { bufferParser.AttachedViews++; } return(bufferParser); }
/// <summary> /// Parses the specified text buffer. Continues to monitor the parsed buffer and updates /// the parse tree asynchronously as the buffer changes. /// </summary> /// <param name="buffer"></param> public BufferParser EnqueueBuffer(IProjectEntry projEntry, ITextView textView, ITextBuffer buffer) { // only attach one parser to each buffer, we can get multiple enqueue's // for example if a document is already open when loading a project. BufferParser bufferParser; if (!buffer.Properties.TryGetProperty<BufferParser>(typeof(BufferParser), out bufferParser)) { Dispatcher dispatcher = null; var uiElement = textView as UIElement; if (uiElement != null) { dispatcher = uiElement.Dispatcher; } bufferParser = new BufferParser(this, dispatcher, projEntry, _parser, buffer); var curSnapshot = buffer.CurrentSnapshot; var severity = _parser.PyService.GeneralOptions.IndentationInconsistencySeverity; bufferParser.EnqueingEntry(); EnqueWorker(() => { _parser.ParseBuffers(bufferParser, severity, curSnapshot); }); } else { bufferParser.AttachedViews++; } return bufferParser; }