Skip to content

Commit 2f93c09

Browse files
committed
chore: isolate code from x/tools
1 parent 9ffeb58 commit 2f93c09

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

pkg/goanalysis/runner_action.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,21 +179,6 @@ func (act *action) analyze() {
179179
}
180180
}
181181

182-
// importObjectFact implements Pass.ImportObjectFact.
183-
// Given a non-nil pointer ptr of type *T, where *T satisfies Fact,
184-
// importObjectFact copies the fact value to *ptr.
185-
func (act *action) importObjectFact(obj types.Object, ptr analysis.Fact) bool {
186-
if obj == nil {
187-
panic("nil object")
188-
}
189-
key := objectFactKey{obj, act.factType(ptr)}
190-
if v, ok := act.objectFacts[key]; ok {
191-
reflect.ValueOf(ptr).Elem().Set(reflect.ValueOf(v).Elem())
192-
return true
193-
}
194-
return false
195-
}
196-
197182
// importPackageFact implements Pass.ImportPackageFact.
198183
// Given a non-nil pointer ptr of type *T, where *T satisfies Fact,
199184
// fact copies the fact value to *ptr.

pkg/goanalysis/runner_base.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ import (
1414
"golang.org/x/tools/go/analysis"
1515
)
1616

17+
// NOTE(ldez) altered: logger; `act.factType`
18+
// importObjectFact implements Pass.ImportObjectFact.
19+
// Given a non-nil pointer ptr of type *T, where *T satisfies Fact,
20+
// importObjectFact copies the fact value to *ptr.
21+
func (act *action) importObjectFact(obj types.Object, ptr analysis.Fact) bool {
22+
if obj == nil {
23+
panic("nil object")
24+
}
25+
key := objectFactKey{obj, act.factType(ptr)}
26+
if v, ok := act.objectFacts[key]; ok {
27+
reflect.ValueOf(ptr).Elem().Set(reflect.ValueOf(v).Elem())
28+
return true
29+
}
30+
return false
31+
}
32+
1733
// NOTE(ldez) altered: removes code related to `act.pass.ExportPackageFact`; logger; `act.factType`.
1834
// exportObjectFact implements Pass.ExportObjectFact.
1935
func (act *action) exportObjectFact(obj types.Object, fact analysis.Fact) {

0 commit comments

Comments
 (0)