GitHub PullRequestReviewCommentEvent at 2014-10-23 13:09:21
Repository: snowcrash
Actor: alikh31
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/apiaryio/snowcrash/pulls/comments/19275511","id":19275511,"diff_hunk":"@@ -46,48 +107,77 @@ void PrintAnnotation(const std::string& prefix, const snowcrash::SourceAnnotatio\n         std::cerr << \" \" << annotation.message;\n     }\n \n+    std::vector<size_t> linesEndIndex;\n+\n+    if (isReportByLineNumber) {\n+        GetLinesEndIndex(source, linesEndIndex);\n+    }\n+\n     if (!annotation.location.empty()) {\n+\n         for (mdp::CharactersRangeSet::const_iterator it = annotation.location.begin();\n              it != annotation.location.end();\n              ++it) {\n+\n             std::cerr << ((it == annotation.location.begin()) ? \" :\" : \";\");\n-            std::cerr << it->location << \":\" << it->length;\n+\n+            if (isReportByLineNumber) {\n+\n+                size_t fromLine, fromColumn, toLine, toColumn;\n+                GetLineFromMap(linesEndIndex, *it, fromLine, fromColumn, toLine, toColumn);\n+\n+                std::cerr << \" on line \" << fromLine << \", column \" << fromColumn;\n+                std::cerr << \" - line \" << toLine << \", column \" << toColumn;\n+            }\n+            else {\n+                std::cerr << it->location << \":\" << it->length;\n+            }\n         }\n     }\n \n     std::cerr << std::endl;\n }\n \n-/// \\brief Print parser report to stderr.\n-/// \\param report A parser report to print\n-void PrintReport(const snowcrash::Report& report)\n+/**\n+ *  \\brief Print parser report to stderr.\n+ *  \\param report A parser report to print\n+ *  \\param source Source sting\n+ *  \\param isReportByLineNumber True if the annotations needs to be printed by line and column number\n+ */\n+void PrintReport(const snowcrash::Report& report,\n+                 const std::string source,\n+                 const bool isReportByLineNumber)\n {\n+\n     std::cerr << std::endl;\n \n     if (report.error.code == Error::OK) {\n         std::cerr << \"OK.\\n\";\n     }\n     else {\n-        PrintAnnotation(\"error:\", report.error);\n+        PrintAnnotation(\"error:\", report.error, source, isReportByLineNumber);\n     }\n \n     for (snowcrash::Warnings::const_iterator it = report.warnings.begin(); it != report.warnings.end(); ++it) {\n-        PrintAnnotation(\"warning:\", *it);\n+        PrintAnnotation(\"warning:\", *it, source, isReportByLineNumber);\n     }\n }\n \n int main(int argc, const char *argv[])\n {\n+\n     cmdline::parser argumentParser;\n+    std::stringstream inputStream;\n+    bool isReportByLineNumber = false;\n+    std::stringstream footerStream;\n \n     argumentParser.set_program_name(\"snowcrash\");\n-    std::stringstream ss;\n \n-    ss << \"<input file>\\n\\n\";","path":"src/snowcrash/snowcrash.cc","position":164,"original_position":162,"commit_id":"1839ad45685b5478a817805c2c71648dc6b9ac7e","original_commit_id":"3628998b69b345ae92b302edea5aace68d51c30a","user":{"login":"alikh31","id":6755109,"avatar_url":"https://avatars.githubusercontent.com/u/6755109?v=2","gravatar_id":"","url":"https://api.github.com/users/alikh31","html_url":"https://github.com/alikh31","followers_url":"https://api.github.com/users/alikh31/followers","following_url":"https://api.github.com/users/alikh31/following{/other_user}","gists_url":"https://api.github.com/users/alikh31/gists{/gist_id}","starred_url":"https://api.github.com/users/alikh31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alikh31/subscriptions","organizations_url":"https://api.github.com/users/alikh31/orgs","repos_url":"https://api.github.com/users/alikh31/repos","events_url":"https://api.github.com/users/alikh31/events{/privacy}","received_events_url":"https://api.github.com/users/alikh31/received_events","type":"User","site_admin":false},"body":"@zdne I thought the name might be confusing(`ss`).","created_at":"2014-10-23T13:09:21Z","updated_at":"2014-10-23T13:09:21Z","html_url":"https://github.com/apiaryio/snowcrash/pull/245#discussion_r19275511","pull_request_url":"https://api.github.com/repos/apiaryio/snowcrash/pulls/245","_links":{"self":{"href":"https://api.github.com/repos/apiaryio/snowcrash/pulls/comments/19275511"},"html":{"href":"https://github.com/apiaryio/snowcrash/pull/245#discussion_r19275511"},"pull_request":{"href":"https://api.github.com/repos/apiaryio/snowcrash/pulls/245"}}},"pull_request":{"url":"https://api.github.com/repos/apiaryio/snowcrash/pulls/245","id":22983858,"html_url":"https://github.com/apiaryio/snowcrash/pull/245","diff_url":"https://github.com/apiaryio/snowcrash/pull/245.diff","patch_url":"https://github.com/apiaryio/snowcrash/pull/245.patch","issue_url":"https://api.github.com/repos/apiaryio/snowcrash/issues/245","number":245,"state":"open","locked":false,"title":"add an option to CLI tool for reporting annotation by line and column number","user":{"login":"alikh31","id":6755109,"avatar_url":"https://avatars.githubusercontent.com/u/6755109?v=2","gravatar_id":"","url":"https://api.github.com/users/alikh31","html_url":"https://github.com/alikh31","followers_url":"https://api.github.com/users/alikh31/followers","following_url":"https://api.github.com/users/alikh31/following{/other_user}","gists_url":"https://api.github.com/users/alikh31/gists{/gist_id}","starred_url":"https://api.github.com/users/alikh31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alikh31/subscriptions","organizations_url":"https://api.github.com/users/alikh31/orgs","repos_url":"https://api.github.com/users/alikh31/repos","events_url":"https://api.github.com/users/alikh31/events{/privacy}","received_events_url":"https://api.github.com/users/alikh31/received_events","type":"User","site_admin":false},"body":"fixes issue #162.\r\nIn the mentioned issue there is a need for reporting annotation with line and column number, in order to make them more readable for human to debug their code.\r\nIn this PR a function has been added [`snowcrash.cc`](https://github.com/alikh31/snowcrash/commit/d8397c2e1b6f7bcc74b3a9357284231408dd93d3#diff-6a5a8e0ab7a5b957ab294981f601a3d4R42) to convert character map into line number, in order to do so there is the need of passing the blueprint source string to the mentioned function for being able to count the lines and columns accordingly. inside the function by two `for` loop the function returns the starting and ending of character map + length.\r\nThere are also some notation fix for `snowcrash.cc` for constancy of the code in compare with snowcrash library.\r\n","created_at":"2014-10-19T18:40:49Z","updated_at":"2014-10-23T13:09:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9eac0146df2da89b952542f05c75c9f038a07f93","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apiaryio/snowcrash/pulls/245/commits","review_comments_url":"https://api.github.com/repos/apiaryio/snowcrash/pulls/245/comments","review_comment_url":"https://api.github.com/repos/apiaryio/snowcrash/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apiaryio/snowcrash/issues/245/comments","statuses_url":"https://api.github.com/repos/apiaryio/snowcrash/statuses/1839ad45685b5478a817805c2c71648dc6b9ac7e","head":{"label":"alikh31:alikh31/issue#162","ref":"alikh31/issue#162","sha":"1839ad45685b5478a817805c2c71648dc6b9ac7e","user":{"login":"alikh31","id":6755109,"avatar_url":"https://avatars.githubusercontent.com/u/6755109?v=2","gravatar_id":"","url":"https://api.github.com/users/alikh31","html_url":"https://github.com/alikh31","followers_url":"https://api.github.com/users/alikh31/followers","following_url":"https://api.github.com/users/alikh31/following{/other_user}","gists_url":"https://api.github.com/users/alikh31/gists{/gist_id}","starred_url":"https://api.github.com/users/alikh31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alikh31/subscriptions","organizations_url":"https://api.github.com/users/alikh31/orgs","repos_url":"https://api.github.com/users/alikh31/repos","events_url":"https://api.github.com/users/alikh31/events{/privacy}","received_events_url":"https://api.github.com/users/alikh31/received_events","type":"User","site_admin":false},"repo":{"id":18800810,"name":"snowcrash","full_name":"alikh31/snowcrash","owner":{"login":"alikh31","id":6755109,"avatar_url":"https://avatars.githubusercontent.com/u/6755109?v=2","gravatar_id":"","url":"https://api.github.com/users/alikh31","html_url":"https://github.com/alikh31","followers_url":"https://api.github.com/users/alikh31/followers","following_url":"https://api.github.com/users/alikh31/following{/other_user}","gists_url":"https://api.github.com/users/alikh31/gists{/gist_id}","starred_url":"https://api.github.com/users/alikh31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alikh31/subscriptions","organizations_url":"https://api.github.com/users/alikh31/orgs","repos_url":"https://api.github.com/users/alikh31/repos","events_url":"https://api.github.com/users/alikh31/events{/privacy}","received_events_url":"https://api.github.com/users/alikh31/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alikh31/snowcrash","description":"API Blueprint Parser","fork":true,"url":"https://api.github.com/repos/alikh31/snowcrash","forks_url":"https://api.github.com/repos/alikh31/snowcrash/forks","keys_url":"https://api.github.com/repos/alikh31/snowcrash/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alikh31/snowcrash/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alikh31/snowcrash/teams","hooks_url":"https://api.github.com/repos/alikh31/snowcrash/hooks","issue_events_url":"https://api.github.com/repos/alikh31/snowcrash/issues/events{/number}","events_url":"https://api.github.com/repos/alikh31/snowcrash/events","assignees_url":"https://api.github.com/repos/alikh31/snowcrash/assignees{/user}","branches_url":"https://api.github.com/repos/alikh31/snowcrash/branches{/branch}","tags_url":"https://api.github.com/repos/alikh31/snowcrash/tags","blobs_url":"https://api.github.com/repos/alikh31/snowcrash/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alikh31/snowcrash/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alikh31/snowcrash/git/refs{/sha}","trees_url":"https://api.github.com/repos/alikh31/snowcrash/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alikh31/snowcrash/statuses/{sha}","languages_url":"https://api.github.com/repos/alikh31/snowcrash/languages","stargazers_url":"https://api.github.com/repos/alikh31/snowcrash/stargazers","contributors_url":"https://api.github.com/repos/alikh31/snowcrash/contributors","subscribers_url":"https://api.github.com/repos/alikh31/snowcrash/subscribers","subscription_url":"https://api.github.com/repos/alikh31/snowcrash/subscription","commits_url":"https://api.github.com/repos/alikh31/snowcrash/commits{/sha}","git_commits_url":"https://api.github.com/repos/alikh31/snowcrash/git/commits{/sha}","comments_url":"https://api.github.com/repos/alikh31/snowcrash/comments{/number}","issue_comment_url":"https://api.github.com/repos/alikh31/snowcrash/issues/comments/{number}","contents_url":"https://api.github.com/repos/alikh31/snowcrash/contents/{+path}","compare_url":"https://api.github.com/repos/alikh31/snowcrash/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alikh31/snowcrash/merges","archive_url":"https://api.github.com/repos/alikh31/snowcrash/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alikh31/snowcrash/downloads","issues_url":"https://api.github.com/repos/alikh31/snowcrash/issues{/number}","pulls_url":"https://api.github.com/repos/alikh31/snowcrash/pulls{/number}","milestones_url":"https://api.github.com/repos/alikh31/snowcrash/milestones{/number}","notifications_url":"https://api.github.com/repos/alikh31/snowcrash/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alikh31/snowcrash/labels{/name}","releases_url":"https://api.github.com/repos/alikh31/snowcrash/releases{/id}","created_at":"2014-04-15T13:24:13Z","updated_at":"2014-07-07T08:09:39Z","pushed_at":"2014-10-23T13:04:41Z","git_url":"git://github.com/alikh31/snowcrash.git","ssh_url":"git@github.com:alikh31/snowcrash.git","clone_url":"https://github.com/alikh31/snowcrash.git","svn_url":"https://github.com/alikh31/snowcrash","homepage":null,"size":4147,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apiaryio:master","ref":"master","sha":"ee327d68771daa07fc075b780e395be6dd102e93","user":{"login":"apiaryio","id":765943,"avatar_url":"https://avatars.githubusercontent.com/u/765943?v=2","gravatar_id":"","url":"https://api.github.com/users/apiaryio","html_url":"https://github.com/apiaryio","followers_url":"https://api.github.com/users/apiaryio/followers","following_url":"https://api.github.com/users/apiaryio/following{/other_user}","gists_url":"https://api.github.com/users/apiaryio/gists{/gist_id}","starred_url":"https://api.github.com/users/apiaryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiaryio/subscriptions","organizations_url":"https://api.github.com/users/apiaryio/orgs","repos_url":"https://api.github.com/users/apiaryio/repos","events_url":"https://api.github.com/users/apiaryio/events{/privacy}","received_events_url":"https://api.github.com/users/apiaryio/received_events","type":"Organization","site_admin":false},"repo":{"id":9173280,"name":"snowcrash","full_name":"apiaryio/snowcrash","owner":{"login":"apiaryio","id":765943,"avatar_url":"https://avatars.githubusercontent.com/u/765943?v=2","gravatar_id":"","url":"https://api.github.com/users/apiaryio","html_url":"https://github.com/apiaryio","followers_url":"https://api.github.com/users/apiaryio/followers","following_url":"https://api.github.com/users/apiaryio/following{/other_user}","gists_url":"https://api.github.com/users/apiaryio/gists{/gist_id}","starred_url":"https://api.github.com/users/apiaryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiaryio/subscriptions","organizations_url":"https://api.github.com/users/apiaryio/orgs","repos_url":"https://api.github.com/users/apiaryio/repos","events_url":"https://api.github.com/users/apiaryio/events{/privacy}","received_events_url":"https://api.github.com/users/apiaryio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apiaryio/snowcrash","description":"API Blueprint Parser","fork":false,"url":"https://api.github.com/repos/apiaryio/snowcrash","forks_url":"https://api.github.com/repos/apiaryio/snowcrash/forks","keys_url":"https://api.github.com/repos/apiaryio/snowcrash/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apiaryio/snowcrash/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apiaryio/snowcrash/teams","hooks_url":"https://api.github.com/repos/apiaryio/snowcrash/hooks","issue_events_url":"https://api.github.com/repos/apiaryio/snowcrash/issues/events{/number}","events_url":"https://api.github.com/repos/apiaryio/snowcrash/events","assignees_url":"https://api.github.com/repos/apiaryio/snowcrash/assignees{/user}","branches_url":"https://api.github.com/repos/apiaryio/snowcrash/branches{/branch}","tags_url":"https://api.github.com/repos/apiaryio/snowcrash/tags","blobs_url":"https://api.github.com/repos/apiaryio/snowcrash/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apiaryio/snowcrash/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apiaryio/snowcrash/git/refs{/sha}","trees_url":"https://api.github.com/repos/apiaryio/snowcrash/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apiaryio/snowcrash/statuses/{sha}","languages_url":"https://api.github.com/repos/apiaryio/snowcrash/languages","stargazers_url":"https://api.github.com/repos/apiaryio/snowcrash/stargazers","contributors_url":"https://api.github.com/repos/apiaryio/snowcrash/contributors","subscribers_url":"https://api.github.com/repos/apiaryio/snowcrash/subscribers","subscription_url":"https://api.github.com/repos/apiaryio/snowcrash/subscription","commits_url":"https://api.github.com/repos/apiaryio/snowcrash/commits{/sha}","git_commits_url":"https://api.github.com/repos/apiaryio/snowcrash/git/commits{/sha}","comments_url":"https://api.github.com/repos/apiaryio/snowcrash/comments{/number}","issue_comment_url":"https://api.github.com/repos/apiaryio/snowcrash/issues/comments/{number}","contents_url":"https://api.github.com/repos/apiaryio/snowcrash/contents/{+path}","compare_url":"https://api.github.com/repos/apiaryio/snowcrash/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apiaryio/snowcrash/merges","archive_url":"https://api.github.com/repos/apiaryio/snowcrash/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apiaryio/snowcrash/downloads","issues_url":"https://api.github.com/repos/apiaryio/snowcrash/issues{/number}","pulls_url":"https://api.github.com/repos/apiaryio/snowcrash/pulls{/number}","milestones_url":"https://api.github.com/repos/apiaryio/snowcrash/milestones{/number}","notifications_url":"https://api.github.com/repos/apiaryio/snowcrash/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apiaryio/snowcrash/labels{/name}","releases_url":"https://api.github.com/repos/apiaryio/snowcrash/releases{/id}","created_at":"2013-04-02T15:23:04Z","updated_at":"2014-10-21T16:36:52Z","pushed_at":"2014-10-23T13:01:00Z","git_url":"git://github.com/apiaryio/snowcrash.git","ssh_url":"git@github.com:apiaryio/snowcrash.git","clone_url":"https://github.com/apiaryio/snowcrash.git","svn_url":"https://github.com/apiaryio/snowcrash","homepage":null,"size":10539,"stargazers_count":181,"watchers_count":181,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":22,"forks":33,"open_issues":22,"watchers":181,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apiaryio/snowcrash/pulls/245"},"html":{"href":"https://github.com/apiaryio/snowcrash/pull/245"},"issue":{"href":"https://api.github.com/repos/apiaryio/snowcrash/issues/245"},"comments":{"href":"https://api.github.com/repos/apiaryio/snowcrash/issues/245/comments"},"review_comments":{"href":"https://api.github.com/repos/apiaryio/snowcrash/pulls/245/comments"},"review_comment":{"href":"https://api.github.com/repos/apiaryio/snowcrash/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apiaryio/snowcrash/pulls/245/commits"},"statuses":{"href":"https://api.github.com/repos/apiaryio/snowcrash/statuses/1839ad45685b5478a817805c2c71648dc6b9ac7e"}}}}