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

Delta Between Two Patch Sets: oracle/callers.go

Issue 13270045: code review 13270045: go.tools/oracle: add option to output results in JSON s... (Closed)
Left Patch Set: diff -r 7c53df5c9267 https://code.google.com/p/go.tools Created 10 years, 6 months ago
Right Patch Set: diff -r 07183b5c385c https://code.google.com/p/go.tools Created 10 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « oracle/callees.go ('k') | oracle/callgraph.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package oracle 5 package oracle
6 6
7 import ( 7 import (
8 "go/token" 8 "go/token"
9 9
10 "code.google.com/p/go.tools/oracle/json"
10 "code.google.com/p/go.tools/pointer" 11 "code.google.com/p/go.tools/pointer"
11 "code.google.com/p/go.tools/ssa" 12 "code.google.com/p/go.tools/ssa"
12 ) 13 )
13 14
14 // Callers reports the possible callers of the function 15 // Callers reports the possible callers of the function
15 // immediately enclosing the specified source location. 16 // immediately enclosing the specified source location.
16 // 17 //
17 // TODO(adonovan): if a caller is a wrapper, show the caller's caller. 18 // TODO(adonovan): if a caller is a wrapper, show the caller's caller.
18 // 19 //
19 func callers(o *oracle) (queryResult, error) { 20 func callers(o *oracle) (queryResult, error) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 for _, site := range r.calls { 66 for _, site := range r.calls {
66 if site.Caller() == r.root { 67 if site.Caller() == r.root {
67 printf(r.target, "the root of the call graph") 68 printf(r.target, "the root of the call graph")
68 } else { 69 } else {
69 printf(site, "\t%s from %s", site.Description(), site.Caller().Func()) 70 printf(site, "\t%s from %s", site.Description(), site.Caller().Func())
70 } 71 }
71 } 72 }
72 } 73 }
73 } 74 }
74 75
75 func (r *callersResult) toJSON(res *ResultJSON, fset *token.FileSet) { 76 func (r *callersResult) toJSON(res *json.Result, fset *token.FileSet) {
76 » var callers []CallerJSON 77 » var callers []json.Caller
77 for _, site := range r.calls { 78 for _, site := range r.calls {
78 » » var c CallerJSON 79 » » var c json.Caller
79 c.Caller = site.Caller().Func().String() 80 c.Caller = site.Caller().Func().String()
80 if site.Caller() == r.root { 81 if site.Caller() == r.root {
81 c.Desc = "synthetic call" 82 c.Desc = "synthetic call"
82 } else { 83 } else {
83 c.Pos = site.Caller().Func().Prog.Fset.Position(site.Pos ()).String() 84 c.Pos = site.Caller().Func().Prog.Fset.Position(site.Pos ()).String()
84 c.Desc = site.Description() 85 c.Desc = site.Description()
85 } 86 }
86 callers = append(callers, c) 87 callers = append(callers, c)
87 } 88 }
88 res.Callers = callers 89 res.Callers = callers
89 } 90 }
LEFTRIGHT

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