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

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

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