@@ -26,9 +26,7 @@ import (
26
26
"golang.org/x/tools/gopls/internal/lsp/filecache"
27
27
"golang.org/x/tools/gopls/internal/lsp/protocol"
28
28
"golang.org/x/tools/gopls/internal/lsp/source"
29
- "golang.org/x/tools/gopls/internal/lsp/source/methodsets"
30
29
"golang.org/x/tools/gopls/internal/lsp/source/typerefs"
31
- "golang.org/x/tools/gopls/internal/lsp/source/xrefs"
32
30
"golang.org/x/tools/gopls/internal/span"
33
31
"golang.org/x/tools/internal/event"
34
32
"golang.org/x/tools/internal/event/tag"
@@ -44,6 +42,8 @@ const (
44
42
preserveImportGraph = true // hold on to the import graph for open packages
45
43
)
46
44
45
+ type unit = struct {}
46
+
47
47
// A typeCheckBatch holds data for a logical type-checking operation, which may
48
48
// type-check many unrelated packages.
49
49
//
@@ -56,7 +56,7 @@ type typeCheckBatch struct {
56
56
handles map [PackageID ]* packageHandle
57
57
parseCache * parseCache
58
58
fset * token.FileSet // describes all parsed or imported files
59
- cpulimit chan struct {} // concurrency limiter for CPU-bound operations
59
+ cpulimit chan unit // concurrency limiter for CPU-bound operations
60
60
61
61
mu sync.Mutex
62
62
syntaxPackages map [PackageID ]* futurePackage // results of processing a requested package; may hold (nil, nil)
@@ -69,7 +69,7 @@ type typeCheckBatch struct {
69
69
// The goroutine that creates the futurePackage is responsible for evaluating
70
70
// its value, and closing the done channel.
71
71
type futurePackage struct {
72
- done chan struct {}
72
+ done chan unit
73
73
v pkgOrErr
74
74
}
75
75
@@ -154,7 +154,7 @@ func (s *snapshot) getImportGraph(ctx context.Context) *importGraph {
154
154
// for the work to be done.
155
155
done := s .importGraphDone
156
156
if done == nil {
157
- done = make (chan struct {} )
157
+ done = make (chan unit )
158
158
s .importGraphDone = done
159
159
release := s .Acquire () // must acquire to use the snapshot asynchronously
160
160
go func () {
@@ -360,7 +360,7 @@ func (s *snapshot) forEachPackageInternal(ctx context.Context, importGraph *impo
360
360
handles : handles ,
361
361
fset : fileSetWithBase (reservedForParsing ),
362
362
syntaxIndex : make (map [PackageID ]int ),
363
- cpulimit : make (chan struct {} , runtime .GOMAXPROCS (0 )),
363
+ cpulimit : make (chan unit , runtime .GOMAXPROCS (0 )),
364
364
syntaxPackages : make (map [PackageID ]* futurePackage ),
365
365
importPackages : make (map [PackageID ]* futurePackage ),
366
366
}
@@ -369,7 +369,7 @@ func (s *snapshot) forEachPackageInternal(ctx context.Context, importGraph *impo
369
369
// Clone the file set every time, to ensure we do not leak files.
370
370
b .fset = tokeninternal .CloneFileSet (importGraph .fset )
371
371
// Pre-populate future cache with 'done' futures.
372
- done := make (chan struct {} )
372
+ done := make (chan unit )
373
373
close (done )
374
374
for id , res := range importGraph .imports {
375
375
b .importPackages [id ] = & futurePackage {done , res }
@@ -427,7 +427,7 @@ func (b *typeCheckBatch) getImportPackage(ctx context.Context, id PackageID) (pk
427
427
}
428
428
}
429
429
430
- f = & futurePackage {done : make (chan struct {} )}
430
+ f = & futurePackage {done : make (chan unit )}
431
431
b .importPackages [id ] = f
432
432
b .mu .Unlock ()
433
433
@@ -479,7 +479,7 @@ func (b *typeCheckBatch) handleSyntaxPackage(ctx context.Context, i int, id Pack
479
479
return f .v .pkg , f .v .err
480
480
}
481
481
482
- f = & futurePackage {done : make (chan struct {} )}
482
+ f = & futurePackage {done : make (chan unit )}
483
483
b .syntaxPackages [id ] = f
484
484
b .mu .Unlock ()
485
485
defer func () {
@@ -508,7 +508,7 @@ func (b *typeCheckBatch) handleSyntaxPackage(ctx context.Context, i int, id Pack
508
508
select {
509
509
case <- ctx .Done ():
510
510
return nil , ctx .Err ()
511
- case b .cpulimit <- struct {} {}:
511
+ case b .cpulimit <- unit {}:
512
512
defer func () {
513
513
<- b .cpulimit // release CPU token
514
514
}()
@@ -637,8 +637,8 @@ func (b *typeCheckBatch) checkPackage(ctx context.Context, ph *packageHandle) (*
637
637
// Write package data to disk asynchronously.
638
638
go func () {
639
639
toCache := map [string ][]byte {
640
- xrefsKind : pkg .xrefs ,
641
- methodSetsKind : pkg .methodsets .Encode (),
640
+ xrefsKind : pkg .xrefs () ,
641
+ methodSetsKind : pkg .methodsets () .Encode (),
642
642
diagnosticsKind : encodeDiagnostics (pkg .diagnostics ),
643
643
}
644
644
@@ -763,13 +763,13 @@ func (s *snapshot) getPackageHandles(ctx context.Context, ids []PackageID) (map[
763
763
// Collect all reachable IDs, and create done channels.
764
764
// TODO: opt: modify SortPostOrder to make this pre-traversal unnecessary.
765
765
var allIDs []PackageID
766
- dones := make (map [PackageID ]chan struct {} )
766
+ dones := make (map [PackageID ]chan unit )
767
767
var walk func (PackageID )
768
768
walk = func (id PackageID ) {
769
769
if _ , ok := dones [id ]; ok {
770
770
return
771
771
}
772
- dones [id ] = make (chan struct {} )
772
+ dones [id ] = make (chan unit )
773
773
allIDs = append (allIDs , id )
774
774
m := meta .metadata [id ]
775
775
for _ , depID := range m .DepsByPkgPath {
@@ -1262,8 +1262,6 @@ func typeCheckImpl(ctx context.Context, b *typeCheckBatch, inputs typeCheckInput
1262
1262
if err != nil {
1263
1263
return nil , err
1264
1264
}
1265
- pkg .methodsets = methodsets .NewIndex (pkg .fset , pkg .types )
1266
- pkg .xrefs = xrefs .Index (pkg .compiledGoFiles , pkg .types , pkg .typesInfo )
1267
1265
1268
1266
// Our heuristic for whether to show type checking errors is:
1269
1267
// + If any file was 'fixed', don't show type checking errors as we
0 commit comments