提交 2c05db0e 编写于 作者: C CyrusNajmabadi

Key off of ProjectState so that we don't recompute when a project hasn't actually changed.

上级 c285ad95
......@@ -47,18 +47,20 @@ private static void FreeSymbolMap(MultiDictionary<string, ISymbol> symbolMap)
/// Cache of project to the checksum for it so that we don't have to expensively recompute
/// this each time we get a project.
/// </summary>
private static ConditionalWeakTable<Project, AsyncLazy<Checksum>> s_projectToSourceChecksum =
new ConditionalWeakTable<Project, AsyncLazy<Checksum>>();
private static ConditionalWeakTable<ProjectState, AsyncLazy<Checksum>> s_projectToSourceChecksum =
new ConditionalWeakTable<ProjectState, AsyncLazy<Checksum>>();
public static Task<Checksum> GetSourceSymbolsChecksumAsync(Project project, CancellationToken cancellationToken)
{
var workspace = project.Solution.Workspace;
var lazy = s_projectToSourceChecksum.GetValue(
project, p => new AsyncLazy<Checksum>(c => ComputeSourceSymbolsChecksumAsync(p, c), cacheResult: true));
project.State, p => new AsyncLazy<Checksum>(c => ComputeSourceSymbolsChecksumAsync(workspace, p, c), cacheResult: true));
return lazy.GetValueAsync(cancellationToken);
}
private static async Task<Checksum> ComputeSourceSymbolsChecksumAsync(Project project, CancellationToken cancellationToken)
private static async Task<Checksum> ComputeSourceSymbolsChecksumAsync(
Workspace workspace, ProjectState projectState, CancellationToken cancellationToken)
{
// The SymbolTree for source is built from the source-symbols from the project's compilation's
// assembly. Specifically, we only get the name, kind and parent/child relationship of all the
......@@ -66,14 +68,14 @@ private static async Task<Checksum> ComputeSourceSymbolsChecksumAsync(Project pr
// changed. The only thing that can make those source-symbols change in that manner are if
// the text of any document changes, or if options for the project change. So we build our
// checksum out of that data.
var serializer = new Serializer(project.Solution.Workspace);
var projectStateChecksums = await project.State.GetStateChecksumsAsync(cancellationToken).ConfigureAwait(false);
var serializer = new Serializer(workspace);
var projectStateChecksums = await projectState.GetStateChecksumsAsync(cancellationToken).ConfigureAwait(false);
// Order the documents by FilePath. Default ordering in the RemoteWorkspace is
// to be ordered by Guid (which is not consistent across VS sessions).
var textChecksumsTasks = project.Documents.OrderBy(d => d.FilePath, StringComparer.Ordinal).Select(async d =>
var textChecksumsTasks = projectState.DocumentStates.OrderBy(d => d.Value.FilePath, StringComparer.Ordinal).Select(async d =>
{
var documentStateChecksum = await d.State.GetStateChecksumsAsync(cancellationToken).ConfigureAwait(false);
var documentStateChecksum = await d.Value.GetStateChecksumsAsync(cancellationToken).ConfigureAwait(false);
return documentStateChecksum.Text;
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册