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)); }
private static async Task PrecalculateBasicInfoAsync(Document document, CancellationToken cancellationToken) { // we already have information. move on if (await SyntaxTreeIdentifierInfo.PrecalculatedAsync(document, cancellationToken).ConfigureAwait(false) && await SyntaxTreeContextInfo.PrecalculatedAsync(document, cancellationToken).ConfigureAwait(false)) { return; } var data = await CreateInfoAsync(document, cancellationToken).ConfigureAwait(false); await data.Item1.SaveAsync(document, cancellationToken).ConfigureAwait(false); await data.Item2.SaveAsync(document, cancellationToken).ConfigureAwait(false); }
private static async Task PrecalculateAdvancedInfoAsync(Document document, CancellationToken cancellationToken) { // we do not support precalculating opened file. if (document.IsOpen()) { return; } // we already have information. move on if (await SyntaxTreeIdentifierInfo.IdentifierSetPrecalculatedAsync(document, cancellationToken).ConfigureAwait(false)) { return; } await SyntaxTreeIdentifierInfo.SaveIdentifierSetAsync(document, cancellationToken).ConfigureAwait(false); }
private static IList <SyntaxToken> GetTokensFromText( ISyntaxFactsService syntaxFacts, Document document, VersionStamp version, SyntaxNode root, SourceText content, string text, Func <SyntaxToken, bool> candidate, CancellationToken cancellationToken) { if (text.Length > 0) { using (var positions = SharedPools.BigDefault <List <int> >().GetPooledObject()) { if (SyntaxTreeIdentifierInfo.TryGetIdentifierLocations(document, version, text, positions.Object, cancellationToken)) { return(GetTokensFromText(root, positions.Object, text, candidate, cancellationToken).ToList()); } } return(GetTokensFromText(syntaxFacts, root, content, text, candidate, cancellationToken).ToList()); } return(SpecializedCollections.EmptyList <SyntaxToken>()); }