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

Snippet refactoring 2 #74767

Merged
merged 3 commits into from
Aug 15, 2024
Merged

Conversation

DoctorKrolic
Copy link
Contributor

Follow up to #74712

2 changes here:

  1. Do not pass SnippetContext around by in reference. The only actual data, that SnippetContext holds is 1 reference to a SyntaxContext. Therefore passing it around by in doesn't win anything, but adds unnecessary cognitive overhead when reading that code
  2. Since SnippetContext already holds a SyntaxContext instance, all async work of getting syntax tree and semantic model from the document has already been done. Therefore it isn't practical to keep this path async. I remember there was a discussion, that semantic snippets engine is a potential candidate for becoming public API. And since there is no way SyntaxContext become public, I additionaly exposed SemanticModel as a public property of SnippetContext. That way a potential API user can get everything they need without having to deal with any async stuff:
  • Syntax tree: context.SemanticModel.SyntaxTree
  • Syntax root: context.SemanticModel.SyntaxTree.GetRoot()
  • Semantic model: context.SemanticModel
  • Compilation: context.SemanticModel.Compilation

@DoctorKrolic DoctorKrolic requested a review from a team as a code owner August 15, 2024 06:51
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 15, 2024
@dotnet-policy-service dotnet-policy-service bot added Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode labels Aug 15, 2024
@DoctorKrolic
Copy link
Contributor Author

@akhera99 PTAL

Copy link
Member

@akhera99 akhera99 left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the contribution!

@akhera99 akhera99 merged commit e1c8615 into dotnet:main Aug 15, 2024
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Aug 15, 2024
@DoctorKrolic DoctorKrolic deleted the snippet-refactoring-2 branch August 16, 2024 04:54
@dibarbet dibarbet modified the milestones: Next, 17.12 P2 Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. 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.

4 participants