{"action":"created","comment":{"url":"https://api.github.com/repos/google/blockly/pulls/comments/166152172","pull_request_review_id":94187495,"id":166152172,"diff_hunk":"@@ -304,47 +304,67 @@ Code.renderContent = function() {\n     xmlTextarea.value = xmlText;\n     xmlTextarea.focus();\n   } else if (content.id == 'content_javascript') {\n-    var code = Blockly.JavaScript.workspaceToCode(Code.workspace);\n-    content.textContent = code;\n-    if (typeof PR.prettyPrintOne == 'function') {\n-      code = content.textContent;\n-      code = PR.prettyPrintOne(code, 'js');\n-      content.innerHTML = code;\n-    }\n+    Code.attemptCodeGeneration(Blockly.JavaScript, 'js');\n   } else if (content.id == 'content_python') {\n-    code = Blockly.Python.workspaceToCode(Code.workspace);\n-    content.textContent = code;\n-    if (typeof PR.prettyPrintOne == 'function') {\n-      code = content.textContent;\n-      code = PR.prettyPrintOne(code, 'py');\n-      content.innerHTML = code;\n-    }\n+    Code.attemptCodeGeneration(Blockly.Python, 'py');\n   } else if (content.id == 'content_php') {\n-    code = Blockly.PHP.workspaceToCode(Code.workspace);\n-    content.textContent = code;\n-    if (typeof PR.prettyPrintOne == 'function') {\n-      code = content.textContent;\n-      code = PR.prettyPrintOne(code, 'php');\n-      content.innerHTML = code;\n-    }\n+    Code.attemptCodeGeneration(Blockly.PHP, 'php');\n   } else if (content.id == 'content_dart') {\n-    code = Blockly.Dart.workspaceToCode(Code.workspace);\n-    content.textContent = code;\n-    if (typeof PR.prettyPrintOne == 'function') {\n-      code = content.textContent;\n-      code = PR.prettyPrintOne(code, 'dart');\n-      content.innerHTML = code;\n-    }\n+    Code.attemptCodeGeneration(Blockly.Dart, 'dart');\n   } else if (content.id == 'content_lua') {\n-    code = Blockly.Lua.workspaceToCode(Code.workspace);\n+    Code.attemptCodeGeneration(Blockly.Lua, 'lua');\n+  }\n+};\n+\n+/**\n+ * Attempt to generate the code and display it in the UI, pretty printed.\n+ * @param generator {Blockly.Generator} The generator to use.\n+ * @param prettyPrintType {string} The file type key for the pretty printer.\n+ */\n+Code.attemptCodeGeneration = function(generator, prettyPrintType) {\n+  var content = document.getElementById('content_' + Code.selected);\n+  content.textContent = '';\n+  if (Code.checkAllGeneratorFunctionsDefined(generator)) {\n+    var code = generator.workspaceToCode(Code.workspace);\n+\n     content.textContent = code;\n     if (typeof PR.prettyPrintOne == 'function') {\n       code = content.textContent;\n-      code = PR.prettyPrintOne(code, 'lua');\n+      code = PR.prettyPrintOne(code, prettyPrintType);\n       content.innerHTML = code;\n     }\n   }\n-};\n+}","path":"demos/code/code.js","position":65,"original_position":65,"commit_id":"fc2877c924928e104c302039dc9faa4b62356ffd","original_commit_id":"fc2877c924928e104c302039dc9faa4b62356ffd","user":{"login":"NeilFraser","id":250480,"avatar_url":"https://avatars3.githubusercontent.com/u/250480?v=4","gravatar_id":"","url":"https://api.github.com/users/NeilFraser","html_url":"https://github.com/NeilFraser","followers_url":"https://api.github.com/users/NeilFraser/followers","following_url":"https://api.github.com/users/NeilFraser/following{/other_user}","gists_url":"https://api.github.com/users/NeilFraser/gists{/gist_id}","starred_url":"https://api.github.com/users/NeilFraser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NeilFraser/subscriptions","organizations_url":"https://api.github.com/users/NeilFraser/orgs","repos_url":"https://api.github.com/users/NeilFraser/repos","events_url":"https://api.github.com/users/NeilFraser/events{/privacy}","received_events_url":"https://api.github.com/users/NeilFraser/received_events","type":"User","site_admin":false},"body":"Semicolon.","created_at":"2018-02-06T00:06:05Z","updated_at":"2018-02-06T00:18:11Z","html_url":"https://github.com/google/blockly/pull/1585#discussion_r166152172","pull_request_url":"https://api.github.com/repos/google/blockly/pulls/1585","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/google/blockly/pulls/comments/166152172"},"html":{"href":"https://github.com/google/blockly/pull/1585#discussion_r166152172"},"pull_request":{"href":"https://api.github.com/repos/google/blockly/pulls/1585"}}},"pull_request":{"url":"https://api.github.com/repos/google/blockly/pulls/1585","id":166875105,"html_url":"https://github.com/google/blockly/pull/1585","diff_url":"https://github.com/google/blockly/pull/1585.diff","patch_url":"https://github.com/google/blockly/pull/1585.patch","issue_url":"https://api.github.com/repos/google/blockly/issues/1585","number":1585,"state":"open","locked":false,"title":"In Code demo, give warning if a generator function is missing.","user":{"login":"AnmAtAnm","id":9916202,"avatar_url":"https://avatars1.githubusercontent.com/u/9916202?v=4","gravatar_id":"","url":"https://api.github.com/users/AnmAtAnm","html_url":"https://github.com/AnmAtAnm","followers_url":"https://api.github.com/users/AnmAtAnm/followers","following_url":"https://api.github.com/users/AnmAtAnm/following{/other_user}","gists_url":"https://api.github.com/users/AnmAtAnm/gists{/gist_id}","starred_url":"https://api.github.com/users/AnmAtAnm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnmAtAnm/subscriptions","organizations_url":"https://api.github.com/users/AnmAtAnm/orgs","repos_url":"https://api.github.com/users/AnmAtAnm/repos","events_url":"https://api.github.com/users/AnmAtAnm/events{/privacy}","received_events_url":"https://api.github.com/users/AnmAtAnm/received_events","type":"User","site_admin":false},"body":"## The basics\r\n\r\n- [x] I branched from develop\r\n- [x] My pull request is against develop\r\n- [x] My code follows the [style guide](https://developers.google.com/blockly/guides/modify/web/style-guide)\r\n\r\n## The details\r\n### Resolves\r\n\r\nGive the user a warning if a generator is not defined for the given blocks and requested language.\r\n\r\nReimplementation of #1557 by @Rgtemze\r\n\r\n### Reason for Changes\r\n\r\nHelp developers with better messaging it a widely used demo.\r\n\r\n### Test Coverage\r\n\r\nI created a new block with no generator functions. I tested with only the new block, with a mix of blocks, and with only older existing blocks.\r\n\r\nTested on:\r\n * Desktop Chrome\r\n<!-- * Desktop Firefox -->\r\n<!-- * Desktop Safari -->\r\n<!-- * Desktop Opera -->\r\n<!-- * Windows Internet Explorer 10 -->\r\n<!-- * Windows Internet Explorer 11 -->\r\n<!-- * Windows Edge -->\r\n\r\n<!--\r\n* Smartphone/Tablet/Chromebook (please complete the following information):\r\n  * Device: [e.g. iPhone6]\r\n  * OS: [e.g. iOS8.1]\r\n  * Browser [e.g. stock browser, safari]\r\n  * Version [e.g. 22]\r\n-->\r\n\r\n### Additional Information\r\n\r\n<!-- Anything else we should know? -->\r\n","created_at":"2018-02-02T18:43:48Z","updated_at":"2018-02-06T00:18:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e123ec0c2ecf70d3277872b9183defa60c9f209d","assignee":{"login":"NeilFraser","id":250480,"avatar_url":"https://avatars3.githubusercontent.com/u/250480?v=4","gravatar_id":"","url":"https://api.github.com/users/NeilFraser","html_url":"https://github.com/NeilFraser","followers_url":"https://api.github.com/users/NeilFraser/followers","following_url":"https://api.github.com/users/NeilFraser/following{/other_user}","gists_url":"https://api.github.com/users/NeilFraser/gists{/gist_id}","starred_url":"https://api.github.com/users/NeilFraser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NeilFraser/subscriptions","organizations_url":"https://api.github.com/users/NeilFraser/orgs","repos_url":"https://api.github.com/users/NeilFraser/repos","events_url":"https://api.github.com/users/NeilFraser/events{/privacy}","received_events_url":"https://api.github.com/users/NeilFraser/received_events","type":"User","site_admin":false},"assignees":[{"login":"NeilFraser","id":250480,"avatar_url":"https://avatars3.githubusercontent.com/u/250480?v=4","gravatar_id":"","url":"https://api.github.com/users/NeilFraser","html_url":"https://github.com/NeilFraser","followers_url":"https://api.github.com/users/NeilFraser/followers","following_url":"https://api.github.com/users/NeilFraser/following{/other_user}","gists_url":"https://api.github.com/users/NeilFraser/gists{/gist_id}","starred_url":"https://api.github.com/users/NeilFraser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NeilFraser/subscriptions","organizations_url":"https://api.github.com/users/NeilFraser/orgs","repos_url":"https://api.github.com/users/NeilFraser/repos","events_url":"https://api.github.com/users/NeilFraser/events{/privacy}","received_events_url":"https://api.github.com/users/NeilFraser/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/blockly/pulls/1585/commits","review_comments_url":"https://api.github.com/repos/google/blockly/pulls/1585/comments","review_comment_url":"https://api.github.com/repos/google/blockly/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/blockly/issues/1585/comments","statuses_url":"https://api.github.com/repos/google/blockly/statuses/fc2877c924928e104c302039dc9faa4b62356ffd","head":{"label":"AnmAtAnm:demo-code-warn-missing-blocks","ref":"demo-code-warn-missing-blocks","sha":"fc2877c924928e104c302039dc9faa4b62356ffd","user":{"login":"AnmAtAnm","id":9916202,"avatar_url":"https://avatars1.githubusercontent.com/u/9916202?v=4","gravatar_id":"","url":"https://api.github.com/users/AnmAtAnm","html_url":"https://github.com/AnmAtAnm","followers_url":"https://api.github.com/users/AnmAtAnm/followers","following_url":"https://api.github.com/users/AnmAtAnm/following{/other_user}","gists_url":"https://api.github.com/users/AnmAtAnm/gists{/gist_id}","starred_url":"https://api.github.com/users/AnmAtAnm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnmAtAnm/subscriptions","organizations_url":"https://api.github.com/users/AnmAtAnm/orgs","repos_url":"https://api.github.com/users/AnmAtAnm/repos","events_url":"https://api.github.com/users/AnmAtAnm/events{/privacy}","received_events_url":"https://api.github.com/users/AnmAtAnm/received_events","type":"User","site_admin":false},"repo":{"id":60655550,"name":"blockly","full_name":"AnmAtAnm/blockly","owner":{"login":"AnmAtAnm","id":9916202,"avatar_url":"https://avatars1.githubusercontent.com/u/9916202?v=4","gravatar_id":"","url":"https://api.github.com/users/AnmAtAnm","html_url":"https://github.com/AnmAtAnm","followers_url":"https://api.github.com/users/AnmAtAnm/followers","following_url":"https://api.github.com/users/AnmAtAnm/following{/other_user}","gists_url":"https://api.github.com/users/AnmAtAnm/gists{/gist_id}","starred_url":"https://api.github.com/users/AnmAtAnm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnmAtAnm/subscriptions","organizations_url":"https://api.github.com/users/AnmAtAnm/orgs","repos_url":"https://api.github.com/users/AnmAtAnm/repos","events_url":"https://api.github.com/users/AnmAtAnm/events{/privacy}","received_events_url":"https://api.github.com/users/AnmAtAnm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AnmAtAnm/blockly","description":"The web-based visual programming editor.","fork":true,"url":"https://api.github.com/repos/AnmAtAnm/blockly","forks_url":"https://api.github.com/repos/AnmAtAnm/blockly/forks","keys_url":"https://api.github.com/repos/AnmAtAnm/blockly/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AnmAtAnm/blockly/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AnmAtAnm/blockly/teams","hooks_url":"https://api.github.com/repos/AnmAtAnm/blockly/hooks","issue_events_url":"https://api.github.com/repos/AnmAtAnm/blockly/issues/events{/number}","events_url":"https://api.github.com/repos/AnmAtAnm/blockly/events","assignees_url":"https://api.github.com/repos/AnmAtAnm/blockly/assignees{/user}","branches_url":"https://api.github.com/repos/AnmAtAnm/blockly/branches{/branch}","tags_url":"https://api.github.com/repos/AnmAtAnm/blockly/tags","blobs_url":"https://api.github.com/repos/AnmAtAnm/blockly/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AnmAtAnm/blockly/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AnmAtAnm/blockly/git/refs{/sha}","trees_url":"https://api.github.com/repos/AnmAtAnm/blockly/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AnmAtAnm/blockly/statuses/{sha}","languages_url":"https://api.github.com/repos/AnmAtAnm/blockly/languages","stargazers_url":"https://api.github.com/repos/AnmAtAnm/blockly/stargazers","contributors_url":"https://api.github.com/repos/AnmAtAnm/blockly/contributors","subscribers_url":"https://api.github.com/repos/AnmAtAnm/blockly/subscribers","subscription_url":"https://api.github.com/repos/AnmAtAnm/blockly/subscription","commits_url":"https://api.github.com/repos/AnmAtAnm/blockly/commits{/sha}","git_commits_url":"https://api.github.com/repos/AnmAtAnm/blockly/git/commits{/sha}","comments_url":"https://api.github.com/repos/AnmAtAnm/blockly/comments{/number}","issue_comment_url":"https://api.github.com/repos/AnmAtAnm/blockly/issues/comments{/number}","contents_url":"https://api.github.com/repos/AnmAtAnm/blockly/contents/{+path}","compare_url":"https://api.github.com/repos/AnmAtAnm/blockly/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AnmAtAnm/blockly/merges","archive_url":"https://api.github.com/repos/AnmAtAnm/blockly/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AnmAtAnm/blockly/downloads","issues_url":"https://api.github.com/repos/AnmAtAnm/blockly/issues{/number}","pulls_url":"https://api.github.com/repos/AnmAtAnm/blockly/pulls{/number}","milestones_url":"https://api.github.com/repos/AnmAtAnm/blockly/milestones{/number}","notifications_url":"https://api.github.com/repos/AnmAtAnm/blockly/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AnmAtAnm/blockly/labels{/name}","releases_url":"https://api.github.com/repos/AnmAtAnm/blockly/releases{/id}","deployments_url":"https://api.github.com/repos/AnmAtAnm/blockly/deployments","created_at":"2016-06-08T00:17:43Z","updated_at":"2016-06-08T00:17:46Z","pushed_at":"2018-02-02T18:50:59Z","git_url":"git://github.com/AnmAtAnm/blockly.git","ssh_url":"git@github.com:AnmAtAnm/blockly.git","clone_url":"https://github.com/AnmAtAnm/blockly.git","svn_url":"https://github.com/AnmAtAnm/blockly","homepage":"https://developers.google.com/blockly/","size":65083,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:develop","ref":"develop","sha":"f497c70be02c97a88cbb6fe0b571dcf4acc1f5e8","user":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":13872231,"name":"blockly","full_name":"google/blockly","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/blockly","description":"The web-based visual programming editor.","fork":false,"url":"https://api.github.com/repos/google/blockly","forks_url":"https://api.github.com/repos/google/blockly/forks","keys_url":"https://api.github.com/repos/google/blockly/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/blockly/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/blockly/teams","hooks_url":"https://api.github.com/repos/google/blockly/hooks","issue_events_url":"https://api.github.com/repos/google/blockly/issues/events{/number}","events_url":"https://api.github.com/repos/google/blockly/events","assignees_url":"https://api.github.com/repos/google/blockly/assignees{/user}","branches_url":"https://api.github.com/repos/google/blockly/branches{/branch}","tags_url":"https://api.github.com/repos/google/blockly/tags","blobs_url":"https://api.github.com/repos/google/blockly/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/blockly/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/blockly/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/blockly/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/blockly/statuses/{sha}","languages_url":"https://api.github.com/repos/google/blockly/languages","stargazers_url":"https://api.github.com/repos/google/blockly/stargazers","contributors_url":"https://api.github.com/repos/google/blockly/contributors","subscribers_url":"https://api.github.com/repos/google/blockly/subscribers","subscription_url":"https://api.github.com/repos/google/blockly/subscription","commits_url":"https://api.github.com/repos/google/blockly/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/blockly/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/blockly/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/blockly/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/blockly/contents/{+path}","compare_url":"https://api.github.com/repos/google/blockly/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/blockly/merges","archive_url":"https://api.github.com/repos/google/blockly/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/blockly/downloads","issues_url":"https://api.github.com/repos/google/blockly/issues{/number}","pulls_url":"https://api.github.com/repos/google/blockly/pulls{/number}","milestones_url":"https://api.github.com/repos/google/blockly/milestones{/number}","notifications_url":"https://api.github.com/repos/google/blockly/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/blockly/labels{/name}","releases_url":"https://api.github.com/repos/google/blockly/releases{/id}","deployments_url":"https://api.github.com/repos/google/blockly/deployments","created_at":"2013-10-25T21:13:33Z","updated_at":"2018-02-05T13:40:44Z","pushed_at":"2018-02-05T10:52:46Z","git_url":"git://github.com/google/blockly.git","ssh_url":"git@github.com:google/blockly.git","clone_url":"https://github.com/google/blockly.git","svn_url":"https://github.com/google/blockly","homepage":"https://developers.google.com/blockly/","size":67465,"stargazers_count":4250,"watchers_count":4250,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1549,"mirror_url":null,"archived":false,"open_issues_count":301,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":1549,"open_issues":301,"watchers":4250,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/blockly/pulls/1585"},"html":{"href":"https://github.com/google/blockly/pull/1585"},"issue":{"href":"https://api.github.com/repos/google/blockly/issues/1585"},"comments":{"href":"https://api.github.com/repos/google/blockly/issues/1585/comments"},"review_comments":{"href":"https://api.github.com/repos/google/blockly/pulls/1585/comments"},"review_comment":{"href":"https://api.github.com/repos/google/blockly/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/blockly/pulls/1585/commits"},"statuses":{"href":"https://api.github.com/repos/google/blockly/statuses/fc2877c924928e104c302039dc9faa4b62356ffd"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"NeilFraser"}}