Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        public virtual void Dispose()
        {
            if (Disposed)
            {
                return;
            }

            Cancel();
            _textBuffer.Changed -= BufferChanged;
            _textDocumentFactory.TextDocumentDisposed -= OnTextDocumentDisposed;

            DocumentTokenizer.OnDestroy();
            DocumentAnalysis.OnDestroy();

            Disposed = true;
            _destroyAction.Invoke(this);
        }