-
Notifications
You must be signed in to change notification settings - Fork 198
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
Cleanup CompletionTriggerAndCommitCharacters #11600
Merged
DustinCampbell
merged 9 commits into
dotnet:main
from
DustinCampbell:cleanup-triggers-and-commit-chars
Mar 10, 2025
Merged
Cleanup CompletionTriggerAndCommitCharacters #11600
DustinCampbell
merged 9 commits into
dotnet:main
from
DustinCampbell:cleanup-triggers-and-commit-chars
Mar 10, 2025
Conversation
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
Because this type only has a single dependency in Visual Studio, it's a bit overkill to include it in the MEF composition. Instead, that dependency (CohostDocumentCompletionEndpoint) can import LanguageServerFeatureOptions and create an instance of CompletionTriggerAndCommitCharacters.
Rather than directly exposing a set, this change adds instance methods to test for valid C# triggers.
Rather than directly exposing a set, this change adds instance methods to test for valid Razor triggers.
Rather than directly exposing a set, this change adds an instance method to test for the Razor delegation trigger character (i.e. '@').
Rather than directly exposing a set, this change adds instance methods to test for valid delegation triggers. Note this change requires a bit of a test change, but I think it's an improvement since the original test was verifying a Razor scenario that could never happen.
Rather than directly exposing a set, this change adds instance methods to test for valid HTML triggers.
This change transforms CompletionTriggerAndCommitCharacters from being a partly static and partly instance service to being fully instance-based. Here is a summary of the changes: - All collections are now private and operations on them are exposed via instance methods. - I've switched from FrozenSet<string> to HashSet<char>. Honestly, I doubt we were getting much value from FrozenSet<string> for strings with the same length. - All initialization is performed in the constructor. - Accessing AllTriggerCharacters or AllCommitCharacters returns a new array each time to avoid modifying the original array. - The Razor transition character ('@') is now a constant rather than a set with a single element.
ryzngard
approved these changes
Mar 10, 2025
...c/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionTriggerAndCommitCharacters.cs
Outdated
Show resolved
Hide resolved
...c/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionTriggerAndCommitCharacters.cs
Outdated
Show resolved
Hide resolved
davidwengier
approved these changes
Mar 10, 2025
...c/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionTriggerAndCommitCharacters.cs
Outdated
Show resolved
Hide resolved
Rather than returning mutable array copies from AllTriggerCharacters and AllCommitCharacters, return an ImmutableArray and let the call sites make the copies as needed.
ryzngard
added a commit
to dotnet/vscode-csharp
that referenced
this pull request
Mar 13, 2025
[View Complete Diff of Changes](https://github.com/dotnet/razor/compare/2798396c3481573aa49f9c792179ebbb5e183dca...c0bd75d99369adcd5a2f7e1f1ac42bee8a3bf619?w=1) * Move VS Code To Pull Diagnostics (#11602) (PR: [#11602](dotnet/razor#11602)) * Upgrade to net9 (#11535) (PR: [#11535](dotnet/razor#11535)) * Cleanup CompletionTriggerAndCommitCharacters (#11600) (PR: [#11600](dotnet/razor#11600)) * Add constraints to CaptureParameters method (#11530) (PR: [#11530](dotnet/razor#11530)) * [main] Update dependencies from dotnet/source-build-reference-packages (#11598) (PR: [#11598](dotnet/razor#11598)) * [FUSE] Layout mapping (#11567) (PR: [#11567](dotnet/razor#11567)) * Stop running cohosting tests with and without FUSE (#11592) (PR: [#11592](dotnet/razor#11592))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recently, I was taking a look at completion performance and noticed that
CompletionTriggerAndCommitCharacters
has gotten into a halfway state where it's sometimes accessed statically, and sometimes as an instance. This change refactorsCompletionTriggerAndCommitCharacters
to be fully instance-based and cleans it up significantly.