Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(690)

Issue 13270045: code review 13270045: go.tools/oracle: add option to output results in JSON s... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
8 years, 10 months ago by adonovan
Modified:
8 years, 10 months ago
Reviewers:
crawshaw1
CC:
crawshaw1, golang-dev
Visibility:
Public.

Description

go.tools/oracle: add option to output results in JSON syntax. See json.go for interface specification. Example usage: % oracle -format=json -mode=callgraph code.google.com/p/go.tools/cmd/oracle + Tests, based on (small) golden files. Overview: Each <query>Result structure has been "lowered" so that all but the most trivial logic in each display() function has been moved to the main query. Each one now has a toJSON method that populates a json.Result struct. Though the <query>Result structs are similar to the correponding JSON protocol, they're not close enough to be used directly; for example, the former contain richer semantic entities (token.Pos, ast.Expr, ssa.Value, pointer.Pointer, etc) whereas JSON contains only their printed forms using Go basic types. The choices of what levels of abstractions the two sets of structs should have is somewhat arbitrary. We may want richer information in the JSON output in future. Details: - oracle.Main has been split into oracle.Query() and the printing of the oracle.Result. - the display() method no longer needs an *oracle param, only a print function. - callees: sort the result for determinism. - callees: compute the union across all contexts. - callers: sort the results for determinism. - describe(package): fixed a bug in the predicate for method accessibility: an unexported method defined in pkg A may belong to a type defined in package B (via embedding/promotion) and may thus be accessible to A. New accessibleMethods() utility fixes this. - describe(type): filter methods by accessibility. - added tests of 'callgraph'. - pointer: eliminated the 'caller CallGraphNode' parameter from pointer.Context.Call callback since it was redundant w.r.t site.Caller(). - added warning if CGO_ENABLED is unset.

Patch Set 1 #

Patch Set 2 : diff -r 28b59754195f https://code.google.com/p/go.tools #

Patch Set 3 : diff -r 7c53df5c9267 https://code.google.com/p/go.tools #

Patch Set 4 : diff -r 7c53df5c9267 https://code.google.com/p/go.tools #

Patch Set 5 : diff -r 7c53df5c9267 https://code.google.com/p/go.tools #

Patch Set 6 : diff -r 7c53df5c9267 https://code.google.com/p/go.tools #

Total comments: 7

Patch Set 7 : diff -r 7c53df5c9267 https://code.google.com/p/go.tools #

Patch Set 8 : diff -r 7c53df5c9267 https://code.google.com/p/go.tools #

Patch Set 9 : diff -r 7c53df5c9267 https://code.google.com/p/go.tools #

Patch Set 10 : diff -r 07183b5c385c https://code.google.com/p/go.tools #

Patch Set 11 : diff -r 07183b5c385c https://code.google.com/p/go.tools #

Patch Set 12 : diff -r 07183b5c385c https://code.google.com/p/go.tools #

Patch Set 13 : diff -r 07183b5c385c https://code.google.com/p/go.tools #

Patch Set 14 : diff -r 07183b5c385c https://code.google.com/p/go.tools #

Patch Set 15 : diff -r 07183b5c385c https://code.google.com/p/go.tools #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1513 lines, -343 lines) Patch
M cmd/oracle/main.go View 1 2 3 4 5 6 7 8 9 10 4 chunks +43 lines, -2 lines 0 comments Download
M oracle/callees.go View 1 2 3 4 5 6 7 8 9 2 chunks +56 lines, -25 lines 0 comments Download
M oracle/callers.go View 1 2 3 4 5 6 7 8 9 3 chunks +31 lines, -18 lines 0 comments Download
M oracle/callgraph.go View 1 2 3 4 5 6 7 8 9 10 11 4 chunks +55 lines, -20 lines 0 comments Download
M oracle/callstack.go View 1 2 3 4 5 6 7 8 9 2 chunks +54 lines, -31 lines 0 comments Download
M oracle/describe.go View 1 2 3 4 5 6 7 8 9 12 chunks +304 lines, -110 lines 0 comments Download
M oracle/freevars.go View 1 2 3 4 5 6 7 8 9 4 chunks +75 lines, -35 lines 0 comments Download
M oracle/implements.go View 1 2 3 4 5 6 7 8 9 4 chunks +23 lines, -6 lines 0 comments Download
A oracle/json/json.go View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +210 lines, -0 lines 0 comments Download
M oracle/oracle.go View 1 2 3 4 5 6 7 8 9 12 chunks +71 lines, -37 lines 0 comments Download
M oracle/oracle_test.go View 1 2 3 4 5 6 7 8 9 4 chunks +35 lines, -14 lines 0 comments Download
M oracle/peers.go View 1 2 3 4 5 6 7 8 9 4 chunks +73 lines, -29 lines 0 comments Download
A oracle/testdata/src/main/callgraph.go View 1 1 chunk +54 lines, -0 lines 0 comments Download
A oracle/testdata/src/main/callgraph.golden View 1 1 chunk +20 lines, -0 lines 0 comments Download
A oracle/testdata/src/main/callgraph-json.go View 1 2 3 4 1 chunk +54 lines, -0 lines 0 comments Download
A oracle/testdata/src/main/callgraph-json.golden View 1 2 3 4 5 6 7 1 chunk +63 lines, -0 lines 0 comments Download
M oracle/testdata/src/main/calls.golden View 1 2 chunks +4 lines, -2 lines 0 comments Download
A oracle/testdata/src/main/calls-json.go View 1 2 3 4 1 chunk +16 lines, -0 lines 0 comments Download
A oracle/testdata/src/main/calls-json.golden View 1 2 3 4 5 6 7 1 chunk +33 lines, -0 lines 0 comments Download
M oracle/testdata/src/main/describe.golden View 1 2 chunks +2 lines, -2 lines 0 comments Download
A oracle/testdata/src/main/describe-json.go View 1 2 3 4 5 1 chunk +30 lines, -0 lines 0 comments Download
A oracle/testdata/src/main/describe-json.golden View 1 2 3 4 5 6 7 1 chunk +164 lines, -0 lines 0 comments Download
M oracle/testdata/src/main/freevars.golden View 1 1 chunk +3 lines, -3 lines 0 comments Download
M oracle/testdata/src/main/peers.golden View 1 2 chunks +6 lines, -6 lines 0 comments Download
A oracle/testdata/src/main/peers-json.go View 1 2 3 4 1 chunk +13 lines, -0 lines 0 comments Download
A oracle/testdata/src/main/peers-json.golden View 1 2 3 4 5 6 7 1 chunk +15 lines, -0 lines 0 comments Download
M pointer/analysis.go View 1 1 chunk +1 line, -1 line 0 comments Download
M pointer/api.go View 1 2 chunks +3 lines, -1 line 0 comments Download
M pointer/callgraph.go View 1 1 chunk +2 lines, -1 line 0 comments Download

Messages

Total messages: 8
adonovan
Hello crawshaw@google.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go.tools
8 years, 10 months ago (2013-08-30 02:03:52 UTC) #1
adonovan
Hello crawshaw@google.com (cc: golang-dev@googlegroups.com), Please take another look.
8 years, 10 months ago (2013-08-30 17:03:59 UTC) #2
crawshaw1
https://codereview.appspot.com/13270045/diff/15001/oracle/json.go File oracle/json.go (right): https://codereview.appspot.com/13270045/diff/15001/oracle/json.go#newcode19 oracle/json.go:19: type PeersJSON struct { Do these types need to ...
8 years, 10 months ago (2013-09-03 13:16:55 UTC) #3
adonovan
https://codereview.appspot.com/13270045/diff/15001/oracle/json.go File oracle/json.go (right): https://codereview.appspot.com/13270045/diff/15001/oracle/json.go#newcode19 oracle/json.go:19: type PeersJSON struct { On 2013/09/03 13:16:55, crawshaw1 wrote: ...
8 years, 10 months ago (2013-09-03 14:20:37 UTC) #4
crawshaw1
If ResultJSON is the exported interface to be used as an API by other Go ...
8 years, 10 months ago (2013-09-03 14:36:07 UTC) #5
adonovan
On 2013/09/03 14:36:07, crawshaw1 wrote: > If ResultJSON is the exported interface to be used ...
8 years, 10 months ago (2013-09-03 15:59:19 UTC) #6
crawshaw1
LGTM
8 years, 10 months ago (2013-09-03 19:20:13 UTC) #7
adonovan
8 years, 10 months ago (2013-09-03 19:29:10 UTC) #8
*** Submitted as
https://code.google.com/p/go/source/detail?r=e3058b01f286&repo=tools ***

go.tools/oracle: add option to output results in JSON syntax.

See json.go for interface specification.

Example usage:
% oracle -format=json -mode=callgraph code.google.com/p/go.tools/cmd/oracle

+ Tests, based on (small) golden files.

Overview:
  Each <query>Result structure has been "lowered" so that all
  but the most trivial logic in each display() function has
  been moved to the main query.

  Each one now has a toJSON method that populates a json.Result
  struct.  Though the <query>Result structs are similar to the
  correponding JSON protocol, they're not close enough to be
  used directly; for example, the former contain richer
  semantic entities (token.Pos, ast.Expr, ssa.Value,
  pointer.Pointer, etc) whereas JSON contains only their
  printed forms using Go basic types.

  The choices of what levels of abstractions the two sets of
  structs should have is somewhat arbitrary.  We may want
  richer information in the JSON output in future.

Details:
- oracle.Main has been split into oracle.Query() and the
  printing of the oracle.Result.
- the display() method no longer needs an *oracle param, only
  a print function.
- callees: sort the result for determinism.
- callees: compute the union across all contexts.
- callers: sort the results for determinism.
- describe(package): fixed a bug in the predicate for method
  accessibility: an unexported method defined in pkg A may
  belong to a type defined in package B (via
  embedding/promotion) and may thus be accessible to A.  New
  accessibleMethods() utility fixes this.
- describe(type): filter methods by accessibility.
- added tests of 'callgraph'.
- pointer: eliminated the 'caller CallGraphNode' parameter from
  pointer.Context.Call callback since it was redundant w.r.t
  site.Caller().
- added warning if CGO_ENABLED is unset.

R=crawshaw
CC=golang-dev
https://codereview.appspot.com/13270045
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b