private async Task <string> GetDocumentId() { if (!string.IsNullOrEmpty(DocumentId)) { return(DocumentId); } if (!DocumentIdCheckHelpers.IsPotentialId(PotentialDocumentId)) { return(null); } try { var ids = await DocumentIdCheckHelpers.GetActualIds(new[] { PotentialDocumentId }); if (ids.Count == 1) { return(PotentialDocumentId); } } catch { // not bothered about exceptions here } return(null); }
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); }); } }