Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid linking back to the original TreeSource in document state updates if the associated lazy is already completed #75355

Conversation

ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented Oct 2, 2024

Previously, I was seeing pull diagnostics requests for linked documents as computing the changes between the original and current version of the file. Instead, change the code where we determine the tree source to use the latest tree source if it's been calculated.

…es if the associated lazy is already completed

Previously, I was seeing pull diagnostics requests for linked documents as computing the changes between the original and current version of the file. Instead, change the code where we determine the tree source to use the latest tree source if it's been calculated.
@ToddGrun ToddGrun requested a review from a team as a code owner October 2, 2024 20:48
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 2, 2024
@@ -69,8 +69,11 @@ public DocumentState UpdateTextAndTreeContents(
// We only need to look one deep here as we'll pull that tree source forward to our level. If another link is
// later added to us, it will do the same thing.
var originalTreeSource = this.TreeSource;
if (originalTreeSource is LinkedFileReuseTreeAndVersionSource linkedFileTreeAndVersionSource)
if (originalTreeSource is LinkedFileReuseTreeAndVersionSource linkedFileTreeAndVersionSource
&& !linkedFileTreeAndVersionSource.TryGetValue(out var _))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this def needs docs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively, if you are able to get the value from the linkedSource, why not pass it along instead? And if you can't, you defer to the original tree source it points to.

Also, i think we should doc .OriginalTreeSource. Mention that it's there to produce a long chain if we haven't computed the intermediary steps. But if we have, we'll use that value instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved code around a bit and added some comments.

@CyrusNajmabadi CyrusNajmabadi self-requested a review October 2, 2024 21:38
@CyrusNajmabadi
Copy link
Member

Removed my approval. I would like to see if this can be potentially different.

@@ -24,7 +24,26 @@ private sealed class LinkedFileReuseTreeAndVersionSource(
ITreeAndVersionSource originalTreeSource,
AsyncLazy<TreeAndVersion> lazyComputation) : ITreeAndVersionSource
{
public readonly ITreeAndVersionSource OriginalTreeSource = originalTreeSource;
// Used as a fallback value in GetComputedTreeAndVersionSource to avoid long lazy chain evaluations.
private readonly ITreeAndVersionSource _originalTreeSource = originalTreeSource;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc comments :)

/// </remarks>
public ITreeAndVersionSource GetNonChainedTreeAndVersionSource()
{
if (TryGetValue(out _))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conditional expr.

@ToddGrun ToddGrun enabled auto-merge (squash) October 3, 2024 18:04
@ToddGrun ToddGrun merged commit 9ff81f4 into dotnet:main Oct 3, 2024
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants