private void DocumentSavedHandler(object sender, TextDocumentFileActionEventArgs e)
        {
            if (!_runner.Settings.LintOnSave)
                return;

            ITextDocument document = (ITextDocument)sender;
            if (_isDisposed || document.TextBuffer == null)
                return;

            switch (e.FileActionType)
            {
                case FileActionTypes.ContentLoadedFromDisk:
                    break;
                case FileActionTypes.DocumentRenamed:
                    _runner.Dispose();
                    _runner = _creator(_document.FilePath);

                    goto case FileActionTypes.ContentSavedToDisk;
                case FileActionTypes.ContentSavedToDisk:
                    Dispatcher.CurrentDispatcher.InvokeAsync(
                        () => _runner.RunLinterAsync().DoNotWait("linting " + _document.FilePath),
                        DispatcherPriority.ApplicationIdle
                    );
                    break;
            }
        }
Example #2
0
        private void DocumentSavedHandler(object sender, TextDocumentFileActionEventArgs e)
        {
            if (!_runner.Settings.LintOnSave)
            {
                return;
            }

            ITextDocument document = (ITextDocument)sender;

            if (_isDisposed || document.TextBuffer == null)
            {
                return;
            }

            switch (e.FileActionType)
            {
            case FileActionTypes.ContentLoadedFromDisk:
                break;

            case FileActionTypes.DocumentRenamed:
                _runner.Dispose();
                _runner = _creator(_document.FilePath);

                goto case FileActionTypes.ContentSavedToDisk;

            case FileActionTypes.ContentSavedToDisk:
                Dispatcher.CurrentDispatcher.InvokeAsync(
                    () => _runner.RunLinterAsync().DoNotWait("linting " + _document.FilePath),
                    DispatcherPriority.ApplicationIdle
                    );
                break;
            }
        }
        public LintFileInvoker(LinterCreator creator, ITextDocument document)
        {
            _creator = creator;
            _document = document;
            _document.FileActionOccurred += DocumentSavedHandler;
            _runner = _creator(_document.FilePath);

            if (_runner.Settings.LintOnSave)
            {
                Dispatcher.CurrentDispatcher.InvokeAsync(
                    () => _runner.RunLinterAsync().DoNotWait("linting " + _document.FilePath),
                    DispatcherPriority.ApplicationIdle
                );
            }
        }
Example #4
0
        public LintFileInvoker(LinterCreator creator, ITextDocument document)
        {
            _creator  = creator;
            _document = document;
            _document.FileActionOccurred += DocumentSavedHandler;
            _runner = _creator(_document.FilePath);

            if (_runner.Settings.LintOnSave)
            {
                Dispatcher.CurrentDispatcher.InvokeAsync(
                    () => _runner.RunLinterAsync().DoNotWait("linting " + _document.FilePath),
                    DispatcherPriority.ApplicationIdle
                    );
            }
        }