private void UpdateReferences(ICodeDocument document, DocumentReferencedIdManager idManager) { // Note: if this proves to be too slow with large documents, we can potentially optimize the finding // of references by only considering the parts of the AST which occur after the Offset at which the text change began // (we can find this by getting hold of the TextSnapshotChangedEventArgs) var potentialReferences = FindPotentialReferences(document).ToList(); var newReferences = potentialReferences.Where(idManager.NeedsChecking).ToArray(); if (newReferences.Any()) { DocumentIdCheckHelpers.GetActualIds(newReferences) .ContinueOnSuccessInTheUIThread(ids => { idManager.AddKnownIds(ids); idManager.AddKnownInvalidIds(newReferences.Except(ids, StringComparer.OrdinalIgnoreCase)); idManager.UpdateCurrentIds(potentialReferences); }); } }
public PropertyValueLinkTagger(ICodeDocument document) : base("PropertyValueLinkTagger", null, document, true) { document.ParseDataChanged += delegate { UpdateTags(); }; idManager = document.Properties.GetOrCreateSingleton(() => new DocumentReferencedIdManager()); idManager.Changed += delegate { UpdateTags(); }; }