-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…#10140) Fixes #10158 I recommend reviewing commit-by-commit. Razor has had a `BatchingWorkQueue` for a long while that has dubious semantics. It is used by three features: - `OpenDocumentGenerator` - Listens for document updates, computes generated output for each, and notifies listeners when a document has been processed. - `WorkspaceSemanticTokensRefreshPublisher` - Called in the server to send the client `semanticTokens/refresh` notifications. This really sort of abuses `BatchingWorkQueue` just for debouncing and only send notifications every 250 milliseconds. - `WorkspaceProjectStateChangeDetector` - Listens for Roslyn workspace and Razor project manager changes and calls into `IProjectWorkspaceStateGenerator.Update(...)` when a change occurs. This change fully replaces `BatchingWorkQueue` with a copy of Roslyn's `AsyncBatchingWorkQueue`, which has consistent semantics and has been battle-hardened for years. I've updated `OpenDocumentGenerator` and `WorkspaceProjectStateChangeDetector` above to use `AsyncBatchingWorkQueue`. For `WorkspaceSemanticTokensRefreshPublisher` (now `WorkspaceSemanticTokensRefreshNotifier`), I've removed the `BatchingWorkQueue` altogether and replaced it with simpler logic that debounces and calls `Task.Delay(...)`. Many thanks to @CyrusNajmabadi for his help with `AsyncBatchingWorkQueue`. @dotnet/razor-compiler: The only relevant compiler changes are in shared code.
- Loading branch information
Showing
53 changed files
with
1,878 additions
and
1,511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...Razor/src/Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace/TaskDelayScheduler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/OpenDocumentGenerator.Comparer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using Microsoft.CodeAnalysis.Razor; | ||
using Microsoft.CodeAnalysis.Razor.ProjectSystem; | ||
|
||
namespace Microsoft.AspNetCore.Razor.LanguageServer; | ||
|
||
internal partial class OpenDocumentGenerator | ||
{ | ||
private sealed class Comparer : IEqualityComparer<IDocumentSnapshot> | ||
{ | ||
public static readonly Comparer Instance = new(); | ||
|
||
private Comparer() | ||
{ | ||
} | ||
|
||
public bool Equals(IDocumentSnapshot? x, IDocumentSnapshot? y) | ||
{ | ||
if (x is null) | ||
{ | ||
return y is null; | ||
} | ||
else if (y is null) | ||
{ | ||
return false; | ||
} | ||
|
||
return FilePathComparer.Instance.Equals(x.FilePath, y.FilePath); | ||
} | ||
|
||
public int GetHashCode(IDocumentSnapshot obj) | ||
{ | ||
return FilePathComparer.Instance.GetHashCode(obj); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.