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
fix(core): avoid duplicating comments in TestBed teardown migration #43776
Closed
crisbeto
wants to merge
1
commit into
angular:master
from
crisbeto:43739/test-bed-duplicate-comments
Closed
fix(core): avoid duplicating comments in TestBed teardown migration #43776
crisbeto
wants to merge
1
commit into
angular:master
from
crisbeto:43739/test-bed-duplicate-comments
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
Currently the TestBed teardown migration is set up in a similar way to all other migrations where we take a `CallExpression`, add a parameter to it, print it, and replace the existing call. The problem is that doing so while preserving the `expression` of the original `CallExpression` can cause comments to be duplicated. This can happen quite frequently, because by default the CLI generates comments before `initTestModule` calls. To work around it, these changes make the migration more precise by inserting a new parameter or replacing and existing one using string manipulation. This requires a bit more code, but it's more reliable than the following alternatives: 1. Using `getFullStart` and `getFullWidth` to replace the node. This would work with our current setup, but the problem is that `getFullStart` also includes whitespace and newlines before the leading comment. This can cause us to mess up the user's formatting and figuring out which whitespace to keep and which one to remove is tricky. 2. Recreating the `CallExpression.expression` when constructing the new node. This would also work since it'll drop any existing comments, but the problem is that `CallExpression.expression` can be a wide variety of nodes which we would have to account for. We can't use `getMutableClone`, because it preserves the comments. Fixes angular#43739.
crisbeto
added
action: review
The PR is still awaiting reviews from at least one requested reviewer
area: core
Issues related to the framework runtime
target: rc
This PR is targeted for the next release-candidate
labels
Oct 8, 2021
devversion
approved these changes
Oct 8, 2021
crisbeto
added
action: merge
The PR is ready for merge by the caretaker
merge: caretaker note
Alert the caretaker performing the merge to check the PR for an out of normal action needed or note
and removed
action: review
The PR is still awaiting reviews from at least one requested reviewer
labels
Oct 8, 2021
Merge assistance: this PR only touches migration code so it doesn't need a presubmit. |
atscott
removed
the
merge: caretaker note
Alert the caretaker performing the merge to check the PR for an out of normal action needed or note
label
Oct 11, 2021
This PR was merged into the repository by commit 08caead. |
atscott
pushed a commit
that referenced
this pull request
Oct 11, 2021
…43776) Currently the TestBed teardown migration is set up in a similar way to all other migrations where we take a `CallExpression`, add a parameter to it, print it, and replace the existing call. The problem is that doing so while preserving the `expression` of the original `CallExpression` can cause comments to be duplicated. This can happen quite frequently, because by default the CLI generates comments before `initTestModule` calls. To work around it, these changes make the migration more precise by inserting a new parameter or replacing and existing one using string manipulation. This requires a bit more code, but it's more reliable than the following alternatives: 1. Using `getFullStart` and `getFullWidth` to replace the node. This would work with our current setup, but the problem is that `getFullStart` also includes whitespace and newlines before the leading comment. This can cause us to mess up the user's formatting and figuring out which whitespace to keep and which one to remove is tricky. 2. Recreating the `CallExpression.expression` when constructing the new node. This would also work since it'll drop any existing comments, but the problem is that `CallExpression.expression` can be a wide variety of nodes which we would have to account for. We can't use `getMutableClone`, because it preserves the comments. Fixes #43739. PR Close #43776
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
action: merge
The PR is ready for merge by the caretaker
area: core
Issues related to the framework runtime
cla: yes
target: rc
This PR is targeted for the next release-candidate
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.
Currently the TestBed teardown migration is set up in a similar way to all other migrations where we take a
CallExpression
, add a parameter to it, print it, and replace the existing call. The problem is that doing so while preserving theexpression
of the originalCallExpression
can cause comments to be duplicated. This can happen quite frequently, because by default the CLI generates comments beforeinitTestModule
calls.To work around it, these changes make the migration more precise by inserting a new parameter or replacing and existing one using string manipulation. This requires a bit more code, but it's more reliable than the following alternatives:
getFullStart
andgetFullWidth
to replace the node. This would work with our current setup, but the problem is thatgetFullStart
also includes whitespace and newlines before the leading comment. This can cause us to mess up the user's formatting and figuring out which whitespace to keep and which one to remove is tricky.CallExpression.expression
when constructing the new node. This would also work since it'll drop any existing comments, but the problem is thatCallExpression.expression
can be a wide variety of nodes which we would have to account for. We can't usegetMutableClone
, because it preserves the comments.Fixes #43739.