Fix error messages for ast viewers and update caching#753
Merged
aeisenberg merged 1 commit intogithub:mainfrom Feb 11, 2021
Merged
Fix error messages for ast viewers and update caching#753aeisenberg merged 1 commit intogithub:mainfrom
aeisenberg merged 1 commit intogithub:mainfrom
Conversation
This commit does two things: 1. Add more appropriate error messages when asts can't be viewed. 2. Make better use of cached operations for asts. In the past, we were not actually using cached operations. Each time an ast view request occurred, we created a new TemplatePrintAstProvider instance. With this change, we reuse the TemplatePrintAstProvider between calls and ensure that an AST that is called once is reused on subsequent calls.
5af9c2a to
514d8a8
Compare
| } | ||
| const queryResults = await this.cache.get(document.uri.toString(), progress, token); | ||
|
|
||
| return new AstBuilder( |
Contributor
There was a problem hiding this comment.
Looks like we now unconditionally return an AstBuilder. Do you still need to return undefined if we didn't find any results?
Contributor
Author
There was a problem hiding this comment.
The cached operation always returns QueryWithResults or it throws. Since the call to get the cached item always has the same type as the operation itself, we are guaranteed that the value will never be undefined.
adityasharad
approved these changes
Feb 11, 2021
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.
This commit does two things:
not actually using cached operations. Each time an ast view request
occurred, we created a new TemplatePrintAstProvider instance. With this
change, we reuse the TemplatePrintAstProvider between calls and ensure
that an AST that is called once is reused on subsequent calls.
I received complaints from users such as @sj that AST viewing was erroring out and it wasn't clear why it was happening.
And the second part of this change will make subsequent calls to view an AST of a file extremely fast.
Checklist
@github/docs-content-dsphas been cc'd in all issues for UI or other user-facing changes made by this pull request.