Skip to content

Commit d98733b

Browse files
committed
chore: isolate code from x/tools
1 parent 00feff8 commit d98733b

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

Diff for: pkg/goanalysis/runner_action.go

-19
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ package goanalysis
22

33
import (
44
"fmt"
5-
"go/types"
6-
"reflect"
75
"runtime/debug"
86

9-
"golang.org/x/tools/go/analysis"
10-
117
"github.com/golangci/golangci-lint/internal/errorutil"
128
)
139

@@ -58,21 +54,6 @@ func (act *action) analyzeSafe() {
5854
act.r.sw.TrackStage(act.a.Name, act.analyze)
5955
}
6056

61-
// importPackageFact implements Pass.ImportPackageFact.
62-
// Given a non-nil pointer ptr of type *T, where *T satisfies Fact,
63-
// fact copies the fact value to *ptr.
64-
func (act *action) importPackageFact(pkg *types.Package, ptr analysis.Fact) bool {
65-
if pkg == nil {
66-
panic("nil package")
67-
}
68-
key := packageFactKey{pkg, act.factType(ptr)}
69-
if v, ok := act.packageFacts[key]; ok {
70-
reflect.ValueOf(ptr).Elem().Set(reflect.ValueOf(v).Elem())
71-
return true
72-
}
73-
return false
74-
}
75-
7657
func (act *action) markDepsForAnalyzingSource() {
7758
// Horizontal deps (analyzer.Requires) must be loaded from source and analyzed before analyzing
7859
// this action.

Diff for: pkg/goanalysis/runner_base.go

+16
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,22 @@ func (act *action) allObjectFacts() []analysis.ObjectFact {
301301
return out
302302
}
303303

304+
// NOTE(ldez) altered: `act.factType`
305+
// importPackageFact implements Pass.ImportPackageFact.
306+
// Given a non-nil pointer ptr of type *T, where *T satisfies Fact,
307+
// fact copies the fact value to *ptr.
308+
func (act *action) importPackageFact(pkg *types.Package, ptr analysis.Fact) bool {
309+
if pkg == nil {
310+
panic("nil package")
311+
}
312+
key := packageFactKey{pkg, act.factType(ptr)}
313+
if v, ok := act.packageFacts[key]; ok {
314+
reflect.ValueOf(ptr).Elem().Set(reflect.ValueOf(v).Elem())
315+
return true
316+
}
317+
return false
318+
}
319+
304320
// NOTE(ldez) altered: removes code related to `act.pass.ExportPackageFact`; logger; `act.factType`.
305321
// exportPackageFact implements Pass.ExportPackageFact.
306322
func (act *action) exportPackageFact(fact analysis.Fact) {

0 commit comments

Comments
 (0)