summaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/tools/internal/modindex/lookup.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2025-03-24 10:50:19 +0000
committerLibravatar GitHub <noreply@github.com>2025-03-24 10:50:19 +0000
commita844f322eebec4ece384aedeb54b7276bccd1884 (patch)
treedea88ff03598bb04a347fdf9aba163f3754e3015 /vendor/golang.org/x/tools/internal/modindex/lookup.go
parent[chore]: Bump github.com/jackc/pgx/v5 from 5.7.2 to 5.7.3 (#3935) (diff)
downloadgotosocial-a844f322eebec4ece384aedeb54b7276bccd1884.tar.xz
[chore]: Bump github.com/miekg/dns from 1.1.63 to 1.1.64 (#3936)
Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.63 to 1.1.64. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.63...v1.1.64) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/golang.org/x/tools/internal/modindex/lookup.go')
-rw-r--r--vendor/golang.org/x/tools/internal/modindex/lookup.go35
1 files changed, 34 insertions, 1 deletions
diff --git a/vendor/golang.org/x/tools/internal/modindex/lookup.go b/vendor/golang.org/x/tools/internal/modindex/lookup.go
index 29d4e3d7a..5499c5c67 100644
--- a/vendor/golang.org/x/tools/internal/modindex/lookup.go
+++ b/vendor/golang.org/x/tools/internal/modindex/lookup.go
@@ -16,6 +16,7 @@ type Candidate struct {
Dir string
ImportPath string
Type LexType
+ Deprecated bool
// information for Funcs
Results int16 // how many results
Sig []Field // arg names and types
@@ -34,6 +35,36 @@ const (
Func
)
+// LookupAll only returns those Candidates whose import path
+// finds all the nms.
+func (ix *Index) LookupAll(pkg string, names ...string) map[string][]Candidate {
+ // this can be made faster when benchmarks show that it needs to be
+ names = uniquify(names)
+ byImpPath := make(map[string][]Candidate)
+ for _, nm := range names {
+ cands := ix.Lookup(pkg, nm, false)
+ for _, c := range cands {
+ byImpPath[c.ImportPath] = append(byImpPath[c.ImportPath], c)
+ }
+ }
+ for k, v := range byImpPath {
+ if len(v) != len(names) {
+ delete(byImpPath, k)
+ }
+ }
+ return byImpPath
+}
+
+// remove duplicates
+func uniquify(in []string) []string {
+ if len(in) == 0 {
+ return in
+ }
+ in = slices.Clone(in)
+ slices.Sort(in)
+ return slices.Compact(in)
+}
+
// Lookup finds all the symbols in the index with the given PkgName and name.
// If prefix is true, it finds all of these with name as a prefix.
func (ix *Index) Lookup(pkg, name string, prefix bool) []Candidate {
@@ -79,8 +110,9 @@ func (ix *Index) Lookup(pkg, name string, prefix bool) []Candidate {
Dir: string(e.Dir),
ImportPath: e.ImportPath,
Type: asLexType(flds[1][0]),
+ Deprecated: len(flds[1]) > 1 && flds[1][1] == 'D',
}
- if flds[1] == "F" {
+ if px.Type == Func {
n, err := strconv.Atoi(flds[2])
if err != nil {
continue // should never happen
@@ -111,6 +143,7 @@ func toFields(sig []string) []Field {
}
// benchmarks show this is measurably better than strings.Split
+// split into first 4 fields separated by single space
func fastSplit(x string) []string {
ans := make([]string, 0, 4)
nxt := 0