Skip to content

Commit be644c7

Browse files
adonovangopherbot
authored andcommitted
x/tools: remove some dead functions
Change-Id: I3f313881123b7ecdb7937cd78424be23ea04fea2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/703875 LUCI-TryBot-Result: Go LUCI <[email protected]> Commit-Queue: Alan Donovan <[email protected]> Auto-Submit: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent db38d36 commit be644c7

File tree

7 files changed

+3
-94
lines changed

7 files changed

+3
-94
lines changed

gopls/internal/analysis/unusedparams/unusedparams.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ funcloop:
179179
// Edge case: _ = func() {...}
180180
// has no local var. Fake one.
181181
v := types.NewVar(id.Pos(), pass.Pkg, id.Name, pass.TypesInfo.TypeOf(n))
182-
typesinternal.SetVarKind(v, typesinternal.LocalVar)
182+
v.SetKind(types.LocalVar)
183183
fn = v
184184
}
185185
}

gopls/internal/golang/completion/util.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"golang.org/x/tools/gopls/internal/util/safetoken"
1616
"golang.org/x/tools/internal/diff"
1717
"golang.org/x/tools/internal/typeparams"
18-
"golang.org/x/tools/internal/typesinternal"
1918
)
2019

2120
// exprAtPos returns the index of the expression containing pos.
@@ -128,7 +127,7 @@ func resolveInvalid(fset *token.FileSet, obj types.Object, node ast.Node, info *
128127
typename := golang.FormatNode(fset, resultExpr)
129128
typ := types.NewNamed(types.NewTypeName(token.NoPos, obj.Pkg(), typename, nil), types.Typ[types.Invalid], nil)
130129
v := types.NewVar(obj.Pos(), obj.Pkg(), obj.Name(), typ)
131-
typesinternal.SetVarKind(v, typesinternal.PackageVar)
130+
v.SetKind(types.PackageVar)
132131
return v
133132
}
134133

imports/forward.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,3 @@ func Process(filename string, src []byte, opt *Options) ([]byte, error) {
6969
}
7070
return intimp.Process(filename, src, intopt)
7171
}
72-
73-
// VendorlessPath returns the devendorized version of the import path ipath.
74-
// For example, VendorlessPath("foo/bar/vendor/a/b") returns "a/b".
75-
func VendorlessPath(ipath string) string {
76-
return intimp.VendorlessPath(ipath)
77-
}

internal/analysisinternal/analysis.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,6 @@ func TypeErrorEndPos(fset *token.FileSet, src []byte, start token.Pos) token.Pos
7474
return end
7575
}
7676

77-
// WalkASTWithParent walks the AST rooted at n. The semantics are
78-
// similar to ast.Inspect except it does not call f(nil).
79-
func WalkASTWithParent(n ast.Node, f func(n ast.Node, parent ast.Node) bool) {
80-
var ancestors []ast.Node
81-
ast.Inspect(n, func(n ast.Node) (recurse bool) {
82-
if n == nil {
83-
ancestors = ancestors[:len(ancestors)-1]
84-
return false
85-
}
86-
87-
var parent ast.Node
88-
if len(ancestors) > 0 {
89-
parent = ancestors[len(ancestors)-1]
90-
}
91-
ancestors = append(ancestors, n)
92-
return f(n, parent)
93-
})
94-
}
95-
9677
// MatchingIdents finds the names of all identifiers in 'node' that match any of the given types.
9778
// 'pos' represents the position at which the identifiers may be inserted. 'pos' must be within
9879
// the scope of each of identifier we select. Otherwise, we will insert a variable at 'pos' that

internal/goroot/importcfg.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,18 @@
44

55
// Package goroot is a copy of package internal/goroot
66
// in the main GO repot. It provides a utility to produce
7-
// an importcfg and import path to package file map mapping
7+
// an import path to package file map mapping
88
// standard library packages to the locations of their export
99
// data files.
1010
package goroot
1111

1212
import (
13-
"bytes"
1413
"fmt"
1514
"os/exec"
1615
"strings"
1716
"sync"
1817
)
1918

20-
// Importcfg returns an importcfg file to be passed to the
21-
// Go compiler that contains the cached paths for the .a files for the
22-
// standard library.
23-
func Importcfg() (string, error) {
24-
var icfg bytes.Buffer
25-
26-
m, err := PkgfileMap()
27-
if err != nil {
28-
return "", err
29-
}
30-
fmt.Fprintf(&icfg, "# import config")
31-
for importPath, export := range m {
32-
fmt.Fprintf(&icfg, "\npackagefile %s=%s", importPath, export)
33-
}
34-
s := icfg.String()
35-
return s, nil
36-
}
37-
3819
var (
3920
stdlibPkgfileMap map[string]string
4021
stdlibPkgfileErr error

internal/mcp/internal/util/util.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,11 @@
55
package util
66

77
import (
8-
"cmp"
98
"fmt"
10-
"iter"
119
"reflect"
12-
"slices"
1310
"strings"
1411
)
1512

16-
// Helpers below are copied from gopls' moremaps package.
17-
18-
// Sorted returns an iterator over the entries of m in key order.
19-
func Sorted[M ~map[K]V, K cmp.Ordered, V any](m M) iter.Seq2[K, V] {
20-
// TODO(adonovan): use maps.Sorted if proposal #68598 is accepted.
21-
return func(yield func(K, V) bool) {
22-
keys := KeySlice(m)
23-
slices.Sort(keys)
24-
for _, k := range keys {
25-
if !yield(k, m[k]) {
26-
break
27-
}
28-
}
29-
}
30-
}
31-
32-
// KeySlice returns the keys of the map M, like slices.Collect(maps.Keys(m)).
33-
func KeySlice[M ~map[K]V, K comparable, V any](m M) []K {
34-
r := make([]K, 0, len(m))
35-
for k := range m {
36-
r = append(r, k)
37-
}
38-
return r
39-
}
40-
4113
type JSONInfo struct {
4214
Omit bool // unexported or first tag element is "-"
4315
Name string // Go field name or first tag element. Empty if Omit is true.

internal/testenv/testenv.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
"golang.org/x/mod/modfile"
2727
"golang.org/x/tools/internal/gocommand"
28-
"golang.org/x/tools/internal/goroot"
2928
)
3029

3130
// packageMainIsDevel reports whether the module containing package main
@@ -423,23 +422,6 @@ func Deadline(t testing.TB) (time.Time, bool) {
423422
return td.Deadline()
424423
}
425424

426-
// WriteImportcfg writes an importcfg file used by the compiler or linker to
427-
// dstPath containing entries for the packages in std and cmd in addition
428-
// to the package to package file mappings in additionalPackageFiles.
429-
func WriteImportcfg(t testing.TB, dstPath string, additionalPackageFiles map[string]string) {
430-
importcfg, err := goroot.Importcfg()
431-
for k, v := range additionalPackageFiles {
432-
importcfg += fmt.Sprintf("\npackagefile %s=%s", k, v)
433-
}
434-
if err != nil {
435-
t.Fatalf("preparing the importcfg failed: %s", err)
436-
}
437-
os.WriteFile(dstPath, []byte(importcfg), 0655)
438-
if err != nil {
439-
t.Fatalf("writing the importcfg failed: %s", err)
440-
}
441-
}
442-
443425
var (
444426
gorootOnce sync.Once
445427
gorootPath string

0 commit comments

Comments
 (0)