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

Delta Between Two Patch Sets: oracle/implements.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, 7 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/freevars.go ('k') | oracle/json/json.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 "encoding/json"
9 "go/token" 8 "go/token"
10 9
11 "code.google.com/p/go.tools/go/types" 10 "code.google.com/p/go.tools/go/types"
11 "code.google.com/p/go.tools/oracle/json"
12 "code.google.com/p/go.tools/ssa" 12 "code.google.com/p/go.tools/ssa"
13 ) 13 )
14 14
15 // Implements displays the 'implements" relation among all 15 // Implements displays the 'implements" relation among all
16 // package-level named types in the package containing the query 16 // package-level named types in the package containing the query
17 // position. 17 // position.
18 // 18 //
19 // TODO(adonovan): more features: 19 // TODO(adonovan): more features:
20 // - should we include pairs of types belonging to 20 // - should we include pairs of types belonging to
21 // different packages in the 'implements' relation? 21 // different packages in the 'implements' relation?
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 var prevIface *types.Named 84 var prevIface *types.Named
85 for _, fact := range r.facts { 85 for _, fact := range r.facts {
86 if fact.iface != prevIface { 86 if fact.iface != prevIface {
87 printf(fact.iface.Obj(), "\tInterface %s:", fact.iface) 87 printf(fact.iface.Obj(), "\tInterface %s:", fact.iface)
88 prevIface = fact.iface 88 prevIface = fact.iface
89 } 89 }
90 printf(deref(fact.conc).(*types.Named).Obj(), "\t\t%s", fact.con c) 90 printf(deref(fact.conc).(*types.Named).Obj(), "\t\t%s", fact.con c)
91 } 91 }
92 } 92 }
93 93
94 func (r *implementsResult) MarshalJSON() ([]byte, error) { 94 func (r *implementsResult) toJSON(res *json.Result, fset *token.FileSet) {
95 » var facts []*ImplementsJSON 95 » var facts []*json.Implements
96 for _, fact := range r.facts { 96 for _, fact := range r.facts {
97 » » facts = append(facts, &ImplementsJSON{ 97 » » facts = append(facts, &json.Implements{
98 I: fact.iface.String(), 98 I: fact.iface.String(),
99 » » » IPos: r.fset.Position(fact.iface.Obj().Pos()).String(), 99 » » » IPos: fset.Position(fact.iface.Obj().Pos()).String(),
100 C: fact.conc.String(), 100 C: fact.conc.String(),
101 » » » CPos: r.fset.Position(deref(fact.conc).(*types.Named).Ob j().Pos()).String(), 101 » » » CPos: fset.Position(deref(fact.conc).(*types.Named).Obj( ).Pos()).String(),
102 }) 102 })
103 } 103 }
104 » return json.Marshal(facts) 104 » res.Implements = facts
105 } 105 }
LEFTRIGHT

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