public Document(ITextDocumentFactoryService textDocumentFactory, ITextDocument textDocument, ILexer lexer, IParser parser, OnDestroyAction onDestroy) { _textDocumentFactory = textDocumentFactory; _textDocument = textDocument; _textBuffer = textDocument.TextBuffer; Lexer = lexer; Parser = parser; _destroyAction = onDestroy; _cts = new CancellationTokenSource(); _tokenizer = new DocumentTokenizer(_textDocument.TextBuffer, Lexer, _cts.Token); DocumentAnalysis = new DocumentAnalysis(this, DocumentTokenizer, Parser); Disposed = false; _textDocumentFactory.TextDocumentDisposed += OnTextDocumentDisposed; _textBuffer.Changed += BufferChanged; }
public virtual void Dispose() { if (Disposed) { return; } Cancel(); _textBuffer.Changed -= BufferChanged; _textDocumentFactory.TextDocumentDisposed -= OnTextDocumentDisposed; DocumentTokenizer.OnDestroy(); DocumentAnalysis.OnDestroy(); Disposed = true; _destroyAction.Invoke(this); }
private void InstructionsUpdated(IInstructionListManager sender, Helpers.AsmType asmType) => DocumentAnalysis.Rescan(RescanReason.InstructionsChanged, UpdateCancellation());