Пример #1
0
        public static async Task <SyntaxTreeContextInfo> GetContextInfoAsync(Document document, CancellationToken cancellationToken)
        {
            SyntaxTreeContextInfo info;

            if (contextSnapshotCache.TryGetValue(document, out info))
            {
                return(info);
            }

            info = await SyntaxTreeContextInfo.LoadAsync(document, cancellationToken).ConfigureAwait(false);

            if (info != null)
            {
                return(contextSnapshotCache.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.Item2;
            return(contextSnapshotCache.GetValue(document, _ => info));
        }
Пример #2
0
        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);
        }