{"action":"created","comment":{"url":"https://api.github.com/repos/0xProject/0x-monorepo/pulls/comments/196325152","pull_request_review_id":129852098,"id":196325152,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NjMyNTE1Mg==","diff_hunk":"@@ -97,18 +98,62 @@ export class RevertTraceSubprovider extends TraceCollectionSubprovider {\n                     continue;\n                 }\n             }\n-            sourceRanges.push(sourceRange);\n+            const fileIndex = contractData.sources.indexOf(sourceRange.fileName);\n+            const sourceSnippet = getSourceRangeSnippet(sourceRange, contractData.sourceCodes[fileIndex]);\n+            if (sourceSnippet !== null) {\n+                sourceSnippets.push(sourceSnippet);\n+            }\n         }\n-        if (sourceRanges.length > 0) {\n+        const filteredSnippets = filterSnippets(sourceSnippets);\n+        if (filteredSnippets.length > 0) {\n             this._logger.error('\\n\\nStack trace for REVERT:\\n');\n-            _.forEach(_.reverse(sourceRanges), sourceRange => {\n-                this._logger.error(\n-                    `${sourceRange.fileName}:${sourceRange.location.start.line}:${sourceRange.location.start.column}`,\n-                );\n+            _.forEach(_.reverse(filteredSnippets), snippet => {\n+                const traceString = getStackTraceString(snippet);\n+                this._logger.error(traceString);\n             });\n             this._logger.error('\\n');\n         } else {\n-            this._logger.error('Could not determine stack trace');\n+            this._logger.error('REVERT detected but could not determine stack trace');\n+        }\n+    }\n+}\n+\n+// removes duplicates and if statements\n+function filterSnippets(sourceSnippets: SourceSnippet[]): SourceSnippet[] {\n+    if (sourceSnippets.length === 0) {\n+        return [];\n+    }\n+    const results: SourceSnippet[] = [sourceSnippets[0]];\n+    let prev = sourceSnippets[0];\n+    for (const sourceSnippet of sourceSnippets) {\n+        if (sourceSnippet.type === 'IfStatement') {\n+            continue;\n+        } else if (sourceSnippet.source === prev.source) {\n+            prev = sourceSnippet;\n+            continue;\n         }\n+        results.push(sourceSnippet);\n+        prev = sourceSnippet;\n+    }\n+    return results;\n+}\n+\n+function getStackTraceString(sourceSnippet: SourceSnippet): string {\n+    let result = `${sourceSnippet.fileName}:${sourceSnippet.range.start.line}:${sourceSnippet.range.start.column}`;\n+    const snippetString = getSourceSnippetString(sourceSnippet);\n+    if (snippetString !== '') {\n+        result += `:\\n        ${snippetString}`;\n+    }\n+    return result;\n+}\n+\n+function getSourceSnippetString(sourceSnippet: SourceSnippet): string {\n+    switch (sourceSnippet.type) {\n+        case 'ContractDefinition':\n+            return `contract ${sourceSnippet.name}`;","path":"packages/sol-cov/src/revert_trace_subprovider.ts","position":85,"original_position":85,"commit_id":"aba1af27b8b4cb1972ce26cccf68e4feb997a402","original_commit_id":"aba1af27b8b4cb1972ce26cccf68e4feb997a402","user":{"login":"LogvinovLeon","id":6204356,"node_id":"MDQ6VXNlcjYyMDQzNTY=","avatar_url":"https://avatars1.githubusercontent.com/u/6204356?v=4","gravatar_id":"","url":"https://api.github.com/users/LogvinovLeon","html_url":"https://github.com/LogvinovLeon","followers_url":"https://api.github.com/users/LogvinovLeon/followers","following_url":"https://api.github.com/users/LogvinovLeon/following{/other_user}","gists_url":"https://api.github.com/users/LogvinovLeon/gists{/gist_id}","starred_url":"https://api.github.com/users/LogvinovLeon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LogvinovLeon/subscriptions","organizations_url":"https://api.github.com/users/LogvinovLeon/orgs","repos_url":"https://api.github.com/users/LogvinovLeon/repos","events_url":"https://api.github.com/users/LogvinovLeon/events{/privacy}","received_events_url":"https://api.github.com/users/LogvinovLeon/received_events","type":"User","site_admin":false},"body":"Is this the only reason why we copied the ASTVisitor? If so - let;s just parse the name with a regex and delete the second ASTVisitor","created_at":"2018-06-19T07:52:49Z","updated_at":"2018-06-19T07:53:22Z","html_url":"https://github.com/0xProject/0x-monorepo/pull/725#discussion_r196325152","pull_request_url":"https://api.github.com/repos/0xProject/0x-monorepo/pulls/725","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/0xProject/0x-monorepo/pulls/comments/196325152"},"html":{"href":"https://github.com/0xProject/0x-monorepo/pull/725#discussion_r196325152"},"pull_request":{"href":"https://api.github.com/repos/0xProject/0x-monorepo/pulls/725"}}},"pull_request":{"url":"https://api.github.com/repos/0xProject/0x-monorepo/pulls/725","id":195684431,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk1Njg0NDMx","html_url":"https://github.com/0xProject/0x-monorepo/pull/725","diff_url":"https://github.com/0xProject/0x-monorepo/pull/725.diff","patch_url":"https://github.com/0xProject/0x-monorepo/pull/725.patch","issue_url":"https://api.github.com/repos/0xProject/0x-monorepo/issues/725","number":725,"state":"open","locked":false,"title":"Include source code snippets in revert stack traces","user":{"login":"albrow","id":800857,"node_id":"MDQ6VXNlcjgwMDg1Nw==","avatar_url":"https://avatars3.githubusercontent.com/u/800857?v=4","gravatar_id":"","url":"https://api.github.com/users/albrow","html_url":"https://github.com/albrow","followers_url":"https://api.github.com/users/albrow/followers","following_url":"https://api.github.com/users/albrow/following{/other_user}","gists_url":"https://api.github.com/users/albrow/gists{/gist_id}","starred_url":"https://api.github.com/users/albrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albrow/subscriptions","organizations_url":"https://api.github.com/users/albrow/orgs","repos_url":"https://api.github.com/users/albrow/repos","events_url":"https://api.github.com/users/albrow/events{/privacy}","received_events_url":"https://api.github.com/users/albrow/received_events","type":"User","site_admin":false},"body":"<!--- Thank you for taking the time to submit a Pull Request -->\r\n\r\n<!--- Provide a general summary of the issue in the Title above -->\r\n\r\n## Description\r\n\r\n<!--- Describe your changes in detail -->\r\n\r\nThis PR improves the `RevertTraceSubprovider` by adding relevant source code snippets to the stack trace. This makes it much easier to follow the stack trace at a glance. Here's an example:\r\n\r\n![screen shot 2018-06-18 at 5 24 33 pm](https://user-images.githubusercontent.com/800857/41569117-37c8820c-731e-11e8-9588-1215ba8f5595.png)\r\n\r\n## Motivation and Context\r\n\r\n<!--- Why is this change required? What problem does it solve? -->\r\n\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## How Has This Been Tested?\r\n\r\n<!--- Please describe in detail how you tested your changes. -->\r\n\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n\r\n<!--- see how your change affects other areas of the code, etc. -->\r\n\r\n## Types of changes\r\n\r\n<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->\r\n\r\n*   [ ] Bug fix (non-breaking change which fixes an issue)\r\n*   [x] New feature (non-breaking change which adds functionality)\r\n*   [ ] Breaking change (fix or feature that would cause existing functionality to change)\r\n\r\n## Checklist:\r\n\r\n<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->\r\n\r\n<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->\r\n\r\n*   [ ] Change requires a change to the documentation.\r\n*   [ ] Added tests to cover my changes.\r\n*   [ ] Added new entries to the relevant CHANGELOG.jsons.\r\n*   [ ] Labeled this PR with the 'WIP' label if it is a work in progress.\r\n*   [ ] Labeled this PR with the labels corresponding to the changed package.\r\n","created_at":"2018-06-19T00:37:44Z","updated_at":"2018-06-19T07:53:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"12001308fa039956fbe9790ae2ba01a654c23b8d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/0xProject/0x-monorepo/pulls/725/commits","review_comments_url":"https://api.github.com/repos/0xProject/0x-monorepo/pulls/725/comments","review_comment_url":"https://api.github.com/repos/0xProject/0x-monorepo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/0xProject/0x-monorepo/issues/725/comments","statuses_url":"https://api.github.com/repos/0xProject/0x-monorepo/statuses/aba1af27b8b4cb1972ce26cccf68e4feb997a402","head":{"label":"0xProject:feature/revert-trace-code-snippets","ref":"feature/revert-trace-code-snippets","sha":"aba1af27b8b4cb1972ce26cccf68e4feb997a402","user":{"login":"0xProject","id":24832717,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0ODMyNzE3","avatar_url":"https://avatars2.githubusercontent.com/u/24832717?v=4","gravatar_id":"","url":"https://api.github.com/users/0xProject","html_url":"https://github.com/0xProject","followers_url":"https://api.github.com/users/0xProject/followers","following_url":"https://api.github.com/users/0xProject/following{/other_user}","gists_url":"https://api.github.com/users/0xProject/gists{/gist_id}","starred_url":"https://api.github.com/users/0xProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xProject/subscriptions","organizations_url":"https://api.github.com/users/0xProject/orgs","repos_url":"https://api.github.com/users/0xProject/repos","events_url":"https://api.github.com/users/0xProject/events{/privacy}","received_events_url":"https://api.github.com/users/0xProject/received_events","type":"Organization","site_admin":false},"repo":{"id":92181371,"node_id":"MDEwOlJlcG9zaXRvcnk5MjE4MTM3MQ==","name":"0x-monorepo","full_name":"0xProject/0x-monorepo","owner":{"login":"0xProject","id":24832717,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0ODMyNzE3","avatar_url":"https://avatars2.githubusercontent.com/u/24832717?v=4","gravatar_id":"","url":"https://api.github.com/users/0xProject","html_url":"https://github.com/0xProject","followers_url":"https://api.github.com/users/0xProject/followers","following_url":"https://api.github.com/users/0xProject/following{/other_user}","gists_url":"https://api.github.com/users/0xProject/gists{/gist_id}","starred_url":"https://api.github.com/users/0xProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xProject/subscriptions","organizations_url":"https://api.github.com/users/0xProject/orgs","repos_url":"https://api.github.com/users/0xProject/repos","events_url":"https://api.github.com/users/0xProject/events{/privacy}","received_events_url":"https://api.github.com/users/0xProject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/0xProject/0x-monorepo","description":"0x protocol monorepo - includes our smart contracts and many developer tools","fork":false,"url":"https://api.github.com/repos/0xProject/0x-monorepo","forks_url":"https://api.github.com/repos/0xProject/0x-monorepo/forks","keys_url":"https://api.github.com/repos/0xProject/0x-monorepo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/0xProject/0x-monorepo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/0xProject/0x-monorepo/teams","hooks_url":"https://api.github.com/repos/0xProject/0x-monorepo/hooks","issue_events_url":"https://api.github.com/repos/0xProject/0x-monorepo/issues/events{/number}","events_url":"https://api.github.com/repos/0xProject/0x-monorepo/events","assignees_url":"https://api.github.com/repos/0xProject/0x-monorepo/assignees{/user}","branches_url":"https://api.github.com/repos/0xProject/0x-monorepo/branches{/branch}","tags_url":"https://api.github.com/repos/0xProject/0x-monorepo/tags","blobs_url":"https://api.github.com/repos/0xProject/0x-monorepo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/0xProject/0x-monorepo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/0xProject/0x-monorepo/git/refs{/sha}","trees_url":"https://api.github.com/repos/0xProject/0x-monorepo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/0xProject/0x-monorepo/statuses/{sha}","languages_url":"https://api.github.com/repos/0xProject/0x-monorepo/languages","stargazers_url":"https://api.github.com/repos/0xProject/0x-monorepo/stargazers","contributors_url":"https://api.github.com/repos/0xProject/0x-monorepo/contributors","subscribers_url":"https://api.github.com/repos/0xProject/0x-monorepo/subscribers","subscription_url":"https://api.github.com/repos/0xProject/0x-monorepo/subscription","commits_url":"https://api.github.com/repos/0xProject/0x-monorepo/commits{/sha}","git_commits_url":"https://api.github.com/repos/0xProject/0x-monorepo/git/commits{/sha}","comments_url":"https://api.github.com/repos/0xProject/0x-monorepo/comments{/number}","issue_comment_url":"https://api.github.com/repos/0xProject/0x-monorepo/issues/comments{/number}","contents_url":"https://api.github.com/repos/0xProject/0x-monorepo/contents/{+path}","compare_url":"https://api.github.com/repos/0xProject/0x-monorepo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/0xProject/0x-monorepo/merges","archive_url":"https://api.github.com/repos/0xProject/0x-monorepo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/0xProject/0x-monorepo/downloads","issues_url":"https://api.github.com/repos/0xProject/0x-monorepo/issues{/number}","pulls_url":"https://api.github.com/repos/0xProject/0x-monorepo/pulls{/number}","milestones_url":"https://api.github.com/repos/0xProject/0x-monorepo/milestones{/number}","notifications_url":"https://api.github.com/repos/0xProject/0x-monorepo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/0xProject/0x-monorepo/labels{/name}","releases_url":"https://api.github.com/repos/0xProject/0x-monorepo/releases{/id}","deployments_url":"https://api.github.com/repos/0xProject/0x-monorepo/deployments","created_at":"2017-05-23T14:17:33Z","updated_at":"2018-06-19T06:20:15Z","pushed_at":"2018-06-19T07:47:15Z","git_url":"git://github.com/0xProject/0x-monorepo.git","ssh_url":"git@github.com:0xProject/0x-monorepo.git","clone_url":"https://github.com/0xProject/0x-monorepo.git","svn_url":"https://github.com/0xProject/0x-monorepo","homepage":"","size":46764,"stargazers_count":671,"watchers_count":671,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":172,"mirror_url":null,"archived":false,"open_issues_count":46,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":172,"open_issues":46,"watchers":671,"default_branch":"v2-prototype"}},"base":{"label":"0xProject:v2-prototype","ref":"v2-prototype","sha":"49f5495c459f194f3cab6ff24526da924bd64a53","user":{"login":"0xProject","id":24832717,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0ODMyNzE3","avatar_url":"https://avatars2.githubusercontent.com/u/24832717?v=4","gravatar_id":"","url":"https://api.github.com/users/0xProject","html_url":"https://github.com/0xProject","followers_url":"https://api.github.com/users/0xProject/followers","following_url":"https://api.github.com/users/0xProject/following{/other_user}","gists_url":"https://api.github.com/users/0xProject/gists{/gist_id}","starred_url":"https://api.github.com/users/0xProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xProject/subscriptions","organizations_url":"https://api.github.com/users/0xProject/orgs","repos_url":"https://api.github.com/users/0xProject/repos","events_url":"https://api.github.com/users/0xProject/events{/privacy}","received_events_url":"https://api.github.com/users/0xProject/received_events","type":"Organization","site_admin":false},"repo":{"id":92181371,"node_id":"MDEwOlJlcG9zaXRvcnk5MjE4MTM3MQ==","name":"0x-monorepo","full_name":"0xProject/0x-monorepo","owner":{"login":"0xProject","id":24832717,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0ODMyNzE3","avatar_url":"https://avatars2.githubusercontent.com/u/24832717?v=4","gravatar_id":"","url":"https://api.github.com/users/0xProject","html_url":"https://github.com/0xProject","followers_url":"https://api.github.com/users/0xProject/followers","following_url":"https://api.github.com/users/0xProject/following{/other_user}","gists_url":"https://api.github.com/users/0xProject/gists{/gist_id}","starred_url":"https://api.github.com/users/0xProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xProject/subscriptions","organizations_url":"https://api.github.com/users/0xProject/orgs","repos_url":"https://api.github.com/users/0xProject/repos","events_url":"https://api.github.com/users/0xProject/events{/privacy}","received_events_url":"https://api.github.com/users/0xProject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/0xProject/0x-monorepo","description":"0x protocol monorepo - includes our smart contracts and many developer tools","fork":false,"url":"https://api.github.com/repos/0xProject/0x-monorepo","forks_url":"https://api.github.com/repos/0xProject/0x-monorepo/forks","keys_url":"https://api.github.com/repos/0xProject/0x-monorepo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/0xProject/0x-monorepo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/0xProject/0x-monorepo/teams","hooks_url":"https://api.github.com/repos/0xProject/0x-monorepo/hooks","issue_events_url":"https://api.github.com/repos/0xProject/0x-monorepo/issues/events{/number}","events_url":"https://api.github.com/repos/0xProject/0x-monorepo/events","assignees_url":"https://api.github.com/repos/0xProject/0x-monorepo/assignees{/user}","branches_url":"https://api.github.com/repos/0xProject/0x-monorepo/branches{/branch}","tags_url":"https://api.github.com/repos/0xProject/0x-monorepo/tags","blobs_url":"https://api.github.com/repos/0xProject/0x-monorepo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/0xProject/0x-monorepo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/0xProject/0x-monorepo/git/refs{/sha}","trees_url":"https://api.github.com/repos/0xProject/0x-monorepo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/0xProject/0x-monorepo/statuses/{sha}","languages_url":"https://api.github.com/repos/0xProject/0x-monorepo/languages","stargazers_url":"https://api.github.com/repos/0xProject/0x-monorepo/stargazers","contributors_url":"https://api.github.com/repos/0xProject/0x-monorepo/contributors","subscribers_url":"https://api.github.com/repos/0xProject/0x-monorepo/subscribers","subscription_url":"https://api.github.com/repos/0xProject/0x-monorepo/subscription","commits_url":"https://api.github.com/repos/0xProject/0x-monorepo/commits{/sha}","git_commits_url":"https://api.github.com/repos/0xProject/0x-monorepo/git/commits{/sha}","comments_url":"https://api.github.com/repos/0xProject/0x-monorepo/comments{/number}","issue_comment_url":"https://api.github.com/repos/0xProject/0x-monorepo/issues/comments{/number}","contents_url":"https://api.github.com/repos/0xProject/0x-monorepo/contents/{+path}","compare_url":"https://api.github.com/repos/0xProject/0x-monorepo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/0xProject/0x-monorepo/merges","archive_url":"https://api.github.com/repos/0xProject/0x-monorepo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/0xProject/0x-monorepo/downloads","issues_url":"https://api.github.com/repos/0xProject/0x-monorepo/issues{/number}","pulls_url":"https://api.github.com/repos/0xProject/0x-monorepo/pulls{/number}","milestones_url":"https://api.github.com/repos/0xProject/0x-monorepo/milestones{/number}","notifications_url":"https://api.github.com/repos/0xProject/0x-monorepo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/0xProject/0x-monorepo/labels{/name}","releases_url":"https://api.github.com/repos/0xProject/0x-monorepo/releases{/id}","deployments_url":"https://api.github.com/repos/0xProject/0x-monorepo/deployments","created_at":"2017-05-23T14:17:33Z","updated_at":"2018-06-19T06:20:15Z","pushed_at":"2018-06-19T07:47:15Z","git_url":"git://github.com/0xProject/0x-monorepo.git","ssh_url":"git@github.com:0xProject/0x-monorepo.git","clone_url":"https://github.com/0xProject/0x-monorepo.git","svn_url":"https://github.com/0xProject/0x-monorepo","homepage":"","size":46764,"stargazers_count":671,"watchers_count":671,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":172,"mirror_url":null,"archived":false,"open_issues_count":46,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":172,"open_issues":46,"watchers":671,"default_branch":"v2-prototype"}},"_links":{"self":{"href":"https://api.github.com/repos/0xProject/0x-monorepo/pulls/725"},"html":{"href":"https://github.com/0xProject/0x-monorepo/pull/725"},"issue":{"href":"https://api.github.com/repos/0xProject/0x-monorepo/issues/725"},"comments":{"href":"https://api.github.com/repos/0xProject/0x-monorepo/issues/725/comments"},"review_comments":{"href":"https://api.github.com/repos/0xProject/0x-monorepo/pulls/725/comments"},"review_comment":{"href":"https://api.github.com/repos/0xProject/0x-monorepo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/0xProject/0x-monorepo/pulls/725/commits"},"statuses":{"href":"https://api.github.com/repos/0xProject/0x-monorepo/statuses/aba1af27b8b4cb1972ce26cccf68e4feb997a402"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"LogvinovLeon"}}