{"action":"created","comment":{"url":"https://api.github.com/repos/SonarSource/sslr/pulls/comments/33780467","id":33780467,"diff_hunk":"@@ -0,0 +1,99 @@\n+/*\n+ * SonarSource Language Recognizer\n+ * Copyright (C) 2010 SonarSource\n+ * dev@sonar.codehaus.org\n+ *\n+ * This program is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU Lesser General Public\n+ * License as published by the Free Software Foundation; either\n+ * version 3 of the License, or (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+ * Lesser General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Lesser General Public\n+ * License along with this program; if not, write to the Free Software\n+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02\n+ */\n+package com.sonar.sslr.api.typed;\n+\n+import com.google.common.annotations.Beta;\n+import com.google.common.collect.Lists;\n+\n+import java.io.File;\n+import java.net.URI;\n+import java.util.Arrays;\n+import java.util.List;\n+\n+@Beta\n+public class Input {\n+\n+  private static final URI FAKE_URI = new File(\"tests://unittests\").toURI();\n+\n+  private final char[] input;\n+  private final URI uri;\n+  private final int[] newLineIndexes;\n+\n+  public Input(char[] input) {\n+    this(input, FAKE_URI);\n+  }\n+\n+  public Input(char[] input, URI uri) {\n+    this.input = input;\n+    this.uri = uri;\n+\n+    List<Integer> newLineIndexesBuilder = Lists.newArrayList();\n+    for (int i = 0; i < input.length; i++) {\n+      if (isNewLine(input, i)) {\n+        newLineIndexesBuilder.add(i + 1);\n+      }\n+    }\n+    this.newLineIndexes = new int[newLineIndexesBuilder.size()];\n+    for (int i = 0; i < newLineIndexes.length; i++) {\n+      this.newLineIndexes[i] = newLineIndexesBuilder.get(i);\n+    }\n+  }\n+\n+  public char[] input() {\n+    return input;\n+  }\n+\n+  public URI uri() {\n+    return uri;\n+  }\n+\n+  public String substring(int from, int to) {\n+    StringBuilder sb = new StringBuilder();\n+    for (int i = from; i < to; i++) {\n+      sb.append(input[i]);\n+    }\n+    return sb.toString();\n+  }\n+\n+  public int[] lineAndColumnAt(int index) {\n+    int[] result = new int[2];\n+    result[0] = lineAt(index);\n+    result[1] = index - lineStartIndex(result[0]) + 1;\n+    return result;\n+  }\n+\n+  private int lineAt(int index) {\n+    int i = Arrays.binarySearch(newLineIndexes, index);\n+    return i >= 0 ? i + 2 : -i;","path":"sslr-core/src/main/java/com/sonar/sslr/api/typed/Input.java","position":84,"original_position":84,"commit_id":"5dc6a15fc8fd2613f294a961f52246e9e4e5b291","original_commit_id":"5dc6a15fc8fd2613f294a961f52246e9e4e5b291","user":{"login":"SonarTech","id":1842438,"avatar_url":"https://avatars.githubusercontent.com/u/1842438?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarTech","html_url":"https://github.com/SonarTech","followers_url":"https://api.github.com/users/SonarTech/followers","following_url":"https://api.github.com/users/SonarTech/following{/other_user}","gists_url":"https://api.github.com/users/SonarTech/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarTech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarTech/subscriptions","organizations_url":"https://api.github.com/users/SonarTech/orgs","repos_url":"https://api.github.com/users/SonarTech/repos","events_url":"https://api.github.com/users/SonarTech/events{/privacy}","received_events_url":"https://api.github.com/users/SonarTech/received_events","type":"User","site_admin":false},"body":"![MAJOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-major.png) Add parentheses to make the operator precedence explicit. [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](http://nemo.sonarqube.org/coding_rules#rule_key=squid%3AS864)\n","created_at":"2015-07-02T14:03:43Z","updated_at":"2015-07-02T14:03:43Z","html_url":"https://github.com/SonarSource/sslr/pull/3#discussion_r33780467","pull_request_url":"https://api.github.com/repos/SonarSource/sslr/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sslr/pulls/comments/33780467"},"html":{"href":"https://github.com/SonarSource/sslr/pull/3#discussion_r33780467"},"pull_request":{"href":"https://api.github.com/repos/SonarSource/sslr/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/SonarSource/sslr/pulls/3","id":39085292,"html_url":"https://github.com/SonarSource/sslr/pull/3","diff_url":"https://github.com/SonarSource/sslr/pull/3.diff","patch_url":"https://github.com/SonarSource/sslr/pull/3.patch","issue_url":"https://api.github.com/repos/SonarSource/sslr/issues/3","number":3,"state":"open","locked":false,"title":"SSLR-373 Provide an API to build a strongly typed tree","user":{"login":"pynicolas","id":6371790,"avatar_url":"https://avatars.githubusercontent.com/u/6371790?v=3","gravatar_id":"","url":"https://api.github.com/users/pynicolas","html_url":"https://github.com/pynicolas","followers_url":"https://api.github.com/users/pynicolas/followers","following_url":"https://api.github.com/users/pynicolas/following{/other_user}","gists_url":"https://api.github.com/users/pynicolas/gists{/gist_id}","starred_url":"https://api.github.com/users/pynicolas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pynicolas/subscriptions","organizations_url":"https://api.github.com/users/pynicolas/orgs","repos_url":"https://api.github.com/users/pynicolas/repos","events_url":"https://api.github.com/users/pynicolas/events{/privacy}","received_events_url":"https://api.github.com/users/pynicolas/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-02T13:59:29Z","updated_at":"2015-07-02T14:03:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"179baa8cdf896c95073f853f3f2ce65e8b44c4e4","assignee":{"login":"dbolkensteyn","id":1132601,"avatar_url":"https://avatars.githubusercontent.com/u/1132601?v=3","gravatar_id":"","url":"https://api.github.com/users/dbolkensteyn","html_url":"https://github.com/dbolkensteyn","followers_url":"https://api.github.com/users/dbolkensteyn/followers","following_url":"https://api.github.com/users/dbolkensteyn/following{/other_user}","gists_url":"https://api.github.com/users/dbolkensteyn/gists{/gist_id}","starred_url":"https://api.github.com/users/dbolkensteyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbolkensteyn/subscriptions","organizations_url":"https://api.github.com/users/dbolkensteyn/orgs","repos_url":"https://api.github.com/users/dbolkensteyn/repos","events_url":"https://api.github.com/users/dbolkensteyn/events{/privacy}","received_events_url":"https://api.github.com/users/dbolkensteyn/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/SonarSource/sslr/pulls/3/commits","review_comments_url":"https://api.github.com/repos/SonarSource/sslr/pulls/3/comments","review_comment_url":"https://api.github.com/repos/SonarSource/sslr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SonarSource/sslr/issues/3/comments","statuses_url":"https://api.github.com/repos/SonarSource/sslr/statuses/5dc6a15fc8fd2613f294a961f52246e9e4e5b291","head":{"label":"pynicolas:typed","ref":"typed","sha":"5dc6a15fc8fd2613f294a961f52246e9e4e5b291","user":{"login":"pynicolas","id":6371790,"avatar_url":"https://avatars.githubusercontent.com/u/6371790?v=3","gravatar_id":"","url":"https://api.github.com/users/pynicolas","html_url":"https://github.com/pynicolas","followers_url":"https://api.github.com/users/pynicolas/followers","following_url":"https://api.github.com/users/pynicolas/following{/other_user}","gists_url":"https://api.github.com/users/pynicolas/gists{/gist_id}","starred_url":"https://api.github.com/users/pynicolas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pynicolas/subscriptions","organizations_url":"https://api.github.com/users/pynicolas/orgs","repos_url":"https://api.github.com/users/pynicolas/repos","events_url":"https://api.github.com/users/pynicolas/events{/privacy}","received_events_url":"https://api.github.com/users/pynicolas/received_events","type":"User","site_admin":false},"repo":{"id":38372235,"name":"sslr","full_name":"pynicolas/sslr","owner":{"login":"pynicolas","id":6371790,"avatar_url":"https://avatars.githubusercontent.com/u/6371790?v=3","gravatar_id":"","url":"https://api.github.com/users/pynicolas","html_url":"https://github.com/pynicolas","followers_url":"https://api.github.com/users/pynicolas/followers","following_url":"https://api.github.com/users/pynicolas/following{/other_user}","gists_url":"https://api.github.com/users/pynicolas/gists{/gist_id}","starred_url":"https://api.github.com/users/pynicolas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pynicolas/subscriptions","organizations_url":"https://api.github.com/users/pynicolas/orgs","repos_url":"https://api.github.com/users/pynicolas/repos","events_url":"https://api.github.com/users/pynicolas/events{/privacy}","received_events_url":"https://api.github.com/users/pynicolas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pynicolas/sslr","description":"","fork":true,"url":"https://api.github.com/repos/pynicolas/sslr","forks_url":"https://api.github.com/repos/pynicolas/sslr/forks","keys_url":"https://api.github.com/repos/pynicolas/sslr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pynicolas/sslr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pynicolas/sslr/teams","hooks_url":"https://api.github.com/repos/pynicolas/sslr/hooks","issue_events_url":"https://api.github.com/repos/pynicolas/sslr/issues/events{/number}","events_url":"https://api.github.com/repos/pynicolas/sslr/events","assignees_url":"https://api.github.com/repos/pynicolas/sslr/assignees{/user}","branches_url":"https://api.github.com/repos/pynicolas/sslr/branches{/branch}","tags_url":"https://api.github.com/repos/pynicolas/sslr/tags","blobs_url":"https://api.github.com/repos/pynicolas/sslr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pynicolas/sslr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pynicolas/sslr/git/refs{/sha}","trees_url":"https://api.github.com/repos/pynicolas/sslr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pynicolas/sslr/statuses/{sha}","languages_url":"https://api.github.com/repos/pynicolas/sslr/languages","stargazers_url":"https://api.github.com/repos/pynicolas/sslr/stargazers","contributors_url":"https://api.github.com/repos/pynicolas/sslr/contributors","subscribers_url":"https://api.github.com/repos/pynicolas/sslr/subscribers","subscription_url":"https://api.github.com/repos/pynicolas/sslr/subscription","commits_url":"https://api.github.com/repos/pynicolas/sslr/commits{/sha}","git_commits_url":"https://api.github.com/repos/pynicolas/sslr/git/commits{/sha}","comments_url":"https://api.github.com/repos/pynicolas/sslr/comments{/number}","issue_comment_url":"https://api.github.com/repos/pynicolas/sslr/issues/comments{/number}","contents_url":"https://api.github.com/repos/pynicolas/sslr/contents/{+path}","compare_url":"https://api.github.com/repos/pynicolas/sslr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pynicolas/sslr/merges","archive_url":"https://api.github.com/repos/pynicolas/sslr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pynicolas/sslr/downloads","issues_url":"https://api.github.com/repos/pynicolas/sslr/issues{/number}","pulls_url":"https://api.github.com/repos/pynicolas/sslr/pulls{/number}","milestones_url":"https://api.github.com/repos/pynicolas/sslr/milestones{/number}","notifications_url":"https://api.github.com/repos/pynicolas/sslr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pynicolas/sslr/labels{/name}","releases_url":"https://api.github.com/repos/pynicolas/sslr/releases{/id}","created_at":"2015-07-01T13:20:35Z","updated_at":"2015-07-01T13:20:36Z","pushed_at":"2015-07-02T13:57:33Z","git_url":"git://github.com/pynicolas/sslr.git","ssh_url":"git@github.com:pynicolas/sslr.git","clone_url":"https://github.com/pynicolas/sslr.git","svn_url":"https://github.com/pynicolas/sslr","homepage":null,"size":5442,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"SonarSource:master","ref":"master","sha":"74008891ebac6b93891c0c370d2a9c8db5916719","user":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"repo":{"id":4159017,"name":"sslr","full_name":"SonarSource/sslr","owner":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarSource/sslr","description":"","fork":false,"url":"https://api.github.com/repos/SonarSource/sslr","forks_url":"https://api.github.com/repos/SonarSource/sslr/forks","keys_url":"https://api.github.com/repos/SonarSource/sslr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarSource/sslr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarSource/sslr/teams","hooks_url":"https://api.github.com/repos/SonarSource/sslr/hooks","issue_events_url":"https://api.github.com/repos/SonarSource/sslr/issues/events{/number}","events_url":"https://api.github.com/repos/SonarSource/sslr/events","assignees_url":"https://api.github.com/repos/SonarSource/sslr/assignees{/user}","branches_url":"https://api.github.com/repos/SonarSource/sslr/branches{/branch}","tags_url":"https://api.github.com/repos/SonarSource/sslr/tags","blobs_url":"https://api.github.com/repos/SonarSource/sslr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarSource/sslr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarSource/sslr/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarSource/sslr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarSource/sslr/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarSource/sslr/languages","stargazers_url":"https://api.github.com/repos/SonarSource/sslr/stargazers","contributors_url":"https://api.github.com/repos/SonarSource/sslr/contributors","subscribers_url":"https://api.github.com/repos/SonarSource/sslr/subscribers","subscription_url":"https://api.github.com/repos/SonarSource/sslr/subscription","commits_url":"https://api.github.com/repos/SonarSource/sslr/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarSource/sslr/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarSource/sslr/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarSource/sslr/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarSource/sslr/contents/{+path}","compare_url":"https://api.github.com/repos/SonarSource/sslr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarSource/sslr/merges","archive_url":"https://api.github.com/repos/SonarSource/sslr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarSource/sslr/downloads","issues_url":"https://api.github.com/repos/SonarSource/sslr/issues{/number}","pulls_url":"https://api.github.com/repos/SonarSource/sslr/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarSource/sslr/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarSource/sslr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarSource/sslr/labels{/name}","releases_url":"https://api.github.com/repos/SonarSource/sslr/releases{/id}","created_at":"2012-04-27T14:21:26Z","updated_at":"2015-05-08T16:29:42Z","pushed_at":"2015-07-02T13:59:29Z","git_url":"git://github.com/SonarSource/sslr.git","ssh_url":"git@github.com:SonarSource/sslr.git","clone_url":"https://github.com/SonarSource/sslr.git","svn_url":"https://github.com/SonarSource/sslr","homepage":null,"size":7555,"stargazers_count":20,"watchers_count":20,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":3,"forks":11,"open_issues":3,"watchers":20,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sslr/pulls/3"},"html":{"href":"https://github.com/SonarSource/sslr/pull/3"},"issue":{"href":"https://api.github.com/repos/SonarSource/sslr/issues/3"},"comments":{"href":"https://api.github.com/repos/SonarSource/sslr/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/SonarSource/sslr/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/SonarSource/sslr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SonarSource/sslr/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/SonarSource/sslr/statuses/5dc6a15fc8fd2613f294a961f52246e9e4e5b291"}}}}