[tools] gopls/internal/golang: allow rename of embedded fields at declaration

1 view
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Jul 8, 2025, 1:56:50 PMJul 8
to Madeline Kalil, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Alan Donovan, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

6 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/rename.go
Insertions: 0, Deletions: 10.

@@ -1681,13 +1681,3 @@
}
return diff.Edit{Start: startOffset, End: endOffset, New: new}, nil
}
-
-// enclosingFile returns the CompiledGoFile of pkg that contains the specified position.
-func enclosingFile(pkg *cache.Package, pos token.Pos) (*parsego.File, bool) {
- for _, pgf := range pkg.CompiledGoFiles() {
- if pgf.File.FileStart <= pos && pos <= pgf.File.FileEnd {
- return pgf, true
- }
- }
- return nil, false
-}
```

Change information

Commit message:
gopls/internal/golang: allow rename of embedded fields at declaration

We previously disabled renaming embedded fields (golang/go#43616).
This makes sense when the cursor is at a use of the embedded field,
but if the cursor is at the declaration of the embedded field within the
struct type declaration we should allow this operation.

Fixes golang/go#45199
Change-Id: I1af78205d5f2c865400bea0df55899588c1e8c56
Reviewed-by: Alan Donovan <adon...@google.com>
Auto-Submit: Madeline Kalil <mka...@google.com>
Files:
  • M gopls/internal/golang/rename.go
  • M gopls/internal/test/marker/testdata/rename/embed.txt
  • M gopls/internal/test/marker/testdata/rename/issue43616.txt
Change size: M
Delta: 3 files changed, 101 insertions(+), 55 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Alan Donovan
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I1af78205d5f2c865400bea0df55899588c1e8c56
Gerrit-Change-Number: 680655
Gerrit-PatchSet: 8
Gerrit-Owner: Madeline Kalil <mka...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages