public static async Task <SyntaxTreeIdentifierInfo> GetIdentifierInfoAsync(Document document, CancellationToken cancellationToken) { SyntaxTreeIdentifierInfo info; if (identifierSnapshotCache.TryGetValue(document, out info)) { return(info); } info = await SyntaxTreeIdentifierInfo.LoadAsync(document, cancellationToken).ConfigureAwait(false); if (info != null) { return(identifierSnapshotCache.GetValue(document, _ => info)); } // alright, we don't have cached information, re-calcuate them here. var data = await CreateInfoAsync(document, cancellationToken).ConfigureAwait(false); // okay, persist this info. await data.Item1.SaveAsync(document, cancellationToken).ConfigureAwait(false); await data.Item2.SaveAsync(document, cancellationToken).ConfigureAwait(false); info = data.Item1; return(identifierSnapshotCache.GetValue(document, _ => info)); }