Ensure we only ask for a symbol's documentation comment once #68452
Merged
jasonmalinowski merged 6 commits intodotnet:mainfrom Jun 7, 2023
Merged
Conversation
This also removes the IStructuralTypeDisplayService we were passing around when we already had (or coud have) language services available.
Right now computing hover information is a fairly expensive portion of an LSIF dump. One small hotspot was we were fetching documentation comment information at least twice: once for the documentation itself and once for computing the exception info. This ensures we fetch it just once per generation. This also generally cleans up the AbstractSymbolDescriptionBuilder: 1. Duplicate local functions for returns/value is unified. 2. Removes a bunch of specific logic in the builder which supported finding the correct documentation in favor of the helper we already had. To support the second one, I added some methods to DocumentationComment to return a DocumentationComment with the contents of a <param> tag as the summary text for a specific parameter; this allows everything else to be able to operate as if that's a regular summary tag and removes some special cases in the code.
jasonmalinowski
commented
Jun 6, 2023
Member
Author
There was a problem hiding this comment.
VS 17.6 fixed the issues around .dic files having to be UTF-16 encoded, so we can just do this now.
jasonmalinowski
commented
Jun 6, 2023
| private void AddDocumentationContent(ISymbol symbol) | ||
| private void AddDocumentationContent(ISymbol symbol, DocumentationComment documentationComment) | ||
| { | ||
| var formatter = Services.GetRequiredLanguageService<IDocumentationCommentFormattingService>(_semanticModel.Language); |
Member
Author
There was a problem hiding this comment.
This logic was duplicated in ISymbolExtensions_2.cs, so it's unified now.
jasonmalinowski
commented
Jun 7, 2023
| internal abstract partial class AbstractSymbolDisplayService : ISymbolDisplayService | ||
| { | ||
| protected readonly LanguageServices Services; | ||
| protected readonly IStructuralTypeDisplayService AnonymousTypeDisplayService; |
Member
Author
There was a problem hiding this comment.
For some reason we were passing around both LanguageServices and also one instance of a specific language service, so cleaned up.
jasonmalinowski
commented
Jun 7, 2023
| return text; | ||
| } | ||
|
|
||
| public DocumentationComment? GetParameter(string parameterName) |
Member
Author
There was a problem hiding this comment.
I should add some better doc comments here -- but to simplify handling in the other parts of the code, the idea here is if we have a member, we can create a new DocumentationComment object that has a <summary> tag with the same contents, so everything else can treat that identically.
CyrusNajmabadi
approved these changes
Jun 7, 2023
This file contains hidden or 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
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.
Right now computing hover information is a fairly expensive portion of an LSIF dump. One small hotspot was we were fetching documentation comment information at least twice: once for the documentation itself and once for computing the exception info. This ensures we fetch it just once per generation.
This also generally cleans up the AbstractSymbolDescriptionBuilder:
To support the second one, I added some methods to DocumentationComment to return a DocumentationComment with the contents of a tag as the summary text for a specific parameter; this allows everything else to be able to operate as if that's a regular summary tag and removes some special cases in the code.
This by itself isn't the hugest speedup (maybe a couple of percent) but generally makes the code easier to follow and easier to see where the remaining expensive bits are in traces.