Represents collection of HTML validation errors and tasks. Tag collection is a primary source for validation squiggles in the editor as well as source of the corresponding messages for the application task list. Collection is thread safe.
Exemplo n.º 1
0
        public EditorErrorTagger(ITextBuffer textBuffer)
        {
            EditorShell.Current.CompositionService.SatisfyImportsOnce(this);

            _document = REditorDocument.FromTextBuffer(textBuffer);
            _document.DocumentClosing            += OnDocumentClosing;
            _document.EditorTree.UpdateCompleted += OnTreeUpdateCompleted;
            _document.EditorTree.NodesRemoved    += OnNodesRemoved;
            _errorTags = new ErrorTagCollection(_document.EditorTree);

            _textBuffer          = _document.EditorTree.TextBuffer;
            _textBuffer.Changed += OnTextBufferChanged;

            _fireCodeMarkerUponCompletion = true;

            // Don't push syntax errors to the Error List in transient
            // documents such as in document attached to a projected buffer
            // in the R interactive window
            if (TaskList != null)
            {
                var view = _document.GetFirstView();
                if (view != null && !view.IsRepl())
                {
                    TaskList.AddTaskSource(this);
                }
            }

            TreeValidator validator = TreeValidator.EnsureFromTextBuffer(_textBuffer, _document.EditorTree);

            validator.Cleared        += OnCleared;
            ResultsQueue              = validator.ValidationResults;
            EditorShell.Current.Idle += OnIdle;

            ServiceManager.AddService <EditorErrorTagger>(this, textBuffer);
        }
Exemplo n.º 2
0
        private void OnDocumentClosing(object sender, EventArgs e)
        {
            if (_textBuffer != null)
            {
                EditorShell.Current.Idle -= OnIdle;

                _document.EditorTree.UpdateCompleted -= OnTreeUpdateCompleted;
                _document.EditorTree.NodesRemoved    -= OnNodesRemoved;

                _document.DocumentClosing -= OnDocumentClosing;
                _document = null;

                _errorTags.Clear();
                _errorTags = null;

                ServiceManager.RemoveService <EditorErrorTagger>(_textBuffer);
                ResultsQueue = null;

                _textBuffer.Changed -= OnTextBufferChanged;
                _textBuffer          = null;

                if (TaskList != null)
                {
                    TaskList.RemoveTaskSource(this);
                }
            }
        }
Exemplo n.º 3
0
        public EditorErrorTagger(ITextBuffer textBuffer, IEditorTaskList taskList, IServiceContainer services)
        {
            _taskList = taskList;

            _settings = services.GetService <IREditorSettings>();
            _idleTime = services.GetService <IIdleTimeService>();

            _document          = textBuffer.GetEditorDocument <IREditorDocument>();
            _document.Closing += OnDocumentClosing;
            _document.EditorTree.UpdateCompleted += OnTreeUpdateCompleted;
            _document.EditorTree.NodesRemoved    += OnNodesRemoved;
            _errorTags = new ErrorTagCollection(_document.EditorTree);

            _textBuffer          = _document.EditorTree.TextBuffer();
            _textBuffer.Changed += OnTextBufferChanged;

            // Don't push syntax errors to the Error List in transient
            // documents such as in document attached to a projected buffer
            // in the R interactive window
            if (_taskList != null && !_document.IsRepl)
            {
                _taskList.AddTaskSource(this);
            }

            var validator = _document.EditorBuffer.GetService <TreeValidator>();

            validator.Cleared += OnCleared;

            _resultsQueue   = validator.ValidationResults;
            _idleTime.Idle += OnIdle;
        }
Exemplo n.º 4
0
        public EditorErrorTagger(ITextBuffer textBuffer, IEditorTaskList taskList, ICoreShell shell)
        {
            _taskList = taskList;
            _shell    = shell;
            _settings = _shell.GetService <IREditorSettings>();

            _document = REditorDocument.FromTextBuffer(textBuffer);
            _document.DocumentClosing            += OnDocumentClosing;
            _document.EditorTree.UpdateCompleted += OnTreeUpdateCompleted;
            _document.EditorTree.NodesRemoved    += OnNodesRemoved;
            _errorTags = new ErrorTagCollection(_document.EditorTree);

            _textBuffer          = _document.EditorTree.TextBuffer;
            _textBuffer.Changed += OnTextBufferChanged;

            _fireCodeMarkerUponCompletion = true;

            // Don't push syntax errors to the Error List in transient
            // documents such as in document attached to a projected buffer
            // in the R interactive window
            if (_taskList != null)
            {
                var view = _document.GetFirstView();
                if (view != null && !view.IsRepl())
                {
                    _taskList.AddTaskSource(this);
                }
            }

            TreeValidator validator = TreeValidator.EnsureFromTextBuffer(_textBuffer, _document.EditorTree, shell);

            validator.Cleared += OnCleared;
            ResultsQueue       = validator.ValidationResults;
            _shell.Idle       += OnIdle;
        }
Exemplo n.º 5
0
        private void OnDocumentClosing(object sender, EventArgs e)
        {
            if (_textBuffer != null)
            {
                _idleTime.Idle -= OnIdle;

                _document.EditorTree.UpdateCompleted -= OnTreeUpdateCompleted;
                _document.EditorTree.NodesRemoved    -= OnNodesRemoved;

                _document.Closing -= OnDocumentClosing;
                _document          = null;

                _errorTags.Clear();
                _errorTags = null;

                ResultsQueue = null;

                _textBuffer.Changed -= OnTextBufferChanged;
                _textBuffer          = null;

                _taskList?.RemoveTaskSource(this);
            }
        }