internal SinkManager(HighlightInvalidKeyrefTaggerProvider taggerProvider, ITableDataSink sink) { _taggetProvider = taggerProvider; _sink = sink; taggerProvider.AddSinkManager(this); }
public HighlightInvalidKeyrefTagger(HighlightInvalidKeyrefTaggerProvider owner, ITextView view, ITextBuffer sourceBuffer) { _owner = owner; _view = view; _buffer = sourceBuffer; //View.Caret.PositionChanged += CaretPositionChanged; //View.LayoutChanged += ViewLayoutChanged; // Get the name of the underlying document buffer ITextDocument document; if (owner.TextDocumentFactoryService.TryGetTextDocument(view.TextDataModel.DocumentBuffer, out document)) { this.FilePath = document.FilePath; document.FileActionOccurred += (sender, ea) => { if (ea.FileActionType == FileActionTypes.DocumentRenamed) { this.FilePath = ea.FilePath; } }; // TODO we should listen for the file changing its name (ITextDocument.FileActionOccurred) } this.ErrorsSnapshot = new SpellingErrorsSnapshot(this.FilePath, 0, new NormalizedSnapshotSpanCollection(), new ReadOnlyCollection <MyXmlAttribute>(new MyXmlAttribute[0])); _owner.AddSpellChecker(this); view.Closed += (sender, ea) => { _owner.RemoveSpellChecker(this); if (_loader != null) { _loader.DocumentDataUpdated -= this.OnDocumentDataUpdated; } }; var textViewAdapter = view.GetVsTextView(); if (!ErrorHandler.Failed(textViewAdapter.GetBuffer(out var textLines))) { IVsUserData userData = textLines as IVsUserData; if (userData != null) { Guid id = typeof(XmlKeyRefCompletionCommandHandler).GUID; userData.GetData(ref id, out var cmdHandler); _loader = (cmdHandler as XmlKeyRefCompletionCommandHandler)?.DocumentDataLoader; if (_loader != null) { _loader.DocumentDataUpdated += this.OnDocumentDataUpdated; } } } }