Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 private void buffer_ChangedLowPriority(object sender, TextContentChangedEventArgs e)
 {
     try
     {
         if (_document == null)
         {
             return;
         }
         if (_document.FilePath == null)
         {
             return;
         }
         CodeModelCache.TryUpdateCache(_document.FilePath.ToLower(), RaiseTagsChanged,
                                       new NormalizedSnapshotSpanCollection());
     }
     catch (Exception ex)
     {
         Logger.Write("BufferChangedLowPriority" + ex);
     }
 }
Exemplo n.º 4
0
 private void GetSignatures()
 {
     _signatures = CodeModelCache.GetCodeInfoFor(_document);
 }