fix: respect herecomments when computing function bounds#162
Merged
alangpierce merged 2 commits intodecaffeinate:masterfrom Feb 19, 2017
Merged
fix: respect herecomments when computing function bounds#162alangpierce merged 2 commits intodecaffeinate:masterfrom
alangpierce merged 2 commits intodecaffeinate:masterfrom
Conversation
Fixes decaffeinate/decaffeinate#687 Previously, the bounds of a function body were shrunk to only include semantic tokens, which could cause a block comment to get moved outside the body and be improperly indented after the normalize step. Now, we include the comments as part of the body. This is a small change that gets this case to work, but it might be that in the future we'll want to avoid all AST location adjustment and/or put block comments in the AST.
Collaborator
eventualbuddha
left a comment
There was a problem hiding this comment.
What happens when a block comment follows a function body but isn't indented to match?
Member
Author
|
I think the block comment is still viewed as outside the function, since the CoffeeScript parser doesn't include it in the function bounds in the first place. This code path that I'm changing is just shrinking the location data from the CoffeeScript parser, but if the CoffeeScript parser got everything correct, I think it wouldn't be necessary. But I can add a test to double-check. |
Also change the test name from "herecomment" to "block comment" to be consistent with other tests/code.
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.
Fixes decaffeinate/decaffeinate#687
Previously, the bounds of a function body were shrunk to only include semantic
tokens, which could cause a block comment to get moved outside the body and be
improperly indented after the normalize step. Now, we include the comments as
part of the body.
This is a small change that gets this case to work, but it might be that in the
future we'll want to avoid all AST location adjustment and/or put block comments
in the AST.