internal RiskTagger(IClassifier classifier, ITextBuffer buffer, ITextDocumentFactoryService textDocumentFactoryService) { try { _classifier = classifier; _buffer = buffer; _textDocumentFactoryService = textDocumentFactoryService; _dte = ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE; ITextDocument document; _syncContext = SynchronizationContext.Current; if (!_textDocumentFactoryService.TryGetTextDocument(_buffer, out document)) { throw new Exception(); } _document = document; _filename = document.FilePath.ToLower(); _enabled = _filename.EndsWith(".vb") || _filename.EndsWith(".cs"); if (_enabled) { _document.FileActionOccurred += _document_FileActionOccurred; _buffer.ChangedLowPriority += buffer_ChangedLowPriority; CodeModelCache.CreateIfNeeded(document, _buffer, _dte); GetSignatures(); } } catch (Exception ex) { Logger.Write("RiskTagger::ctor" + ex); } }
void _document_FileActionOccurred(object sender, TextDocumentFileActionEventArgs e) { try { if (e.FileActionType == FileActionTypes.DocumentRenamed) { var doc = (ITextDocument)sender; CodeModelCache.CreateIfNeeded((ITextDocument)sender, _buffer, _dte); _filename = doc.FilePath.ToLower(); CodeModelCache.TryUpdateCache(e.FilePath.ToLower(), RaiseTagsChanged, new NormalizedSnapshotSpanCollection()); } } catch (Exception ex) { Logger.Write("DocActionOccurred" + ex); } }