Unreviewed changes
2 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: gopls/internal/golang/type_definition.go
Insertions: 1, Deletions: 1.
@@ -19,7 +19,7 @@
)
// TypeDefinition handles the textDocument/typeDefinition request for Go files.
-func TypeDefinition(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, position protocol.Position) ([]protocol.Location, error) {
+func TypeDefinition(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, rng protocol.Range) ([]protocol.Location, error) {
ctx, done := event.Start(ctx, "golang.TypeDefinition")
defer done()
@@ -27,11 +27,11 @@
if err != nil {
return nil, err
}
- pos, err := pgf.PositionPos(position)
+ start, end, err := pgf.RangePos(rng)
if err != nil {
return nil, err
}
- cur, ok := pgf.Cursor().FindByPos(pos, pos)
+ cur, ok := pgf.Cursor().FindByPos(start, end)
if !ok {
return nil, fmt.Errorf("no enclosing syntax") // can't happen
}
@@ -69,13 +69,19 @@
if t == nil {
return nil, fmt.Errorf("no enclosing expression has a type")
}
- tname := typeToObject(t)
- if tname == nil {
- return nil, fmt.Errorf("cannot find type name from type %s", t)
+ tnames := typeToObjects(t)
+ if len(tnames) == 0 {
+ return nil, fmt.Errorf("cannot find type name(s) from type %s", t)
}
- loc, err := ObjectLocation(ctx, pkg.FileSet(), snapshot, tname)
- if err != nil {
- return nil, err
+
+ var locs []protocol.Location
+ for _, t := range tnames {
+ loc, err := ObjectLocation(ctx, pkg.FileSet(), snapshot, t)
+ if err != nil {
+ return nil, err
+ }
+ locs = append(locs, loc)
}
- return []protocol.Location{loc}, nil
+
+ return locs, nil
}
```
Change information
Commit message:
gopls/internal/cache/parsego: construct File.Cursor lazily
File.Cursor is now an accessor method.
This crude benchmark shows a significant improvement in wall time:
$ /usr/bin/time GOPLSCACHE=$(mktemp -d) gopls check ./main.go
before 3.920 3.927 4.081 4.279 4.416 4.542 5.453 mean=4.374
after 3.710 3.758 3.820 3.881 3.942 4.199 4.378 mean=3.955
Unfortunately our perf dashboard is currently down (golang/go#76873).
Fixes golang/go#76813
Change-Id: I822e20206e39d63fccc8ed11ee1f3ba45eca07d8
Files:
- M gopls/internal/analysis/fillstruct/fillstruct.go
- M gopls/internal/cache/parsego/file.go
- M gopls/internal/cache/parsego/parse.go
- M gopls/internal/cache/xrefs/xrefs.go
- M gopls/internal/golang/call_hierarchy.go
- M gopls/internal/golang/codeaction.go
- M gopls/internal/golang/definition.go
- M gopls/internal/golang/extract.go
- M gopls/internal/golang/folding_range.go
- M gopls/internal/golang/hover.go
- M gopls/internal/golang/implementation.go
- M gopls/internal/golang/inlay_hint.go
- M gopls/internal/golang/inline.go
- M gopls/internal/golang/invertifcondition.go
- M gopls/internal/golang/lines.go
- M gopls/internal/golang/modify_tags.go
- M gopls/internal/golang/references.go
- M gopls/internal/golang/rename.go
- M gopls/internal/golang/rename_check.go
- M gopls/internal/golang/stubmethods/stubcalledfunc.go
- M gopls/internal/golang/stubmethods/stubmethods.go
- M gopls/internal/golang/type_definition.go
- M gopls/internal/golang/type_hierarchy.go
- M gopls/internal/golang/undeclared.go
- M gopls/internal/mcp/file_context.go
- M gopls/internal/server/link.go
Change size: M
Delta: 26 files changed, 65 insertions(+), 61 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Madeline Kalil
TryBots-Pass: LUCI-TryBot-Result-1 by Go LUCI, TryBot-Bypass+1 by Alan Donovan