{"action":"created","comment":{"url":"https://api.github.com/repos/influxdata/flux/pulls/comments/244843867","pull_request_review_id":188815518,"id":244843867,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NDg0Mzg2Nw==","diff_hunk":"@@ -0,0 +1,121 @@\n+package ast\n+\n+import (\n+\t\"strconv\"\n+\t\"strings\"\n+)\n+\n+// GetErrors will collect all of the errors from the construction of the AST.\n+// If there were no errors, this will return nil. If the limit is set to\n+// positive number, it will limit the number of errors to the given number. If\n+// it is set to a negative number, it will return the last N errors. A value of\n+// zero will return all errors.\n+func GetErrors(root Node, limit int) []error {\n+\tv := errorVisitor{limit: limit}\n+\tWalk(&v, root)\n+\tif limit < 0 && len(v.errs) > -limit {\n+\t\tsz := -limit\n+\t\terrs := make([]error, 0, sz)\n+\t\tfor i := len(v.errs) - sz; i < len(v.errs); i++ {\n+\t\t\terrs = append(errs, v.errs[i])\n+\t\t}\n+\t\treturn errs\n+\t}\n+\treturn v.errs\n+}\n+\n+// errorDetail contains the details of the error. Err is the error itself while\n+// Detail is the detailed information about the error.\n+type errorDetail struct {\n+\tErr    string\n+\tDetail string\n+}\n+\n+func (e errorDetail) Error() string {\n+\tvar sb strings.Builder\n+\tsb.WriteString(e.Err)\n+\tif e.Detail != \"\" {\n+\t\tsb.WriteString(\": \")\n+\t\tsb.WriteString(e.Detail)\n+\t}\n+\treturn sb.String()\n+}\n+\n+// Error is an error within the AST. It contains the information about\n+// where the error happened along with the underlying cause.\n+type Error struct {\n+\tloc   SourceLocation\n+\tcause errorDetail\n+}\n+\n+func (e *Error) Error() string {\n+\tvar sb strings.Builder\n+\tsb.WriteString(e.cause.Err)\n+\tif e.loc.Start.Line > 0 {\n+\t\tif sb.Len() > 0 {\n+\t\t\tsb.WriteString(\":\")\n+\t\t}\n+\t\tsb.WriteString(strconv.FormatInt(int64(e.loc.Start.Line), 10))\n+\t}\n+\tif e.loc.Start.Column > 0 {\n+\t\tif sb.Len() > 0 {\n+\t\t\tsb.WriteString(\":\")\n+\t\t}\n+\t\tsb.WriteString(strconv.FormatInt(int64(e.loc.Start.Column), 10))\n+\t}\n+\tif e.cause.Detail != \"\" {\n+\t\tif sb.Len() > 0 {\n+\t\t\tsb.WriteString(\": \")\n+\t\t}\n+\t\tsb.WriteString(e.cause.Detail)\n+\t}\n+\treturn sb.String()\n+}\n+\n+func (e *Error) Location() SourceLocation {\n+\treturn e.loc\n+}\n+\n+func (e *Error) Cause() error {\n+\treturn e.cause\n+}\n+\n+type errorVisitor struct {\n+\terrs  []error\n+\tlimit int\n+}\n+\n+func (ev *errorVisitor) Visit(n Node) Visitor {\n+\tif !ev.more() {\n+\t\treturn nil\n+\t}\n+\n+\t// TODO(jsternberg): Fill in the details for how we retrieve errors.\n+\tswitch n := n.(type) {\n+\tcase *BadStatement:","path":"ast/errors.go","position":82,"original_position":95,"commit_id":"a0f92352ccbac3808512a87a1f500db449563108","original_commit_id":"ffc9df2824ff5342a76533943decb86a88086b48","user":{"login":"jsternberg","id":1212129,"node_id":"MDQ6VXNlcjEyMTIxMjk=","avatar_url":"https://avatars2.githubusercontent.com/u/1212129?v=4","gravatar_id":"","url":"https://api.github.com/users/jsternberg","html_url":"https://github.com/jsternberg","followers_url":"https://api.github.com/users/jsternberg/followers","following_url":"https://api.github.com/users/jsternberg/following{/other_user}","gists_url":"https://api.github.com/users/jsternberg/gists{/gist_id}","starred_url":"https://api.github.com/users/jsternberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsternberg/subscriptions","organizations_url":"https://api.github.com/users/jsternberg/orgs","repos_url":"https://api.github.com/users/jsternberg/repos","events_url":"https://api.github.com/users/jsternberg/events{/privacy}","received_events_url":"https://api.github.com/users/jsternberg/received_events","type":"User","site_admin":false},"body":"Yes. I was expecting this switch statement to contain the equivalent `Validate` logic for each node, but I wanted to keep it hidden just so we had more flexibility with error handling so there wouldn't be a specific `Validate` method. I also wanted it in one location just so that we could see all error handling text in a single location rather than hunting around for the correct implementation.\r\n\r\nAlthough that's an implementation detail so we could switch to using `Validate` instead pretty easily or we could switch the logic to an unexposed `validate` method. Before doing that though, I would like to experiment with this code layout.","created_at":"2019-01-02T20:23:36Z","updated_at":"2019-01-02T20:23:37Z","html_url":"https://github.com/influxdata/flux/pull/288#discussion_r244843867","pull_request_url":"https://api.github.com/repos/influxdata/flux/pulls/288","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/influxdata/flux/pulls/comments/244843867"},"html":{"href":"https://github.com/influxdata/flux/pull/288#discussion_r244843867"},"pull_request":{"href":"https://api.github.com/repos/influxdata/flux/pulls/288"}},"in_reply_to_id":244801572},"pull_request":{"url":"https://api.github.com/repos/influxdata/flux/pulls/288","id":231270707,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxMjcwNzA3","html_url":"https://github.com/influxdata/flux/pull/288","diff_url":"https://github.com/influxdata/flux/pull/288.diff","patch_url":"https://github.com/influxdata/flux/pull/288.patch","issue_url":"https://api.github.com/repos/influxdata/flux/issues/288","number":288,"state":"open","locked":false,"title":"feat(parser): add a method for retrieving errors within the flux AST","user":{"login":"jsternberg","id":1212129,"node_id":"MDQ6VXNlcjEyMTIxMjk=","avatar_url":"https://avatars2.githubusercontent.com/u/1212129?v=4","gravatar_id":"","url":"https://api.github.com/users/jsternberg","html_url":"https://github.com/jsternberg","followers_url":"https://api.github.com/users/jsternberg/followers","following_url":"https://api.github.com/users/jsternberg/following{/other_user}","gists_url":"https://api.github.com/users/jsternberg/gists{/gist_id}","starred_url":"https://api.github.com/users/jsternberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsternberg/subscriptions","organizations_url":"https://api.github.com/users/jsternberg/orgs","repos_url":"https://api.github.com/users/jsternberg/repos","events_url":"https://api.github.com/users/jsternberg/events{/privacy}","received_events_url":"https://api.github.com/users/jsternberg/received_events","type":"User","site_admin":false},"body":"The `GetErrors` method will traverse the AST and find any nodes that\nimplement the `error` interface. It will then add them to the list of\nerrors that were added while constructing the AST and these nodes should\nalso have information about where the error happened.\n\nThis also includes a way to limit the number of errors so that we can\nimplement a functionality to only print the first error (might be useful\nfor chronograf) or limit the command line output to the first 10 errors. If\na value of zero or lower is given, it will collect all errors.","created_at":"2018-11-15T17:10:58Z","updated_at":"2019-01-02T20:23:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6445b2631966c9596e0e4a6333c89c3b8e422cfe","assignee":{"login":"nathanielc","id":3771906,"node_id":"MDQ6VXNlcjM3NzE5MDY=","avatar_url":"https://avatars3.githubusercontent.com/u/3771906?v=4","gravatar_id":"","url":"https://api.github.com/users/nathanielc","html_url":"https://github.com/nathanielc","followers_url":"https://api.github.com/users/nathanielc/followers","following_url":"https://api.github.com/users/nathanielc/following{/other_user}","gists_url":"https://api.github.com/users/nathanielc/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanielc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanielc/subscriptions","organizations_url":"https://api.github.com/users/nathanielc/orgs","repos_url":"https://api.github.com/users/nathanielc/repos","events_url":"https://api.github.com/users/nathanielc/events{/privacy}","received_events_url":"https://api.github.com/users/nathanielc/received_events","type":"User","site_admin":false},"assignees":[{"login":"nathanielc","id":3771906,"node_id":"MDQ6VXNlcjM3NzE5MDY=","avatar_url":"https://avatars3.githubusercontent.com/u/3771906?v=4","gravatar_id":"","url":"https://api.github.com/users/nathanielc","html_url":"https://github.com/nathanielc","followers_url":"https://api.github.com/users/nathanielc/followers","following_url":"https://api.github.com/users/nathanielc/following{/other_user}","gists_url":"https://api.github.com/users/nathanielc/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanielc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanielc/subscriptions","organizations_url":"https://api.github.com/users/nathanielc/orgs","repos_url":"https://api.github.com/users/nathanielc/repos","events_url":"https://api.github.com/users/nathanielc/events{/privacy}","received_events_url":"https://api.github.com/users/nathanielc/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/influxdata/flux/pulls/288/commits","review_comments_url":"https://api.github.com/repos/influxdata/flux/pulls/288/comments","review_comment_url":"https://api.github.com/repos/influxdata/flux/pulls/comments{/number}","comments_url":"https://api.github.com/repos/influxdata/flux/issues/288/comments","statuses_url":"https://api.github.com/repos/influxdata/flux/statuses/a0f92352ccbac3808512a87a1f500db449563108","head":{"label":"influxdata:js-parser-get-errors","ref":"js-parser-get-errors","sha":"a0f92352ccbac3808512a87a1f500db449563108","user":{"login":"influxdata","id":5713248,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3MTMyNDg=","avatar_url":"https://avatars2.githubusercontent.com/u/5713248?v=4","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"repo":{"id":137362393,"node_id":"MDEwOlJlcG9zaXRvcnkxMzczNjIzOTM=","name":"flux","full_name":"influxdata/flux","private":false,"owner":{"login":"influxdata","id":5713248,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3MTMyNDg=","avatar_url":"https://avatars2.githubusercontent.com/u/5713248?v=4","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/influxdata/flux","description":"Flux is a lightweight scripting language for querying databases (like InfluxDB) and working with data. It's part of InfluxDB 1.7 and 2.0, but can be run independently of those.","fork":false,"url":"https://api.github.com/repos/influxdata/flux","forks_url":"https://api.github.com/repos/influxdata/flux/forks","keys_url":"https://api.github.com/repos/influxdata/flux/keys{/key_id}","collaborators_url":"https://api.github.com/repos/influxdata/flux/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/influxdata/flux/teams","hooks_url":"https://api.github.com/repos/influxdata/flux/hooks","issue_events_url":"https://api.github.com/repos/influxdata/flux/issues/events{/number}","events_url":"https://api.github.com/repos/influxdata/flux/events","assignees_url":"https://api.github.com/repos/influxdata/flux/assignees{/user}","branches_url":"https://api.github.com/repos/influxdata/flux/branches{/branch}","tags_url":"https://api.github.com/repos/influxdata/flux/tags","blobs_url":"https://api.github.com/repos/influxdata/flux/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/influxdata/flux/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/influxdata/flux/git/refs{/sha}","trees_url":"https://api.github.com/repos/influxdata/flux/git/trees{/sha}","statuses_url":"https://api.github.com/repos/influxdata/flux/statuses/{sha}","languages_url":"https://api.github.com/repos/influxdata/flux/languages","stargazers_url":"https://api.github.com/repos/influxdata/flux/stargazers","contributors_url":"https://api.github.com/repos/influxdata/flux/contributors","subscribers_url":"https://api.github.com/repos/influxdata/flux/subscribers","subscription_url":"https://api.github.com/repos/influxdata/flux/subscription","commits_url":"https://api.github.com/repos/influxdata/flux/commits{/sha}","git_commits_url":"https://api.github.com/repos/influxdata/flux/git/commits{/sha}","comments_url":"https://api.github.com/repos/influxdata/flux/comments{/number}","issue_comment_url":"https://api.github.com/repos/influxdata/flux/issues/comments{/number}","contents_url":"https://api.github.com/repos/influxdata/flux/contents/{+path}","compare_url":"https://api.github.com/repos/influxdata/flux/compare/{base}...{head}","merges_url":"https://api.github.com/repos/influxdata/flux/merges","archive_url":"https://api.github.com/repos/influxdata/flux/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/influxdata/flux/downloads","issues_url":"https://api.github.com/repos/influxdata/flux/issues{/number}","pulls_url":"https://api.github.com/repos/influxdata/flux/pulls{/number}","milestones_url":"https://api.github.com/repos/influxdata/flux/milestones{/number}","notifications_url":"https://api.github.com/repos/influxdata/flux/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/influxdata/flux/labels{/name}","releases_url":"https://api.github.com/repos/influxdata/flux/releases{/id}","deployments_url":"https://api.github.com/repos/influxdata/flux/deployments","created_at":"2018-06-14T13:32:57Z","updated_at":"2019-01-02T18:44:46Z","pushed_at":"2019-01-02T20:10:01Z","git_url":"git://github.com/influxdata/flux.git","ssh_url":"git@github.com:influxdata/flux.git","clone_url":"https://github.com/influxdata/flux.git","svn_url":"https://github.com/influxdata/flux","homepage":"https://influxdata.com","size":2860,"stargazers_count":65,"watchers_count":65,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":232,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":5,"open_issues":232,"watchers":65,"default_branch":"master"}},"base":{"label":"influxdata:master","ref":"master","sha":"8d7ca30b6c00fe28613ea9b2da07cb352442c3ab","user":{"login":"influxdata","id":5713248,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3MTMyNDg=","avatar_url":"https://avatars2.githubusercontent.com/u/5713248?v=4","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"repo":{"id":137362393,"node_id":"MDEwOlJlcG9zaXRvcnkxMzczNjIzOTM=","name":"flux","full_name":"influxdata/flux","private":false,"owner":{"login":"influxdata","id":5713248,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3MTMyNDg=","avatar_url":"https://avatars2.githubusercontent.com/u/5713248?v=4","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/influxdata/flux","description":"Flux is a lightweight scripting language for querying databases (like InfluxDB) and working with data. It's part of InfluxDB 1.7 and 2.0, but can be run independently of those.","fork":false,"url":"https://api.github.com/repos/influxdata/flux","forks_url":"https://api.github.com/repos/influxdata/flux/forks","keys_url":"https://api.github.com/repos/influxdata/flux/keys{/key_id}","collaborators_url":"https://api.github.com/repos/influxdata/flux/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/influxdata/flux/teams","hooks_url":"https://api.github.com/repos/influxdata/flux/hooks","issue_events_url":"https://api.github.com/repos/influxdata/flux/issues/events{/number}","events_url":"https://api.github.com/repos/influxdata/flux/events","assignees_url":"https://api.github.com/repos/influxdata/flux/assignees{/user}","branches_url":"https://api.github.com/repos/influxdata/flux/branches{/branch}","tags_url":"https://api.github.com/repos/influxdata/flux/tags","blobs_url":"https://api.github.com/repos/influxdata/flux/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/influxdata/flux/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/influxdata/flux/git/refs{/sha}","trees_url":"https://api.github.com/repos/influxdata/flux/git/trees{/sha}","statuses_url":"https://api.github.com/repos/influxdata/flux/statuses/{sha}","languages_url":"https://api.github.com/repos/influxdata/flux/languages","stargazers_url":"https://api.github.com/repos/influxdata/flux/stargazers","contributors_url":"https://api.github.com/repos/influxdata/flux/contributors","subscribers_url":"https://api.github.com/repos/influxdata/flux/subscribers","subscription_url":"https://api.github.com/repos/influxdata/flux/subscription","commits_url":"https://api.github.com/repos/influxdata/flux/commits{/sha}","git_commits_url":"https://api.github.com/repos/influxdata/flux/git/commits{/sha}","comments_url":"https://api.github.com/repos/influxdata/flux/comments{/number}","issue_comment_url":"https://api.github.com/repos/influxdata/flux/issues/comments{/number}","contents_url":"https://api.github.com/repos/influxdata/flux/contents/{+path}","compare_url":"https://api.github.com/repos/influxdata/flux/compare/{base}...{head}","merges_url":"https://api.github.com/repos/influxdata/flux/merges","archive_url":"https://api.github.com/repos/influxdata/flux/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/influxdata/flux/downloads","issues_url":"https://api.github.com/repos/influxdata/flux/issues{/number}","pulls_url":"https://api.github.com/repos/influxdata/flux/pulls{/number}","milestones_url":"https://api.github.com/repos/influxdata/flux/milestones{/number}","notifications_url":"https://api.github.com/repos/influxdata/flux/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/influxdata/flux/labels{/name}","releases_url":"https://api.github.com/repos/influxdata/flux/releases{/id}","deployments_url":"https://api.github.com/repos/influxdata/flux/deployments","created_at":"2018-06-14T13:32:57Z","updated_at":"2019-01-02T18:44:46Z","pushed_at":"2019-01-02T20:10:01Z","git_url":"git://github.com/influxdata/flux.git","ssh_url":"git@github.com:influxdata/flux.git","clone_url":"https://github.com/influxdata/flux.git","svn_url":"https://github.com/influxdata/flux","homepage":"https://influxdata.com","size":2860,"stargazers_count":65,"watchers_count":65,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":232,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":5,"open_issues":232,"watchers":65,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/influxdata/flux/pulls/288"},"html":{"href":"https://github.com/influxdata/flux/pull/288"},"issue":{"href":"https://api.github.com/repos/influxdata/flux/issues/288"},"comments":{"href":"https://api.github.com/repos/influxdata/flux/issues/288/comments"},"review_comments":{"href":"https://api.github.com/repos/influxdata/flux/pulls/288/comments"},"review_comment":{"href":"https://api.github.com/repos/influxdata/flux/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/influxdata/flux/pulls/288/commits"},"statuses":{"href":"https://api.github.com/repos/influxdata/flux/statuses/a0f92352ccbac3808512a87a1f500db449563108"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jsternberg"}}