-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Semantic snippets: handle case with inline statement snippets before member access expression #74966
Merged
akhera99
merged 2 commits into
dotnet:main
from
DoctorKrolic:inline-snippets-member-access
Sep 11, 2024
Merged
Semantic snippets: handle case with inline statement snippets before member access expression #74966
akhera99
merged 2 commits into
dotnet:main
from
DoctorKrolic:inline-snippets-member-access
Sep 11, 2024
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
… position to handle member access expression case
dotnet-issue-labeler
bot
added
Area-IDE
untriaged
Issues and PRs which have not yet been triaged by a lead
labels
Aug 31, 2024
dotnet-policy-service
bot
added
Community
The pull request was submitted by a contributor who is not a Microsoft employee.
VSCode
labels
Aug 31, 2024
3 tasks
@akhera99 PTAL |
akhera99
approved these changes
Sep 10, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you for the contribution!
Can we merge this one please? |
333fred
added a commit
to 333fred/roslyn
that referenced
this pull request
Sep 13, 2024
* upstream/main: (45 commits) Adjust an assert in EmitArgument (dotnet#75067) Switch to new VMR control set (dotnet#75056) Disallow ref assignment to ternary or another ref assignment (dotnet#75076) Move some emit tests from Emit2 to Emit3 to avoid hitting UserString heap limit (dotnet#75091) BindAttributeCore - use proper binder to avoid an attribute binding cycle (dotnet#75060) Remove buggy IsPublic method from TypeAttributesExtensions (dotnet#75081) Include initial filter node when searching for nodes to order modifiers Remove additional Gitter link (dotnet#75086) Remove newlines between test run information sections Log messages for Test Results Fix stack adjustment when emitting stackalloc (dotnet#75042) Lock translation of strings used to demonstrate identifier naming styles docs: Correct SDK version in documentation to match global.json (dotnet#75038) Add a test observing lack of an issue. (dotnet#75057) Fix preview refresh on selection for enum flags checkboxes Semantic snippets: handle case with inline statement snippets before member access expression (dotnet#74966) Configure release/vscode branch for nuget publishing Remove MS.CA.Test.Resources.Proprietary PackageReference (dotnet#75037) Allow suppressing nullability warnings in more ref scenarios (dotnet#74498) Update dependencies from https://github.com/dotnet/arcade build 20240909.6 (dotnet#75040) ...
This was referenced Sep 14, 2024
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.
Previously inline statement snippets chacked, wherther they are part of a member access expression with parent being an expression statament. The second part of the check makes sure, that in cases like
Invocation(validType.$$)
the snippet isn't offered since we cannot insert a statement inside an invocation argument. That logic had ta flaw. It couldn't handle case like this:Here syntractically we have the same thing as
validType.$$Console.WriteLine();
, therefore a snippet is executed in a hierarchy of expressions, thus by the previous rules is invalid there. But it is obvious, that this is just a state-of-the-world during typing and the snippet should be offered. Thus I changed how the core logic works. Instead of traversing a potentially complicated subtree I made a check, whether a position before the inline expression is suitable to insert statement into. This both guards us againstInvocation(validType.$$)
, but also suggests snippet in the primary case we want to fix. However, I didn't want snippets to appear inside a line as you edit it, e.g. I don't thinkforeach
snippet will be useful if you are insideenumerable.$$Select(...
, in such case you probably want to add a method to the call chain or something similar. Therefore I made an additional line checks, so now inline statement snippet can only be the last "member access" on the line. Yes, we usually compute completions based only on previous tokens, but snippets stand out quite a bit, so I think that such approach to them is ok