Skip to content

Commit 87f6888

Browse files
committed
Merge remote-tracking branch 'origin/master' into gopls-release-branch.0.19
For golang/go#73965 Change-Id: I4f1f76735a8a745d7bf0f0a532f2ac9bb5f4ed01
2 parents d24e68d + 5af564a commit 87f6888

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1290
-851
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ go 1.23.0
55
require (
66
github.com/google/go-cmp v0.6.0
77
github.com/yuin/goldmark v1.4.13
8-
golang.org/x/mod v0.24.0
9-
golang.org/x/net v0.40.0
10-
golang.org/x/sync v0.14.0
8+
golang.org/x/mod v0.25.0
9+
golang.org/x/net v0.41.0
10+
golang.org/x/sync v0.15.0
1111
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457
1212
)
1313

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
22
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
33
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
44
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
5-
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
6-
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
7-
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
8-
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
9-
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
10-
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
5+
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
6+
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
7+
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
8+
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
9+
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
10+
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
1111
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
1212
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
1313
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457 h1:zf5N6UOrA487eEFacMePxjXAJctxKmyjKUsjA11Uzuk=

gopls/doc/features/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ when making significant changes to existing features or when adding new ones.
4242
- [Symbol](navigation.md#symbol): fuzzy search for symbol by name
4343
- [Selection Range](navigation.md#selection-range): select enclosing unit of syntax
4444
- [Call Hierarchy](navigation.md#call-hierarchy): show outgoing/incoming calls to the current function
45+
- [Type Hierarchy](navigation.md#type-hierarchy): show interfaces/implementations of the current type
4546
- [Completion](completion.md): context-aware completion of identifiers, statements
4647
- [Code transformation](transformation.md): fixes and refactorings
4748
- [Formatting](transformation.md#formatting): format the source code
@@ -58,6 +59,7 @@ when making significant changes to existing features or when adding new ones.
5859
- Support for non-Go files:
5960
- [Template files](templates.md): files parsed by `text/template` and `html/template`
6061
- [go.mod and go.work files](modfiles.md): Go module and workspace manifests
62+
- [Go *.s assembly files](assembly.ms): Go assembly files
6163
- [Command-line interface](../command-line.md): CLI for debugging and scripting (unstable)
6264

6365
You can find this page from within your editor by executing the

gopls/doc/features/assembly.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Gopls: Support for Go *.s assembly files
2+
3+
Gopls has rudimentary support for LSP operations in Go assembly files.
4+
5+
Go assembly files have a `.s` file name extension. LSP clients need to
6+
be configured to recognize `.s` files as Go assembly files, since this
7+
file name extension is also used for assembly files in other
8+
languages. A good heuristic is that if a file named `*.s` belongs to a
9+
directory containing at least one `*.go` file, then the `.s` file is
10+
Go assembly, and its appropriate language server is gopls.
11+
12+
Only Definition (`textDocument/definition`) requests are currently
13+
supported. For example, a Definition request on the `sigpanic`
14+
symbol in this file in GOROOT/src/runtime/asm.s:
15+
16+
```asm
17+
JMP ·sigpanic<ABIInternal>(SB)
18+
```
19+
20+
returns the location of the function declaration in
21+
GOROOT/src/runtime/signal_unix.go:
22+
23+
```go
24+
//go:linkname sigpanic
25+
func sigpanic() {
26+
```
27+
28+
See also issue golang/go#71754, which tracks the development of LSP
29+
features in Go assembly files.

gopls/go.mod

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ require (
66
github.com/fatih/gomodifytags v1.17.1-0.20250423142747-f3939df9aa3c
77
github.com/google/go-cmp v0.6.0
88
github.com/jba/templatecheck v0.7.1
9-
golang.org/x/mod v0.24.0
10-
golang.org/x/sync v0.14.0
9+
golang.org/x/mod v0.25.0
10+
golang.org/x/sync v0.15.0
1111
golang.org/x/telemetry v0.0.0-20250417124945-06ef541f3fa3
12-
golang.org/x/text v0.25.0
13-
golang.org/x/tools v0.33.1-0.20250604180551-4d89d8aef849
12+
golang.org/x/text v0.26.0
13+
golang.org/x/tools v0.33.1-0.20250521210010-423c5afcceff
1414
golang.org/x/vuln v1.1.4
1515
gopkg.in/yaml.v3 v3.0.1
1616
honnef.co/go/tools v0.7.0-0.dev.0.20250523013057-bbc2f4dd71ea
@@ -27,3 +27,5 @@ require (
2727
golang.org/x/sys v0.33.0 // indirect
2828
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
2929
)
30+
31+
replace golang.org/x/tools => ../

gopls/go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
3535
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
3636
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
3737
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
38-
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
39-
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
38+
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
39+
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
4040
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
4141
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
4242
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
@@ -52,8 +52,8 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5252
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
5353
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
5454
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
55-
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
56-
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
55+
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
56+
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
5757
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
5858
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5959
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -88,17 +88,17 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
8888
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
8989
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
9090
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
91-
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
92-
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
91+
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
92+
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
9393
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
9494
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
9595
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
9696
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
9797
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
9898
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
9999
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
100-
golang.org/x/tools v0.33.1-0.20250604180551-4d89d8aef849 h1:y+3SPx7RmIoU/DCRF+k0+AhC/jvtMWEzb2m5j2j4OWA=
101-
golang.org/x/tools v0.33.1-0.20250604180551-4d89d8aef849/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI=
100+
golang.org/x/tools v0.33.1-0.20250521210010-423c5afcceff h1:bA6IPdkOZlJfemcA6L5+cR2eglJm0B1m7JgMNgZyfgs=
101+
golang.org/x/tools v0.33.1-0.20250521210010-423c5afcceff/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI=
102102
golang.org/x/vuln v1.1.4 h1:Ju8QsuyhX3Hk8ma3CesTbO8vfJD9EvUBgHvkxHBzj0I=
103103
golang.org/x/vuln v1.1.4/go.mod h1:F+45wmU18ym/ca5PLTPLsSzr2KppzswxPP603ldA67s=
104104
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

gopls/internal/cache/session.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type Session struct {
6464

6565
viewMu sync.Mutex
6666
views []*View
67-
viewMap map[protocol.DocumentURI]*View // file->best view or nil; nil after shutdown
67+
viewMap map[protocol.DocumentURI]*View // file->best view or nil; nil after shutdown; the key must be a clean uri.
6868

6969
// snapshots is a counting semaphore that records the number
7070
// of unreleased snapshots associated with this session.
@@ -139,15 +139,16 @@ func (s *Session) NewView(ctx context.Context, folder *Folder) (*View, *Snapshot
139139
}
140140
view, snapshot, release := s.createView(ctx, def)
141141
s.views = append(s.views, view)
142-
s.viewMap[protocol.Clean(folder.Dir)] = view
142+
s.viewMap[folder.Dir.Clean()] = view
143143
return view, snapshot, release, nil
144144
}
145145

146146
// HasView checks whether the uri's view exists.
147147
func (s *Session) HasView(uri protocol.DocumentURI) bool {
148+
uri = uri.Clean()
148149
s.viewMu.Lock()
149150
defer s.viewMu.Unlock()
150-
_, ok := s.viewMap[protocol.Clean(uri)]
151+
_, ok := s.viewMap[uri]
151152
return ok
152153
}
153154

@@ -379,6 +380,7 @@ func (s *Session) View(id string) (*View, error) {
379380
//
380381
// On success, the caller must call the returned function to release the snapshot.
381382
func (s *Session) SnapshotOf(ctx context.Context, uri protocol.DocumentURI) (*Snapshot, func(), error) {
383+
uri = uri.Clean()
382384
// Fast path: if the uri has a static association with a view, return it.
383385
s.viewMu.Lock()
384386
v, err := s.viewOfLocked(ctx, uri)
@@ -396,7 +398,7 @@ func (s *Session) SnapshotOf(ctx context.Context, uri protocol.DocumentURI) (*Sn
396398
// View is shut down. Forget this association.
397399
s.viewMu.Lock()
398400
if s.viewMap[uri] == v {
399-
delete(s.viewMap, protocol.Clean(uri))
401+
delete(s.viewMap, uri)
400402
}
401403
s.viewMu.Unlock()
402404
}
@@ -473,7 +475,7 @@ var errNoViews = errors.New("no views")
473475
// viewOfLocked evaluates the best view for uri, memoizing its result in
474476
// s.viewMap.
475477
//
476-
// Precondition: caller holds s.viewMu lock.
478+
// Precondition: caller holds s.viewMu lock; uri must be clean.
477479
//
478480
// May return (nil, nil) if no best view can be determined.
479481
func (s *Session) viewOfLocked(ctx context.Context, uri protocol.DocumentURI) (*View, error) {
@@ -500,7 +502,7 @@ func (s *Session) viewOfLocked(ctx context.Context, uri protocol.DocumentURI) (*
500502
// (as in golang/go#60776).
501503
v = relevantViews[0]
502504
}
503-
s.viewMap[protocol.Clean(uri)] = v // may be nil
505+
s.viewMap[uri] = v // may be nil
504506
}
505507
return v, nil
506508
}
@@ -748,7 +750,7 @@ func (s *Session) ResetView(ctx context.Context, uri protocol.DocumentURI) (*Vie
748750
return nil, fmt.Errorf("session is shut down")
749751
}
750752

751-
view, err := s.viewOfLocked(ctx, uri)
753+
view, err := s.viewOfLocked(ctx, uri.Clean())
752754
if err != nil {
753755
return nil, err
754756
}

gopls/internal/cache/source.go

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"golang.org/x/tools/gopls/internal/cache/metadata"
1515
"golang.org/x/tools/gopls/internal/cache/symbols"
1616
"golang.org/x/tools/gopls/internal/protocol"
17-
"golang.org/x/tools/internal/event"
17+
"golang.org/x/tools/gopls/internal/util/moremaps"
1818
"golang.org/x/tools/internal/imports"
1919
)
2020

@@ -136,27 +136,27 @@ func (s *goplsSource) ResolveReferences(ctx context.Context, filename string, mi
136136
func (s *goplsSource) resolveCacheReferences(missing imports.References) ([]*result, error) {
137137
ix, err := s.S.view.ModcacheIndex()
138138
if err != nil {
139-
event.Error(s.ctx, "resolveCacheReferences", err)
139+
return nil, err
140140
}
141141

142142
found := make(map[string]*result)
143-
for pkg, nms := range missing {
144-
var ks []string
145-
for k := range nms {
146-
ks = append(ks, k)
147-
}
148-
cs := ix.LookupAll(pkg, ks...) // map[importPath][]Candidate
149-
for k, cands := range cs {
150-
res := found[k]
143+
for pkgName, nameSet := range missing {
144+
names := moremaps.KeySlice(nameSet)
145+
for importPath, cands := range ix.LookupAll(pkgName, names...) {
146+
res := found[importPath]
151147
if res == nil {
152148
res = &result{
153-
&imports.Result{
154-
Import: &imports.ImportInfo{ImportPath: k},
155-
Package: &imports.PackageInfo{Name: pkg, Exports: make(map[string]bool)},
149+
res: &imports.Result{
150+
Import: &imports.ImportInfo{
151+
ImportPath: importPath,
152+
},
153+
Package: &imports.PackageInfo{
154+
Name: pkgName,
155+
Exports: make(map[string]bool)},
156156
},
157-
false,
157+
deprecated: false,
158158
}
159-
found[k] = res
159+
found[importPath] = res
160160
}
161161
for _, c := range cands {
162162
res.res.Package.Exports[c.Name] = true
@@ -166,11 +166,7 @@ func (s *goplsSource) resolveCacheReferences(missing imports.References) ([]*res
166166
}
167167

168168
}
169-
var ans []*result
170-
for _, x := range found {
171-
ans = append(ans, x)
172-
}
173-
return ans, nil
169+
return moremaps.ValueSlice(found), nil
174170
}
175171

176172
type found struct {

gopls/internal/cmd/serve.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ func (s *Serve) Run(ctx context.Context, args ...string) error {
105105
// event for a given LSP session ID is sent after its corresponding creation
106106
// event.
107107
var eventChan chan lsprpc.SessionEvent
108-
// cache shared between MCP and LSP servers.
109-
var ca *cache.Cache
110108

111109
if s.app.Remote != "" {
112110
var err error
@@ -118,8 +116,7 @@ func (s *Serve) Run(ctx context.Context, args ...string) error {
118116
if s.MCPAddress != "" {
119117
eventChan = make(chan lsprpc.SessionEvent)
120118
}
121-
ca = cache.New(nil)
122-
ss = lsprpc.NewStreamServer(ca, isDaemon, eventChan, s.app.options)
119+
ss = lsprpc.NewStreamServer(cache.New(nil), isDaemon, eventChan, s.app.options)
123120
}
124121

125122
group, ctx := errgroup.WithContext(ctx)
@@ -136,7 +133,7 @@ func (s *Serve) Run(ctx context.Context, args ...string) error {
136133
}
137134
}()
138135

139-
return mcp.Serve(ctx, s.MCPAddress, eventChan, ca, isDaemon)
136+
return mcp.Serve(ctx, s.MCPAddress, eventChan, isDaemon)
140137
})
141138
}
142139

gopls/internal/debug/flight.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ func startFlightRecorder() (http.HandlerFunc, error) {
113113
return
114114
}
115115

116+
// Some of the CI builders can be quite heavily loaded.
117+
// Give them an extra grace period.
118+
timeout := 10 * time.Second
119+
if os.Getenv("GO_BUILDER_NAME") != "" {
120+
timeout = 1 * time.Minute
121+
}
122+
116123
select {
117124
case addr := <-urlC:
118125
// Success! Send a redirect to the new location.
@@ -122,8 +129,8 @@ func startFlightRecorder() (http.HandlerFunc, error) {
122129
case <-r.Context().Done():
123130
errorf("canceled")
124131

125-
case <-time.After(10 * time.Second):
126-
errorf("trace viewer failed to start", err)
132+
case <-time.After(timeout):
133+
errorf("trace viewer failed to start within %v", timeout)
127134
}
128135
}, nil
129136
}

0 commit comments

Comments
 (0)