[vscode-go] extension/src/language: extend range support to type def

5 views
Skip to first unread message

Hongxiang Jiang (Gerrit)

unread,
Dec 5, 2025, 9:46:43 PM (11 days ago) Dec 5
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Hongxiang Jiang has uploaded the change for review

Commit message

extension/src/language: extend range support to type def

gopls.lsp is triggered programmerly by the language client,
if error encountered, the vscode will pop up notifications
as if the ongoing LSP method is blocking. This CL also
suppress the error encountered gopls.lsp command.
Change-Id: Ia064a7bb149bee632198c7affb0e975de2fe7e0c

Change diff

diff --git a/extension/src/language/goLanguageServer.ts b/extension/src/language/goLanguageServer.ts
index 735f751..6d08f83 100644
--- a/extension/src/language/goLanguageServer.ts
+++ b/extension/src/language/goLanguageServer.ts
@@ -477,6 +477,31 @@
}
},
middleware: {
+ provideTypeDefinition: async (doc, pos, token, next) => {
+ if (!goCtx.languageClient) {
+ return await next(doc, pos, token);
+ }
+
+ const editor = vscode.window.activeTextEditor;
+ if (!editor || doc !== editor.document) {
+ return await next(doc, pos, token);
+ }
+
+ const selection = editor?.selection;
+ if (selection.isEmpty || !selection.contains(pos)) {
+ return await next(doc, pos, token);
+ }
+
+ // Attaching selected range to gopls type def request.
+ const param = goCtx.languageClient.code2ProtocolConverter.asTextDocumentPositionParams(doc, pos);
+ (param as any).range = goCtx.languageClient.code2ProtocolConverter.asRange(selection);
+
+ const result: any = await vscode.commands.executeCommand('gopls.lsp', {
+ method: 'textDocument/typeDefinition',
+ param: param
+ });
+ return goCtx.languageClient.protocol2CodeConverter.asDefinitionResult(result);
+ },
provideHover: async (doc, pos, token, next) => {
// gopls.lsp is a command that acts as a dispatcher, allowing
// the client to trigger any LSP RPC via "workspace/executeCommand"
@@ -492,7 +517,7 @@
}

const selection = editor?.selection;
- if (!selection || !selection.contains(pos)) {
+ if (selection.isEmpty || !selection.contains(pos)) {
return await next(doc, pos, token);
}

@@ -597,8 +622,9 @@

return res;
} catch (e) {
- // Suppress error messages for frequently triggered commands.
- if (command === 'gopls.package_symbols') {
+ // Suppress error messages for frequently triggered
+ // or programmerly triggered commads.
+ if (command === 'gopls.package_symbols' || command === 'gopls.lsp') {
return null;
}
// TODO: how to print ${e} reliably???

Change information

Files:
  • M extension/src/language/goLanguageServer.ts
Change size: S
Delta: 1 file changed, 29 insertions(+), 3 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: Ia064a7bb149bee632198c7affb0e975de2fe7e0c
Gerrit-Change-Number: 727560
Gerrit-PatchSet: 1
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
unsatisfied_requirement
satisfied_requirement
open
diffy

Madeline Kalil (Gerrit)

unread,
Dec 8, 2025, 10:16:14 AM (9 days ago) Dec 8
to Hongxiang Jiang, goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Hongxiang Jiang

Madeline Kalil voted and added 1 comment

Votes added by Madeline Kalil

Code-Review+2

1 comment

File extension/src/language/goLanguageServer.ts
Line 626, Patchset 1 (Latest): // or programmerly triggered commads.
Madeline Kalil . unresolved

"programmatically" ? As in it's not triggered directly by the user, it's triggered internally by the extension, if that's what you mean?

Open in Gerrit

Related details

Attention is currently required from:
  • Hongxiang Jiang
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: Ia064a7bb149bee632198c7affb0e975de2fe7e0c
Gerrit-Change-Number: 727560
Gerrit-PatchSet: 1
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Comment-Date: Mon, 08 Dec 2025 15:16:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Dec 8, 2025, 9:30:10 PM (8 days ago) Dec 8
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Hongxiang Jiang

Hongxiang Jiang uploaded new patchset

Hongxiang Jiang uploaded patch set #2 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • Hongxiang Jiang
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: Ia064a7bb149bee632198c7affb0e975de2fe7e0c
Gerrit-Change-Number: 727560
Gerrit-PatchSet: 2
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Dec 8, 2025, 9:30:35 PM (8 days ago) Dec 8
to goph...@pubsubhelper.golang.org, Alan Donovan, Madeline Kalil, Gopher Robot, golang-co...@googlegroups.com

Hongxiang Jiang added 1 comment

File extension/src/language/goLanguageServer.ts
Line 626, Patchset 1: // or programmerly triggered commads.
Madeline Kalil . resolved

"programmatically" ? As in it's not triggered directly by the user, it's triggered internally by the extension, if that's what you mean?

Hongxiang Jiang

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: Ia064a7bb149bee632198c7affb0e975de2fe7e0c
Gerrit-Change-Number: 727560
Gerrit-PatchSet: 1
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-CC: Alan Donovan <adon...@google.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Comment-Date: Tue, 09 Dec 2025 02:30:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Madeline Kalil <mka...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Dec 8, 2025, 9:31:11 PM (8 days ago) Dec 8
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Hongxiang Jiang uploaded new patchset

Hongxiang Jiang uploaded patch set #3 to this change.
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: Ia064a7bb149bee632198c7affb0e975de2fe7e0c
Gerrit-Change-Number: 727560
Gerrit-PatchSet: 3
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Dec 8, 2025, 9:32:03 PM (8 days ago) Dec 8
to goph...@pubsubhelper.golang.org, Alan Donovan, Madeline Kalil, Gopher Robot, golang-co...@googlegroups.com

Hongxiang Jiang voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: Ia064a7bb149bee632198c7affb0e975de2fe7e0c
Gerrit-Change-Number: 727560
Gerrit-PatchSet: 3
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-CC: Alan Donovan <adon...@google.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Comment-Date: Tue, 09 Dec 2025 02:31:58 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Dec 8, 2025, 9:32:19 PM (8 days ago) Dec 8
to goph...@pubsubhelper.golang.org, Go LUCI, Alan Donovan, Madeline Kalil, Gopher Robot, golang-co...@googlegroups.com

Hongxiang Jiang voted and added 1 comment

Votes added by Hongxiang Jiang

Hold+1

1 comment

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Hongxiang Jiang . resolved

Waiting for gopls CL to merge first.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Holds
  • requirement satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: Ia064a7bb149bee632198c7affb0e975de2fe7e0c
Gerrit-Change-Number: 727560
Gerrit-PatchSet: 3
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-CC: Alan Donovan <adon...@google.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Comment-Date: Tue, 09 Dec 2025 02:32:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Dec 8, 2025, 10:05:42 PM (8 days ago) Dec 8
to goph...@pubsubhelper.golang.org, Go LUCI, Alan Donovan, Madeline Kalil, Gopher Robot, golang-co...@googlegroups.com

Hongxiang Jiang voted

Commit-Queue+1
Hold+1
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Holds
  • requirement satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: Ia064a7bb149bee632198c7affb0e975de2fe7e0c
Gerrit-Change-Number: 727560
Gerrit-PatchSet: 4
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-CC: Alan Donovan <adon...@google.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Comment-Date: Tue, 09 Dec 2025 03:05:37 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Dec 9, 2025, 1:42:53 AM (8 days ago) Dec 9
to goph...@pubsubhelper.golang.org, Go LUCI, Alan Donovan, Madeline Kalil, Gopher Robot, golang-co...@googlegroups.com

Hongxiang Jiang voted Commit-Queue+1

Commit-Queue+1
Gerrit-Comment-Date: Tue, 09 Dec 2025 06:42:46 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Dec 16, 2025, 3:13:01 PM (11 hours ago) Dec 16
to goph...@pubsubhelper.golang.org, Go LUCI, Alan Donovan, Madeline Kalil, Gopher Robot, golang-co...@googlegroups.com

Hongxiang Jiang voted

Auto-Submit+1
Commit-Queue+1
Hold+0
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: Ia064a7bb149bee632198c7affb0e975de2fe7e0c
Gerrit-Change-Number: 727560
Gerrit-PatchSet: 5
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-CC: Alan Donovan <adon...@google.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Comment-Date: Tue, 16 Dec 2025 20:12:54 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Gopher Robot (Gerrit)

unread,
Dec 16, 2025, 3:29:49 PM (11 hours ago) Dec 16
to Hongxiang Jiang, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Alan Donovan, Madeline Kalil, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

1 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: extension/src/language/goLanguageServer.ts
Insertions: 1, Deletions: 1.

@@ -623,7 +623,7 @@
return res;
} catch (e) {

// Suppress error messages for frequently triggered
-						// or programmerly triggered commads.
+ // or programmatically triggered commads.

if (command === 'gopls.package_symbols' || command === 'gopls.lsp') {
return null;
}
```

Change information

Commit message:
extension/src/language: extend range support to type def

gopls.lsp is triggered programmatically by the language client,

if error encountered, the vscode will pop up notifications
as if the ongoing LSP method is blocking. This CL also
suppress the error encountered gopls.lsp command.

Gopls CL 728600

For golang/go#76723
Change-Id: Ia064a7bb149bee632198c7affb0e975de2fe7e0c
Reviewed-by: Madeline Kalil <mka...@google.com>
Auto-Submit: Hongxiang Jiang <hxj...@golang.org>
Files:
  • M extension/src/language/goLanguageServer.ts
Change size: S
Delta: 1 file changed, 29 insertions(+), 3 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Madeline Kalil
  • 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: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: Ia064a7bb149bee632198c7affb0e975de2fe7e0c
Gerrit-Change-Number: 727560
Gerrit-PatchSet: 6
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages