{"action":"created","comment":{"url":"https://api.github.com/repos/jashkenas/coffeescript/pulls/comments/130316963","pull_request_review_id":53176846,"id":130316963,"diff_hunk":"@@ -57,6 +60,34 @@ exports.Base = class Base\n   compile: (o, lvl) ->\n     fragmentsToText @compileToFragments o, lvl\n \n+  # Occasionally a node is compiled multiple times, for example to get the name\n+  # of a variable to add to scope tracking. When we know that a “premature”\n+  # compilation won’t result in comments being output, set those comments aside\n+  # so that they’re preserved for a later `compile` call that will result in\n+  # the comments being included in the output.\n+  compileWithoutComments: (o, lvl, method = 'compile') ->\n+    if @comments\n+      @ignoreTheseCommentsTemporarily = @comments","path":"src/nodes.coffee","position":45,"original_position":45,"commit_id":"e116c853aae3a85e336e76a69b6cd8d335f5602d","original_commit_id":"e116c853aae3a85e336e76a69b6cd8d335f5602d","user":{"login":"connec","id":160652,"avatar_url":"https://avatars2.githubusercontent.com/u/160652?v=4","gravatar_id":"","url":"https://api.github.com/users/connec","html_url":"https://github.com/connec","followers_url":"https://api.github.com/users/connec/followers","following_url":"https://api.github.com/users/connec/following{/other_user}","gists_url":"https://api.github.com/users/connec/gists{/gist_id}","starred_url":"https://api.github.com/users/connec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/connec/subscriptions","organizations_url":"https://api.github.com/users/connec/orgs","repos_url":"https://api.github.com/users/connec/repos","events_url":"https://api.github.com/users/connec/events{/privacy}","received_events_url":"https://api.github.com/users/connec/received_events","type":"User","site_admin":false},"body":"*Edit:* I see it affects `unwrapped` as well, but we could still keep two local variables (e.g. `comments` and `unwrappedComments`).","created_at":"2017-07-31T10:14:06Z","updated_at":"2017-07-31T10:14:06Z","html_url":"https://github.com/jashkenas/coffeescript/pull/4572#discussion_r130316963","pull_request_url":"https://api.github.com/repos/jashkenas/coffeescript/pulls/4572","_links":{"self":{"href":"https://api.github.com/repos/jashkenas/coffeescript/pulls/comments/130316963"},"html":{"href":"https://github.com/jashkenas/coffeescript/pull/4572#discussion_r130316963"},"pull_request":{"href":"https://api.github.com/repos/jashkenas/coffeescript/pulls/4572"}}},"pull_request":{"url":"https://api.github.com/repos/jashkenas/coffeescript/pulls/4572","id":125546174,"html_url":"https://github.com/jashkenas/coffeescript/pull/4572","diff_url":"https://github.com/jashkenas/coffeescript/pull/4572.diff","patch_url":"https://github.com/jashkenas/coffeescript/pull/4572.patch","issue_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4572","number":4572,"state":"open","locked":false,"title":"[CS2] Comments","user":{"login":"GeoffreyBooth","id":456802,"avatar_url":"https://avatars2.githubusercontent.com/u/456802?v=4","gravatar_id":"","url":"https://api.github.com/users/GeoffreyBooth","html_url":"https://github.com/GeoffreyBooth","followers_url":"https://api.github.com/users/GeoffreyBooth/followers","following_url":"https://api.github.com/users/GeoffreyBooth/following{/other_user}","gists_url":"https://api.github.com/users/GeoffreyBooth/gists{/gist_id}","starred_url":"https://api.github.com/users/GeoffreyBooth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GeoffreyBooth/subscriptions","organizations_url":"https://api.github.com/users/GeoffreyBooth/orgs","repos_url":"https://api.github.com/users/GeoffreyBooth/repos","events_url":"https://api.github.com/users/GeoffreyBooth/events{/privacy}","received_events_url":"https://api.github.com/users/GeoffreyBooth/received_events","type":"User","site_admin":false},"body":"This PR aims to reimplement how we compile comments—both block (`### ###` or `/* */`) and end-of-line (`#` or `//`). This would close #4290 per the discussion in #4541. It would also help provide better support for plugins, as discussed in #4540, #4529 and #4563. Once we get this working with comments, the same techniques could apply to embedded JavaScript, which will also help plugins or pre-/postprocessors.\r\n\r\nThe basic idea is that when the lexer consumes a comment, instead of making a token for it, the comment data is attached to a nearby token as a property like our current `locationData`. The comments property hitches a ride on that token through the parser and rewriter, possibly getting moved onto a different token by the rewriter as appropriate; and then in `nodes.coffee` the comment gets output before or after the token it stowed away on.\r\n\r\nBecause the comment never becomes a token, the grammar never touches it; and so you can put block comments anywhere: `foo = 2 ### yo! ### + 3`. The tricky part is that not all tokens make it through the parser; and some that do get jumbled. The rewriter has significant work to do to make sure that the comment makes it across attached to the nearest surviving token, with enough information preserved that the comment can be output sensibly.\r\n\r\nSo, have you ever wondered what magic awaits in the rewriter, where streams of tokens are mutated while being looped over? Ever glimpsed `parser.js` and pondered the mysterious `yy` variable and gargantuan `switch` statement? Read `grammar.coffee` and considered how the hell the function at the top somehow gets rendered into JavaScript in `parser.js`, and what it does there? Well, this PR is for you!","created_at":"2017-06-14T09:12:13Z","updated_at":"2017-07-31T10:14:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ade3f0c95ae9476d2fc653222462d155f5c966f5","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/jashkenas/coffeescript/pulls/4572/commits","review_comments_url":"https://api.github.com/repos/jashkenas/coffeescript/pulls/4572/comments","review_comment_url":"https://api.github.com/repos/jashkenas/coffeescript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4572/comments","statuses_url":"https://api.github.com/repos/jashkenas/coffeescript/statuses/e116c853aae3a85e336e76a69b6cd8d335f5602d","head":{"label":"GeoffreyBooth:comments","ref":"comments","sha":"e116c853aae3a85e336e76a69b6cd8d335f5602d","user":{"login":"GeoffreyBooth","id":456802,"avatar_url":"https://avatars2.githubusercontent.com/u/456802?v=4","gravatar_id":"","url":"https://api.github.com/users/GeoffreyBooth","html_url":"https://github.com/GeoffreyBooth","followers_url":"https://api.github.com/users/GeoffreyBooth/followers","following_url":"https://api.github.com/users/GeoffreyBooth/following{/other_user}","gists_url":"https://api.github.com/users/GeoffreyBooth/gists{/gist_id}","starred_url":"https://api.github.com/users/GeoffreyBooth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GeoffreyBooth/subscriptions","organizations_url":"https://api.github.com/users/GeoffreyBooth/orgs","repos_url":"https://api.github.com/users/GeoffreyBooth/repos","events_url":"https://api.github.com/users/GeoffreyBooth/events{/privacy}","received_events_url":"https://api.github.com/users/GeoffreyBooth/received_events","type":"User","site_admin":false},"repo":{"id":60229517,"name":"coffeescript","full_name":"GeoffreyBooth/coffeescript","owner":{"login":"GeoffreyBooth","id":456802,"avatar_url":"https://avatars2.githubusercontent.com/u/456802?v=4","gravatar_id":"","url":"https://api.github.com/users/GeoffreyBooth","html_url":"https://github.com/GeoffreyBooth","followers_url":"https://api.github.com/users/GeoffreyBooth/followers","following_url":"https://api.github.com/users/GeoffreyBooth/following{/other_user}","gists_url":"https://api.github.com/users/GeoffreyBooth/gists{/gist_id}","starred_url":"https://api.github.com/users/GeoffreyBooth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GeoffreyBooth/subscriptions","organizations_url":"https://api.github.com/users/GeoffreyBooth/orgs","repos_url":"https://api.github.com/users/GeoffreyBooth/repos","events_url":"https://api.github.com/users/GeoffreyBooth/events{/privacy}","received_events_url":"https://api.github.com/users/GeoffreyBooth/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/GeoffreyBooth/coffeescript","description":"Unfancy JavaScript","fork":true,"url":"https://api.github.com/repos/GeoffreyBooth/coffeescript","forks_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/forks","keys_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/teams","hooks_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/hooks","issue_events_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/issues/events{/number}","events_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/events","assignees_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/assignees{/user}","branches_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/branches{/branch}","tags_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/tags","blobs_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/git/refs{/sha}","trees_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/statuses/{sha}","languages_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/languages","stargazers_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/stargazers","contributors_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/contributors","subscribers_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/subscribers","subscription_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/subscription","commits_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/commits{/sha}","git_commits_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/git/commits{/sha}","comments_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/comments{/number}","issue_comment_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/issues/comments{/number}","contents_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/contents/{+path}","compare_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/merges","archive_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/downloads","issues_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/issues{/number}","pulls_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/pulls{/number}","milestones_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/milestones{/number}","notifications_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/labels{/name}","releases_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/releases{/id}","deployments_url":"https://api.github.com/repos/GeoffreyBooth/coffeescript/deployments","created_at":"2016-06-02T03:25:23Z","updated_at":"2017-05-03T06:09:15Z","pushed_at":"2017-07-31T00:47:13Z","git_url":"git://github.com/GeoffreyBooth/coffeescript.git","ssh_url":"git@github.com:GeoffreyBooth/coffeescript.git","clone_url":"https://github.com/GeoffreyBooth/coffeescript.git","svn_url":"https://github.com/GeoffreyBooth/coffeescript","homepage":"http://coffeescript.org/","size":21348,"stargazers_count":3,"watchers_count":3,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":3,"default_branch":"readme"}},"base":{"label":"jashkenas:2","ref":"2","sha":"6c9cf378117136c198492b3a46bc6fd89fa2ab41","user":{"login":"jashkenas","id":4732,"avatar_url":"https://avatars3.githubusercontent.com/u/4732?v=4","gravatar_id":"","url":"https://api.github.com/users/jashkenas","html_url":"https://github.com/jashkenas","followers_url":"https://api.github.com/users/jashkenas/followers","following_url":"https://api.github.com/users/jashkenas/following{/other_user}","gists_url":"https://api.github.com/users/jashkenas/gists{/gist_id}","starred_url":"https://api.github.com/users/jashkenas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jashkenas/subscriptions","organizations_url":"https://api.github.com/users/jashkenas/orgs","repos_url":"https://api.github.com/users/jashkenas/repos","events_url":"https://api.github.com/users/jashkenas/events{/privacy}","received_events_url":"https://api.github.com/users/jashkenas/received_events","type":"User","site_admin":false},"repo":{"id":441269,"name":"coffeescript","full_name":"jashkenas/coffeescript","owner":{"login":"jashkenas","id":4732,"avatar_url":"https://avatars3.githubusercontent.com/u/4732?v=4","gravatar_id":"","url":"https://api.github.com/users/jashkenas","html_url":"https://github.com/jashkenas","followers_url":"https://api.github.com/users/jashkenas/followers","following_url":"https://api.github.com/users/jashkenas/following{/other_user}","gists_url":"https://api.github.com/users/jashkenas/gists{/gist_id}","starred_url":"https://api.github.com/users/jashkenas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jashkenas/subscriptions","organizations_url":"https://api.github.com/users/jashkenas/orgs","repos_url":"https://api.github.com/users/jashkenas/repos","events_url":"https://api.github.com/users/jashkenas/events{/privacy}","received_events_url":"https://api.github.com/users/jashkenas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jashkenas/coffeescript","description":"Unfancy JavaScript","fork":false,"url":"https://api.github.com/repos/jashkenas/coffeescript","forks_url":"https://api.github.com/repos/jashkenas/coffeescript/forks","keys_url":"https://api.github.com/repos/jashkenas/coffeescript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jashkenas/coffeescript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jashkenas/coffeescript/teams","hooks_url":"https://api.github.com/repos/jashkenas/coffeescript/hooks","issue_events_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/events{/number}","events_url":"https://api.github.com/repos/jashkenas/coffeescript/events","assignees_url":"https://api.github.com/repos/jashkenas/coffeescript/assignees{/user}","branches_url":"https://api.github.com/repos/jashkenas/coffeescript/branches{/branch}","tags_url":"https://api.github.com/repos/jashkenas/coffeescript/tags","blobs_url":"https://api.github.com/repos/jashkenas/coffeescript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jashkenas/coffeescript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jashkenas/coffeescript/git/refs{/sha}","trees_url":"https://api.github.com/repos/jashkenas/coffeescript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jashkenas/coffeescript/statuses/{sha}","languages_url":"https://api.github.com/repos/jashkenas/coffeescript/languages","stargazers_url":"https://api.github.com/repos/jashkenas/coffeescript/stargazers","contributors_url":"https://api.github.com/repos/jashkenas/coffeescript/contributors","subscribers_url":"https://api.github.com/repos/jashkenas/coffeescript/subscribers","subscription_url":"https://api.github.com/repos/jashkenas/coffeescript/subscription","commits_url":"https://api.github.com/repos/jashkenas/coffeescript/commits{/sha}","git_commits_url":"https://api.github.com/repos/jashkenas/coffeescript/git/commits{/sha}","comments_url":"https://api.github.com/repos/jashkenas/coffeescript/comments{/number}","issue_comment_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/comments{/number}","contents_url":"https://api.github.com/repos/jashkenas/coffeescript/contents/{+path}","compare_url":"https://api.github.com/repos/jashkenas/coffeescript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jashkenas/coffeescript/merges","archive_url":"https://api.github.com/repos/jashkenas/coffeescript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jashkenas/coffeescript/downloads","issues_url":"https://api.github.com/repos/jashkenas/coffeescript/issues{/number}","pulls_url":"https://api.github.com/repos/jashkenas/coffeescript/pulls{/number}","milestones_url":"https://api.github.com/repos/jashkenas/coffeescript/milestones{/number}","notifications_url":"https://api.github.com/repos/jashkenas/coffeescript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jashkenas/coffeescript/labels{/name}","releases_url":"https://api.github.com/repos/jashkenas/coffeescript/releases{/id}","deployments_url":"https://api.github.com/repos/jashkenas/coffeescript/deployments","created_at":"2009-12-18T01:39:53Z","updated_at":"2017-07-31T09:56:28Z","pushed_at":"2017-07-31T00:47:17Z","git_url":"git://github.com/jashkenas/coffeescript.git","ssh_url":"git@github.com:jashkenas/coffeescript.git","clone_url":"https://github.com/jashkenas/coffeescript.git","svn_url":"https://github.com/jashkenas/coffeescript","homepage":"http://coffeescript.org/","size":20270,"stargazers_count":14116,"watchers_count":14116,"language":"CoffeeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1920,"mirror_url":null,"open_issues_count":77,"forks":1920,"open_issues":77,"watchers":14116,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jashkenas/coffeescript/pulls/4572"},"html":{"href":"https://github.com/jashkenas/coffeescript/pull/4572"},"issue":{"href":"https://api.github.com/repos/jashkenas/coffeescript/issues/4572"},"comments":{"href":"https://api.github.com/repos/jashkenas/coffeescript/issues/4572/comments"},"review_comments":{"href":"https://api.github.com/repos/jashkenas/coffeescript/pulls/4572/comments"},"review_comment":{"href":"https://api.github.com/repos/jashkenas/coffeescript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jashkenas/coffeescript/pulls/4572/commits"},"statuses":{"href":"https://api.github.com/repos/jashkenas/coffeescript/statuses/e116c853aae3a85e336e76a69b6cd8d335f5602d"}}}}
{"actor":{"display_login":"connec"}}