public ErrorsNotificationControl(IWpfTextView wpfTextView)
        {
            _textView = wpfTextView;

            this.Height = 0;
            this.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            if (JsParser.UI.Properties.Settings.Default.ShowErrorsNotificationOnTopOfEditor)
            {
                if (wpfTextView == null ||
                    wpfTextView.TextDataModel == null ||
                    wpfTextView.TextDataModel.DocumentBuffer == null ||
                    wpfTextView.TextDataModel.DocumentBuffer.Properties == null ||
                    (!wpfTextView.TextDataModel.DocumentBuffer.Properties.TryGetProperty(typeof(Microsoft.VisualStudio.Text.ITextDocument), out ITextDocument document)) ||
                    document == null ||
                    document.TextBuffer == null
                    )
                {
                    // Perform a monstroneous null-check while extracting document object.
                    // There were couple of issues probably caused of non error checking : http://code.google.com/p/js-addin/issues/detail?id=32, http://code.google.com/p/js-addin/issues/detail?id=30

                    // There is no document, so just empty initialize without any functionality.
                }
                else
                {
                    _docFilePath = document.FilePath;
                    document.FileActionOccurred += Document_FileActionOccurred;
                    JsParserEventsBroadcaster.Subscribe(JsParserEventsHandler, _docFilePath);
                }
            }

            InitializeComponent();
        }
        public void Dispose()
        {
            JsParserEventsBroadcaster.Unsubscribe(JsParserEventsHandler, _docFilePath);

            if (!_isDisposed)
            {
                GC.SuppressFinalize(this);
                _isDisposed = true;
            }
        }
 private void Document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e)
 {
     if (e.FileActionType.HasFlag(FileActionTypes.ContentSavedToDisk) ||
         e.FileActionType.HasFlag(FileActionTypes.DocumentRenamed))
     {
         if (e.FilePath != _docFilePath)
         {
             //Need to update registration
             JsParserEventsBroadcaster.UpdateSubscription(_docFilePath, e.FilePath);
             _docFilePath = e.FilePath;
         }
     }
 }
        public void CallParserForDocument(ICodeProvider codeProvider)
        {
            _activeDocFullName = codeProvider.FullName;

            var result = _jsParserService.Process(codeProvider);

            var toolWindow = _findWindowDelegate();

            if (result == null)
            {
                // Not JS case - need to clean tree
                _jsParserService.InvalidateCash();
                if (toolWindow != null)
                {
                    toolWindow.NavigationTreeView.Clear();
                }

                return;
            }

            if (string.IsNullOrEmpty(result.FileName))
            {
                // skip - cached result
                return;
            }

            JsParserEventsBroadcaster.FireActionsForDoc(
                _activeDocFullName,
                new JsParserErrorsNotificationArgs
            {
                Code         = codeProvider,
                FullFileName = _activeDocFullName,
                Errors       = result.Errors
            });

            if (toolWindow != null)
            {
                NotifyColorChangeToToolWindow();
                toolWindow.NavigationTreeView.UpdateTree(result, codeProvider);
            }
        }